If OodAppkit.use_ood_log_formatting is set to true in an initializer, then we do these things:
set the log formatter of the Rails.logger to OodAppkit::LogFormatter.new
set the progname of the Rails.logger to the app token (if it exists)
enable lograge if the config option is available
By default this is enabled in production. The log formatter prepends logs with timestamp, app token, and log level. For example, here is a single request:
NOTE: I wanted to use the Rails config option log_formatter but that was not working when I set it from the engine. I tried multiple things, including ::Rails.configuration.log_formatter = OodAppkit::LogFormatter.new in the before_initialize section and config.log_formatter. I end up with something like this:
I should probably make lograge a dependency since I'm doing this: app.config.lograge.enabled = true
Also, this is temporary. Probably should make this a separate ood_rails_logging gem.
Fixes #https://github.com/AweSim-OSC/osc-ondemand/issues/85
If
OodAppkit.use_ood_log_formatting
is set to true in an initializer, then we do these things:Rails.logger
toOodAppkit::LogFormatter.new
progname
of theRails.logger
to the app token (if it exists)By default this is enabled in production. The log formatter prepends logs with timestamp, app token, and log level. For example, here is a single request:
This addresses https://github.com/AweSim-OSC/osc-ondemand/issues/85
NOTE: I wanted to use the Rails config option
log_formatter
but that was not working when I set it from the engine. I tried multiple things, including::Rails.configuration.log_formatter = OodAppkit::LogFormatter.new
in thebefore_initialize
section andconfig.log_formatter
. I end up with something like this:Using the log_formatter option in the future would be preferable to the
Rails.logger.formatter.extend
line in the future.