A powerful logger for Roda with a few tricks up it's sleeve.
- Coloured output per level
- Structured output of query params
- Tracking of database query time and count
- Tracking of blocks which handle path segment
- Tracing missed requests
- Tracing all requests
Add this line to your application's Gemfile:
gem "roda-enhanced_logger"
And then execute:
$ bundle
Or install it yourself as:
$ gem install roda-enhanced_logger
For basic usage, simply enable through the plugin
mechanism.
class App < Roda
plugin :enhanced_logger
end
If you serve assets through Roda, your logs might be fairly noisy, so you can filter them.
plugin :enhanced_logger, filter: ->(path) { path.start_with?("/assets") }
By default, EnhancedLogger will attempt to filter passwords and CSRF tokens, but you can filter other fields too.
plugin :enhanced_logger, filtered_params: %w[api_key]
If there's a DB
constant defined for Sequel, EnhancedLogger will automatically
use it, but you can pass in a custom value if necessary.
plugin :enhanced_logger, db: Container[:db]
During development, a 404 might catch you off guard for a path that you feel should exist, so it's handy to trace missed routes to aide in debugging.
plugin :enhanced_logger, trace_missed: true
Or always trace every request.
plugin :enhanced_logger, trace_all: true
Bug reports and pull requests are welcome on GitHub at https://github.com/adam12/roda-enhanced_logger.
I love pull requests! If you fork this project and modify it, please ping me to see if your changes can be incorporated back into this project.
That said, if your feature idea is nontrivial, you should probably open an issue to discuss it before attempting a pull request.
The gem is available as open source under the terms of the MIT License.