Module: Fluent::PluginLoggerMixin

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#logObject

Returns the value of attribute log.



421
422
423
# File 'lib/fluent/log.rb', line 421

def log
  @log
end

Class Method Details

.included(klass) ⇒ Object



408
409
410
411
412
413
# File 'lib/fluent/log.rb', line 408

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

Instance Method Details

#configure(conf) ⇒ Object



423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/fluent/log.rb', line 423

def configure(conf)
  super

  if level = conf['@log_level']
    unless @log.is_a?(PluginLogger)
      @log = PluginLogger.new($log.dup)
    end
    @log.level = level
    @log.optional_header = "[#{self.class.name}#{plugin_id_configured? ? "(" + @id + ")" : ""}] "
    @log.optional_attrs = {}
  end
end

#initializeObject



415
416
417
418
419
# File 'lib/fluent/log.rb', line 415

def initialize
  super

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

#startObject



436
437
438
439
# File 'lib/fluent/log.rb', line 436

def start
  @log.reset
  super
end

#terminateObject



441
442
443
444
# File 'lib/fluent/log.rb', line 441

def terminate
  super
  @log.reset
end