Class: Dotenv::ReplayLogger

Inherits:
Logger
  • Object
show all
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

Constructor Details

#initializeReplayLogger

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