Sha256: 3cdda8c8d10fd35311581b425f4dbe7ab53eb355b63493a845a1e0d377500be7

Contents?: true

Size: 678 Bytes

Versions: 20

Compression:

Stored size: 678 Bytes

Contents

class MultiLogger
  attr_reader :loggers

  def initialize(*args)
    @loggers = args
  end

  def level=(level)
    @loggers.each { |logger| logger.level = level }
  end

  def levels
    @loggers.map(&:level)
  end

  def min_level
    levels.min
  end

  def close
    @loggers.map(&:close)
  end

  def add(level, *args)
    @loggers.each { |logger| logger.add(level, *args) }
  end

  Logger::Severity.constants.each do |level|
    define_method(level.downcase) do |*args|
      @loggers.each { |logger| logger.send(level.downcase, *args) }
    end

    define_method("#{ level.downcase }?".to_sym) do
      min_level <= Logger::Severity.const_get(level)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
iqvoc-4.14.5 app/aides/multi_logger.rb
iqvoc-4.14.4 app/aides/multi_logger.rb
iqvoc-4.13.2 app/aides/multi_logger.rb
iqvoc-4.13.0 app/aides/multi_logger.rb
iqvoc-4.12.1 app/aides/multi_logger.rb
iqvoc-4.12.0 app/aides/multi_logger.rb
iqvoc-4.11.1 app/aides/multi_logger.rb
iqvoc-4.11.0 app/aides/multi_logger.rb
iqvoc-4.10.0 app/aides/multi_logger.rb
iqvoc-4.9.0 app/aides/multi_logger.rb
iqvoc-4.8.2 app/aides/multi_logger.rb
iqvoc-4.8.1 app/aides/multi_logger.rb
iqvoc-4.8.0 app/aides/multi_logger.rb
iqvoc-4.7.0 lib/multi_logger.rb
iqvoc-4.6.1 lib/multi_logger.rb
iqvoc-4.5.2 lib/multi_logger.rb
iqvoc-4.6.0 lib/multi_logger.rb
iqvoc-4.5.1 lib/multi_logger.rb
iqvoc-4.5.0 lib/multi_logger.rb
iqvoc-4.4.0 lib/multi_logger.rb