Sha256: 982aa230179d1bbaee50251c9170fd6b268eb9aeb199513dc348c49157017a9b

Contents?: true

Size: 659 Bytes

Versions: 5

Compression:

Stored size: 659 Bytes

Contents

# https://github.com/karafka/null-logger/blob/master/lib/null_logger.rb
# under MIT license as of 5/9/2016

# Null logger class
# Is used when logger is not defined
class NullLogger
  # Possible log levels from ruby Logger::Severity class
  LOG_LEVELS = %w( unknown fatal error warn info debug ).freeze

  # Returns nil for any method call from LOG_LEVELS array
  # Instead raise NoMethodError
  # @example:
  #   NullLogger.new.fatal -> return nil
  #   NullLogger.new.wrong_method -> raise NoMethodError
  def method_missing(method_name, *args, &block)
    return nil if LOG_LEVELS.include?(method_name.to_s)
    super(method_name, *args, &block)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tickwork-0.9.2 test/null_logger.rb
tickwork-0.9.1 test/null_logger.rb
tickwork-0.9.0 test/null_logger.rb
tickwork-0.1.0 test/null_logger.rb
tickwork-0.0.1 test/null_logger.rb