Class: Fluent::ReemitOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_reemit.rb

Instance Method Summary collapse

Constructor Details

#initializeReemitOutput

Returns a new instance of ReemitOutput.



10
11
12
13
# File 'lib/fluent/plugin/out_reemit.rb', line 10

def initialize
  super
  @match_cache = {}
end

Instance Method Details

#configure(conf) ⇒ Object



15
16
17
# File 'lib/fluent/plugin/out_reemit.rb', line 15

def configure(conf)
  super
end

#contain_self?(output) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
62
63
64
65
66
67
68
# File 'lib/fluent/plugin/out_reemit.rb', line 59

def contain_self?(output)
  if output.kind_of?(MultiOutput)
    output.outputs.each do |o|
      return true if contain_self?(o)
    end
  else
    return true if output == self
  end
  false
end

#emit(tag, es, chain) ⇒ Object



19
20
21
22
23
24
# File 'lib/fluent/plugin/out_reemit.rb', line 19

def emit(tag, es, chain)
  engine_emit(tag, es)
  chain.next
rescue => e
  log.warn "reemit: #{e.class} #{e.message} #{e.backtrace.first}"
end

#engine_emit(tag, es) ⇒ Object

My Engine.emit



27
28
29
30
31
32
33
34
# File 'lib/fluent/plugin/out_reemit.rb', line 27

def engine_emit(tag, es)
  target = @match_cache[tag]
  unless target
    target = engine_match(tag) || Fluent::EngineClass::NoMatchMatch.new
    @match_cache[tag] = target
  end
  target.emit(tag, es)
end

#engine_match(tag) ⇒ Object

My Engine.match



37
38
39
40
# File 'lib/fluent/plugin/out_reemit.rb', line 37

def engine_match(tag)
  # @matches.find {|m| m.match(tag) } # original Engine.match
  Engine.matches.find {|m| match_without_self(m, tag) }
end

#match_without_self(m, tag) ⇒ Object

<match foo.bar>

type reemit

</match>

and

<match foo.bar>

type copy
<store>
  type reemit
</store>

</match>



54
55
56
57
# File 'lib/fluent/plugin/out_reemit.rb', line 54

def match_without_self(m, tag)
  return false if contain_self?(m.output)
  m.match(tag)
end