Class: Lamian::Logger Private
- Inherits:
-
Logger
- Object
- Logger
- Lamian::Logger
- Defined in:
- lib/lamian/logger.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides thread-local loggers to catch teed messages from regular loggers. Uses :__lamian_logger thread variable
Class Method Summary collapse
-
.current ⇒ Lamian::Logger
private
Provides access to logger bound to curent thread.
Instance Method Summary collapse
-
#add(*args, &block) ⇒ Object
private
Part of Logger api, entry point for all logs extened to run on each log device in stack.
-
#dump(format: nil) ⇒ Object
private
Dumps log collected in this run.
-
#initialize ⇒ Logger
constructor
private
A new instance of Logger.
-
#run ⇒ Object
private
Collects logs sent inside block.
Constructor Details
#initialize ⇒ Logger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Logger.
17 18 19 20 21 |
# File 'lib/lamian/logger.rb', line 17 def initialize super(nil) self.level = 0 self.logdevs = [] end |
Class Method Details
.current ⇒ Lamian::Logger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Provides access to logger bound to curent thread
13 14 15 |
# File 'lib/lamian/logger.rb', line 13 def self.current Thread.current[:__lamian_logger] ||= new end |
Instance Method Details
#add(*args, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Part of Logger api, entry point for all logs extened to run on each log device in stack
35 36 37 38 39 40 41 42 |
# File 'lib/lamian/logger.rb', line 35 def add(*args, &block) @formatter = Lamian.config.formatter logdevs.each do |logdev| @logdev = logdev super end end |
#dump(format: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Dumps log collected in this run
51 52 53 54 55 |
# File 'lib/lamian/logger.rb', line 51 def dump(format: nil) result = logdevs[-1]&.string&.dup apply_format!(format, result) result end |
#run ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Collects logs sent inside block
25 26 27 28 29 30 31 |
# File 'lib/lamian/logger.rb', line 25 def run logdevs.push(StringIO.new) yield ensure logdevs.pop end |