Class: Fluent::Plugin::SplunkOutput::MatchFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/out_splunk/match_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(pattern, formatter) ⇒ MatchFormatter

Returns a new instance of MatchFormatter.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fluent/plugin/out_splunk/match_formatter.rb', line 6

def initialize(pattern, formatter)
  # based on fluentd/lib/fluent/event_router.rb
  patterns = pattern.split(/\s+/).map do |str|
    Fluent::MatchPattern.create(str)
  end
  @pattern =
    if patterns.length == 1
      patterns[0]
    else
      Fluent::OrMatchPattern.new(patterns)
    end
  @formatter = formatter
end

Instance Method Details

#format(tag, time, record) ⇒ Object



24
25
26
# File 'lib/fluent/plugin/out_splunk/match_formatter.rb', line 24

def format(tag, time, record)
  @formatter.format tag, time, record
end

#match?(tag) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/fluent/plugin/out_splunk/match_formatter.rb', line 20

def match?(tag)
  @pattern.match tag
end