honeybadger-ruby icon indicating copy to clipboard operation
honeybadger-ruby copied to clipboard

Use Honeybadger logging.level setting when logging to Rails log

Open joshuap opened this issue 5 years ago • 4 comments

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.

joshuap avatar Nov 05 '20 18:11 joshuap

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 avatar Nov 20 '22 15:11 KonnorRogers

@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:

joshuap avatar Nov 22 '22 00:11 joshuap

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.

subzero10 avatar Nov 25 '22 12:11 subzero10

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.

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).

joshuap avatar Dec 05 '22 22:12 joshuap