Sha256: 7737b8413ef5ba25b5495c2746389ee1ddd9220c97300a7d3f31c19f1a1c39cd

Contents?: true

Size: 553 Bytes

Versions: 9

Compression:

Stored size: 553 Bytes

Contents

module Dotenv
  # A logger that can be used before the apps real logger is initialized.
  class ReplayLogger < Logger
    def initialize
      super(nil) # Doesn't matter what this is, it won't be used.
      @logs = []
    end

    # Override the add method to store logs so we can replay them to a real logger later.
    def add(*args, &block)
      @logs.push([args, block])
    end

    # Replay the store logs to a real logger.
    def replay(logger)
      @logs.each { |args, block| logger.add(*args, &block) }
      @logs.clear
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dotenv-3.1.7 lib/dotenv/replay_logger.rb
dotenv-3.1.6 lib/dotenv/replay_logger.rb
dotenv-3.1.5 lib/dotenv/replay_logger.rb
dotenv-3.1.4 lib/dotenv/replay_logger.rb
dotenv-3.1.3 lib/dotenv/replay_logger.rb
dotenv-3.1.2 lib/dotenv/replay_logger.rb
dotenv-3.1.1 lib/dotenv/replay_logger.rb
dotenv-3.1.0 lib/dotenv/replay_logger.rb
dotenv-3.0.3 lib/dotenv/replay_logger.rb