0.01
No commit activity in last 3 years
No release in over 3 years
Betterer Rails logger that handles multi-threading well
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 4.0.0, ~> 4.0
 Project Readme

SweetLogger

This little gem solves two issues with rails ActiveSuppot::Logger when it's running in a multi-threaded environment.

  1. It doesn't let log entries for concurrent requests overlap
  2. Adds a log silencer (for /assets/) that works correctly with multiple threads

Installation

Add this line to your application's Gemfile:

gem 'sweet-logger'

Enjoy!

Rack::Lock

By default in the development environment, Rails adds the Rack::Lock middleware so that the rack server will process only one request at a time.

If you need to enable the real multi-threaded processing in the development environment, add this to your config/application.rb

  config.middleware.delete Rack::Lock

Also, you might going to need add the folloing to your config/development.rb if your web page makes several requests to your app on a page load

  config.eager_load = true

That will prevent race conditions on code-reloads when you make changes to your app code.

Silencer

Our sweet logger comes with a silencer in case you need to remove some of the entries from leaking into the logs. By default it silences the /assets/ entries. But if you need to silence anything else, add this to one of your rails initializers

SweetLogger.silence %w[
  favicon.io
  livereload.js
  /something/else
]

NOTE: logger will check if the route included in the current request's path.

Contributing

  1. Fork it ( https://github.com/MadRabbit/sweet-logger/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request