lib/fluent/plugin/out_grepcounter.rb in fluent-plugin-grepcounter-0.5.1 vs lib/fluent/plugin/out_grepcounter.rb in fluent-plugin-grepcounter-0.5.2

- old
+ new

@@ -1,9 +1,14 @@ # encoding: UTF-8 class Fluent::GrepCounterOutput < Fluent::Output Fluent::Plugin.register_output('grepcounter', self) + # To support log_level option implemented by Fluentd v0.10.43 + unless method_defined?(:log) + define_method("log") { $log } + end + REGEXP_MAX_NUM = 20 def initialize super require 'pathname' @@ -170,11 +175,11 @@ @matches[tag] += matches end chain.next rescue => e - $log.warn "grepcounter: #{e.class} #{e.message} #{e.backtrace.first}" + log.warn "grepcounter: #{e.class} #{e.message} #{e.backtrace.first}" end # thread callback def watcher # instance variable, and public accessable, for test @@ -186,11 +191,11 @@ now = Fluent::Engine.now flush_emit(now - @last_checked) @last_checked = now end rescue => e - $log.warn "grepcounter: #{e.class} #{e.message} #{e.backtrace.first}" + log.warn "grepcounter: #{e.class} #{e.message} #{e.backtrace.first}" end end end # This method is the real one to emit @@ -279,11 +284,11 @@ :exclude => @exclude, :input_key => @input_key, }, f) end rescue => e - $log.warn "out_grepcounter: Can't write store_file #{e.class} #{e.message}" + log.warn "out_grepcounter: Can't write store_file #{e.class} #{e.message}" end end # Load internal status from a file # @@ -305,17 +310,17 @@ @saved_duration = stored[:saved_duration] # skip the saved duration to continue counting @last_checked = Fluent::Engine.now - @saved_duration else - $log.warn "out_grepcounter: stored data is outdated. ignore stored data" + log.warn "out_grepcounter: stored data is outdated. ignore stored data" end else - $log.warn "out_grepcounter: configuration param was changed. ignore stored data" + log.warn "out_grepcounter: configuration param was changed. ignore stored data" end end rescue => e - $log.warn "out_grepcounter: Can't load store_file #{e.class} #{e.message}" + log.warn "out_grepcounter: Can't load store_file #{e.class} #{e.message}" end end end