Class: Kafo::Logger
- Inherits:
-
Object
- Object
- Kafo::Logger
- Defined in:
- lib/kafo/logger.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name = 'root') ⇒ Logger
constructor
A new instance of Logger.
- #log(level, *args, &block) ⇒ Object
Constructor Details
#initialize(name = 'root') ⇒ Logger
Returns a new instance of Logger.
9 10 11 12 |
# File 'lib/kafo/logger.rb', line 9 def initialize(name = 'root') @name = name @logger = (name == 'root') ? Logging.root_logger : Logging.add_logger(name) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
7 8 9 |
# File 'lib/kafo/logger.rb', line 7 def logger @logger end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/kafo/logger.rb', line 7 def name @name end |
Instance Method Details
#log(level, *args, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kafo/logger.rb', line 14 def log(level, *args, &block) if Logging.buffering? if block_given? data = yield else data = args end Logging.to_buffer(@name, ::Logging::LogEvent.new(@name, ::Logging::LEVELS[level.to_s], data, false)) else Logging.dump_buffer if Logging.dump_needed? @logger.send(level, *args, &block) end end |