Class: Fluent::PluginLogger

Inherits:
Log
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/fluent/log.rb

Overview

PluginLogger has own log level separated from global $log object. This class enables log_level option in each plugin.

PluginLogger has same functionality as Log but some methods are forwarded to internal logger for keeping logging action consistency in the process, e.g. color, event, etc.

Direct Known Subclasses

Test::TestLogger

Constant Summary

Constants inherited from Log

Log::IGNORE_SAME_LOG_MAX_CACHE_SIZE, Log::LEVEL_DEBUG, Log::LEVEL_ERROR, Log::LEVEL_FATAL, Log::LEVEL_INFO, Log::LEVEL_TEXT, Log::LEVEL_TRACE, Log::LEVEL_WARN, Log::LOG_EVENT_LABEL, Log::LOG_EVENT_TAG_PREFIX, Log::LOG_ROTATE_AGE, Log::LOG_TYPES, Log::LOG_TYPE_DEFAULT, Log::LOG_TYPE_SUPERVISOR, Log::LOG_TYPE_WORKER0

Instance Attribute Summary

Attributes inherited from Log

#format, #ignore_repeated_log_interval, #ignore_same_log_interval, #level, #log_event_enabled, #optional_attrs, #optional_header, #out, #suppress_repeated_stacktrace, #time_format

Instance Method Summary collapse

Methods inherited from Log

#caller_line, #debug, #debug_backtrace, #disable_events, #dump_stacktrace, #dup, #enable_color?, #enable_debug, #enable_event, #error, #error_backtrace, #event, event_tags, #fatal, #fatal_backtrace, #flush, #format_time, #get_worker_id, #ignore_repeated_log?, #ignore_same_log?, #info, #info_backtrace, #log_type, #logdev=, #on_debug, #on_error, #on_fatal, #on_info, #on_trace, #on_warn, per_process_path, #puts, #reopen!, #reset, #skipped_type?, #stdout?, str_to_level, #suppress_stacktrace?, #trace, #trace_backtrace, #warn, #warn_backtrace, #write

Constructor Details

#initialize(logger) ⇒ PluginLogger

Returns a new instance of PluginLogger.



628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
# File 'lib/fluent/log.rb', line 628

def initialize(logger)
  @logger = logger
  @level = @logger.level
  @format = nil
  @depth_offset = 2
  if logger.instance_variable_defined?(:@suppress_repeated_stacktrace)
    @suppress_repeated_stacktrace = logger.instance_variable_get(:@suppress_repeated_stacktrace)
  end
  if logger.instance_variable_defined?(:@ignore_repeated_log_interval)
    @ignore_repeated_log_interval = logger.instance_variable_get(:@ignore_repeated_log_interval)
  end
  if logger.instance_variable_defined?(:@ignore_same_log_interval)
    @ignore_same_log_interval = logger.instance_variable_get(:@ignore_same_log_interval)
  end

  self.format = @logger.format
  self.time_format = @logger.time_format
  enable_color @logger.enable_color?
end

Instance Method Details

#enable_color(b = true) ⇒ Object



666
667
668
669
# File 'lib/fluent/log.rb', line 666

def enable_color(b = true)
  orig_enable_color b
  @logger.enable_color b
end

#format=(fmt) ⇒ Object



656
657
658
659
# File 'lib/fluent/log.rb', line 656

def format=(fmt)
  self.orig_format = fmt
  @logger.format = fmt
end

#level=(log_level_str) ⇒ Object



648
649
650
# File 'lib/fluent/log.rb', line 648

def level=(log_level_str)
  @level = Log.str_to_level(log_level_str)
end

#orig_enable_colorObject



654
# File 'lib/fluent/log.rb', line 654

alias orig_enable_color enable_color

#orig_format=Object



652
# File 'lib/fluent/log.rb', line 652

alias orig_format= format=

#orig_time_format=Object



653
# File 'lib/fluent/log.rb', line 653

alias orig_time_format= time_format=

#time_format=(fmt) ⇒ Object



661
662
663
664
# File 'lib/fluent/log.rb', line 661

def time_format=(fmt)
  self.orig_time_format = fmt
  @logger.time_format = fmt
end