honeybadger-ruby
honeybadger-ruby copied to clipboard
Use Honeybadger logging.level setting when logging to Rails log
See #296 for additional context. Currently, the logging.level setting only works when logging.path (or a custom logger) is also configured. It would be nice if logging.level also applied to the default Rails logger, but only for Honeybadger. I think that people expect logging.level to work for Honeybadger logs regardless of where the output is being sent.
Perhaps an internal check before calling the logging methods?
For example:
if config.logging_level <= Logging::INFO
logger.info(sprintf('Initializing Honeybadger Error Tracker for Ruby. Ship it! version=%s framework=%s', Honeybadger::VERSION, detected_framework))
end
Something like that for an internal check before calling the logger? The helpers in the "Logging" module would also have to be updated to have the log_level check I imagine.
@KonnorRogers yeah, I was thinking that we could probably add the suppression to the logging module so that it would just skip sending the log to the logger if our internal level is lower. We have a complicated logging setup. :joy:
Perhaps an internal check before calling the logging methods?
For example:
if config.logging_level <= Logging::INFO logger.info(sprintf('Initializing Honeybadger Error Tracker for Ruby. Ship it! version=%s framework=%s', Honeybadger::VERSION, detected_framework)) end
Isn't this an anti-pattern though? I mean the whole point for calling a specific logging level method (logger.info, logger.error, etc.) is so that we let the logger decide if and where to send that log. Note: I don't know how logging is implemented in the Ruby client.
Perhaps an internal check before calling the logging methods? For example:
if config.logging_level <= Logging::INFO logger.info(sprintf('Initializing Honeybadger Error Tracker for Ruby. Ship it! version=%s framework=%s', Honeybadger::VERSION, detected_framework)) endIsn't this an anti-pattern though? I mean the whole point for calling a specific logging level method (
logger.info,logger.error, etc.) is so that we let the logger decide if and where to send that log. Note: I don't know how logging is implemented in the Ruby client.
We share the Rails logger by default, but you can also configure a separate Honeybadger-specific logger. I think the best way to think about it is that our configured log level takes precedence, but only for our logs (when logging to the default Rails logger).