grape_logging
grape_logging copied to clipboard
wrong status code 500 logged
I am using the newest gem versions. It looks like the logger is executed before the rescue_from
which sets the statuscode.
logger.formatter = GrapeLogging::Formatters::Default.new
use GrapeLogging::Middleware::RequestLogger, logger: logger, include: [ GrapeLogging::Loggers::Response.new,
GrapeLogging::Loggers::FilterParameters.new,
GrapeLogging::Loggers::ClientEnv.new,
GrapeLogging::Loggers::RequestHeaders.new ]
rescue_from WineBouncer::Errors::OAuthUnauthorizedError do |e|
error! e, 401
end
Simple fix:
insert_before Grape::Middleware::Error, GrapeLogging::Middleware::RequestLogger, logger: logger, include: [ GrapeLogging::Loggers::Response.new,
GrapeLogging::Loggers::FilterParameters.new,
GrapeLogging::Loggers::ClientEnv.new,
GrapeLogging::Loggers::RequestHeaders.new ]
Instead of use ...
just insert_before Grape::Middleware::Error,...
and the exceptions hit the logger after the rescue_from
handlers. Now the logger logs the right status code.
I am using grape v1.0.2
Maybe update the readme?
@thedarkside thanks for the report! could you please create PR for the readme?
Seems already partially done with https://github.com/aserafin/grape_logging/pull/74