Class: Dotenv::ReplayLogger
- Inherits:
-
Logger
- Object
- Logger
- Dotenv::ReplayLogger
- Defined in:
- lib/dotenv/replay_logger.rb
Overview
A logger that can be used before the apps real logger is initialized.
Instance Method Summary collapse
-
#add(*args, &block) ⇒ Object
Override the add method to store logs so we can replay them to a real logger later.
-
#initialize ⇒ ReplayLogger
constructor
A new instance of ReplayLogger.
-
#replay(logger) ⇒ Object
Replay the store logs to a real logger.
Constructor Details
#initialize ⇒ ReplayLogger
Returns a new instance of ReplayLogger.
4 5 6 7 |
# File 'lib/dotenv/replay_logger.rb', line 4 def initialize super(nil) # Doesn't matter what this is, it won't be used. @logs = [] end |
Instance Method Details
#add(*args, &block) ⇒ Object
Override the add method to store logs so we can replay them to a real logger later.
10 11 12 |
# File 'lib/dotenv/replay_logger.rb', line 10 def add(*args, &block) @logs.push([args, block]) end |
#replay(logger) ⇒ Object
Replay the store logs to a real logger.
15 16 17 18 |
# File 'lib/dotenv/replay_logger.rb', line 15 def replay(logger) @logs.each { |args, block| logger.add(*args, &block) } @logs.clear end |