Friday, 11 December 2015

Suppress ready and complete log messages from rack-timeout

The rack-timout gem has an annoying habit of logging two lines for each request at INFO level, e.g.:
source=rack-timeout id=11b2abd0-d4af-4a13-9c5a-a8729af45e40 wait=15ms timeout=29985ms state=ready
source=rack-timeout id=11b2abd0-d4af-4a13-9c5a-a8729af45e40 wait=15ms timeout=29985ms service=165ms state=completed

I like logging at INFO in production because I get a log message per request.

You can reduce the log level rack-timeout uses to log those states by adding this to your initializer:
Rack::Timeout::StateChangeLoggingObserver::STATE_LOG_LEVEL[:ready] = :debug
Rack::Timeout::StateChangeLoggingObserver::STATE_LOG_LEVEL[:completed] = :debug