lib/fluent/plugin/out_grepcounter.rb in fluent-plugin-grepcounter-0.5.5 vs lib/fluent/plugin/out_grepcounter.rb in fluent-plugin-grepcounter-0.5.6
- old
+ new
@@ -5,10 +5,15 @@
# To support log_level option implemented by Fluentd v0.10.43
unless method_defined?(:log)
define_method("log") { $log }
end
+ # Define `router` method of v0.12 to support v0.10 or earlier
+ unless method_defined?(:router)
+ define_method("router") { Fluent::Engine }
+ end
+
REGEXP_MAX_NUM = 20
def initialize
super
require 'pathname'
@@ -93,11 +98,11 @@
else
@less_equal = @threshold
end
end
- if @tag.nil? and @add_tag_prefix.nil? and @remove_tag_prefix.nil? and @add_tag_suffix.nil? and @remove_tag_suffix.nil? and @remove_tag_slice.nil?
+ if conf['@label'].nil? and @tag.nil? and @add_tag_prefix.nil? and @remove_tag_prefix.nil? and @add_tag_suffix.nil? and @remove_tag_suffix.nil? and @remove_tag_slice.nil?
@add_tag_prefix = 'count' # not ConfigError to support lower version compatibility
end
@tag_proc = tag_proc
case @aggregate
@@ -201,27 +206,27 @@
case @aggregate
when 'all'
count = flushed_counts[:all]
matches = flushed_matches[:all]
output = generate_output(count, matches)
- Fluent::Engine.emit(@tag, time, output) if output
+ router.emit(@tag, time, output) if output
when 'out_tag'
flushed_counts.keys.each do |out_tag|
count = flushed_counts[out_tag]
matches = flushed_matches[out_tag]
output = generate_output(count, matches)
if output
- Fluent::Engine.emit(out_tag, time, output)
+ router.emit(out_tag, time, output)
end
end
else # in_tag
flushed_counts.keys.each do |tag|
count = flushed_counts[tag]
matches = flushed_matches[tag]
output = generate_output(count, matches, tag)
if output
out_tag = @tag_proc.call(tag)
- Fluent::Engine.emit(out_tag, time, output)
+ router.emit(out_tag, time, output)
end
end
end
end