Class: Fluent::Plugin::SplunkHecOutput::MatchFormatter

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

Instance Method Summary collapse

Constructor Details

#initialize(pattern, formatter) ⇒ MatchFormatter

Returns a new instance of MatchFormatter.



4
5
6
7
8
9
10
11
12
13
# File 'lib/fluent/plugin/out_splunk_hec/match_formatter.rb', line 4

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

Instance Method Details

#format(tag, time, record) ⇒ Object



19
20
21
# File 'lib/fluent/plugin/out_splunk_hec/match_formatter.rb', line 19

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

#match?(tag) ⇒ Boolean

Returns:

  • (Boolean)


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

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