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.



567
568
569
# File 'lib/fluent/log.rb', line 567

def log
  @log
end

Class Method Details

.included(klass) ⇒ Object



554
555
556
557
558
559
# File 'lib/fluent/log.rb', line 554

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



569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/fluent/log.rb', line 569

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

#initializeObject



561
562
563
564
565
# File 'lib/fluent/log.rb', line 561

def initialize
  super

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

#terminateObject



586
587
588
589
# File 'lib/fluent/log.rb', line 586

def terminate
  super
  @log.reset
end