module Fluent::PluginLoggerMixin

Attributes

log[RW]

Public Class Methods

included(klass) click to toggle source
# File lib/fluent/log.rb, line 680
def self.included(klass)
  klass.instance_eval {
    desc 'Allows the user to set different levels of logging for each plugin.'
    config_param :@log_level, :string, default: nil, alias: :log_level # 'log_level' will be warned as deprecated
  }
end
new() click to toggle source
Calls superclass method
# File lib/fluent/log.rb, line 687
def initialize
  super

  @log = $log # Use $log object directly by default
end

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/log.rb, line 695
def configure(conf)
  super

  if plugin_id_configured? || conf['@log_level']
    @log = PluginLogger.new($log.dup) unless @log.is_a?(PluginLogger)
    @log.optional_attrs = {}

    if level = conf['@log_level']
      @log.level = level
    end

    if plugin_id_configured?
      @log.optional_header = "[#{@id}] "
    end
  end
end
terminate() click to toggle source
Calls superclass method
# File lib/fluent/log.rb, line 712
def terminate
  super
  @log.reset
end