Class: Honeybadger::Logging::ConfigLogger

Inherits:
StandardLogger show all
Defined in:
lib/honeybadger/logging.rb

Constant Summary collapse

LOCATE_CALLER_LOCATION =
Regexp.new("#{Regexp.escape(__FILE__)}").freeze
CALLER_LOCATION =
Regexp.new("#{Regexp.escape(File.expand_path('../../../', __FILE__))}/(.*)").freeze
INFO_SUPPLEMENT =
' level=%s pid=%s'.freeze
DEBUG_SUPPLEMENT =
' at=%s'.freeze

Instance Method Summary collapse

Methods inherited from StandardLogger

#level

Methods inherited from Base

#level

Constructor Details

#initialize(config, logger = Logger.new('/dev/null')) ⇒ ConfigLogger

Returns a new instance of ConfigLogger.



117
118
119
120
121
122
# File 'lib/honeybadger/logging.rb', line 117

def initialize(config, logger = Logger.new('/dev/null'))
  @config = config
  @tty = STDOUT.tty?
  @tty_level = @config.log_level(:'logging.tty_level')
  super(logger)
end

Instance Method Details

#add(severity, msg) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/honeybadger/logging.rb', line 124

def add(severity, msg)
  return true if suppress_tty?(severity)

  # There is no debug level in Honeybadger. Debug logs will be logged at
  # the info level if the debug config option is on.
  if severity == Logger::Severity::DEBUG
    return true if suppress_debug?
    super(Logger::Severity::INFO, supplement(msg, Logger::Severity::DEBUG))
  else
    super(severity, supplement(msg, severity))
  end
end

#debug?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/honeybadger/logging.rb', line 137

def debug?
  @config.log_debug?
end