class Honeybadger::Logging::ConfigLogger

Constants

CALLER_LOCATION
DEBUG_SUPPLEMENT
INFO_SUPPLEMENT
LOCATE_CALLER_LOCATION

Public Class Methods

new(config, logger = Logger.new(nil)) click to toggle source
# File lib/honeybadger/logging.rb, line 124
def initialize(config, logger = Logger.new(nil))
  @config = config
  @tty = STDOUT.tty?
  @tty_level = @config.log_level(:'logging.tty_level')
  super(logger)
end

Public Instance Methods

add(severity, msg) click to toggle source
# File lib/honeybadger/logging.rb, line 131
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?() click to toggle source
# File lib/honeybadger/logging.rb, line 144
def debug?
  @config.log_debug?
end

Private Instance Methods

caller_location() click to toggle source
# File lib/honeybadger/logging.rb, line 170
def caller_location
  if caller && caller.find {|l| l !~ LOCATE_CALLER_LOCATION && l =~ CALLER_LOCATION }
    Regexp.last_match(1)
  end
end
supplement(msg, severity) click to toggle source
# File lib/honeybadger/logging.rb, line 158
def supplement(msg, severity)
  return msg unless msg.kind_of?(String)

  r = msg.dup
  r << sprintf(INFO_SUPPLEMENT, severity, Process.pid)
  if severity == Logger::Severity::DEBUG && l = caller_location
    r << sprintf(DEBUG_SUPPLEMENT, l.dump)
  end

  r
end
suppress_debug?() click to toggle source
# File lib/honeybadger/logging.rb, line 150
def suppress_debug?
  !debug?
end
suppress_tty?(severity) click to toggle source
# File lib/honeybadger/logging.rb, line 154
def suppress_tty?(severity)
  @tty && severity < @tty_level
end