-
Notifications
You must be signed in to change notification settings - Fork 76
Logging Errors Effectively
Jordan Pickwell edited this page Sep 25, 2017
·
1 revision
GrapeLogging has its own begin-rescue which will catch any exceptions, log them, and then re-raise them. This can create either double/incorrect output in the logs. To fix this, just insert GrapeLogging after Rack::Head
.
class Base < Grape::API
# ...
# instead of `use`
insert_after(
Rack::Head,
GrapeLogging::Middleware::RequestLogger,
# ...
)
# ...
end
This will allow you to log the error responses the same way as the success responses. You will need to make sure you have a rescue_from(:all)
handler in your APIs, otherwise any uncaught exceptions will be handled by GrapeLogging and produce inconsistent log entries.