Class: Dreamcatcher::LoggerProxy
- Inherits:
-
Object
- Object
- Dreamcatcher::LoggerProxy
- Defined in:
- lib/dreamcatcher/logger_proxy.rb
Defined Under Namespace
Classes: LogEntry
Instance Attribute Summary collapse
-
#log_entries ⇒ Object
readonly
Returns the value of attribute log_entries.
-
#original_logger ⇒ Object
readonly
Returns the value of attribute original_logger.
Class Method Summary collapse
Instance Method Summary collapse
- #capture(&block) ⇒ Object
-
#initialize(logger) ⇒ LoggerProxy
constructor
A new instance of LoggerProxy.
Constructor Details
#initialize(logger) ⇒ LoggerProxy
Returns a new instance of LoggerProxy.
7 8 9 10 |
# File 'lib/dreamcatcher/logger_proxy.rb', line 7 def initialize(logger) @original_logger = logger @log_entries = [] end |
Instance Attribute Details
#log_entries ⇒ Object (readonly)
Returns the value of attribute log_entries.
5 6 7 |
# File 'lib/dreamcatcher/logger_proxy.rb', line 5 def log_entries @log_entries end |
#original_logger ⇒ Object (readonly)
Returns the value of attribute original_logger.
5 6 7 |
# File 'lib/dreamcatcher/logger_proxy.rb', line 5 def original_logger @original_logger end |
Class Method Details
.capture(logger, &block) ⇒ Object
20 21 22 |
# File 'lib/dreamcatcher/logger_proxy.rb', line 20 def self.capture(logger, &block) Dreamcatcher::LoggerProxy.new(logger).capture(&block) end |
Instance Method Details
#capture(&block) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/dreamcatcher/logger_proxy.rb', line 12 def capture(&block) register_logger_monkeypatch unless @original_logger.nil? yield if block_given? return self ensure deregister_logger_monkeypatch unless @original_logger.nil? end |