Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass status code to loggers #71

Open
stanhu opened this issue Apr 18, 2020 · 0 comments
Open

Pass status code to loggers #71

stanhu opened this issue Apr 18, 2020 · 0 comments

Comments

@stanhu
Copy link

stanhu commented Apr 18, 2020

Right now the loggers only have access to the request and response_body, but it would be nice to have access to the status code as well. For now, we're working around the problem by storing the intended status code in the request.env, but this is not ideal.

Not sure the best way to support this without breaking compatibility of the parameters call in

params.merge! logger.parameters(request, response_body) do |_, oldval, newval|
. We could check if the signature accepts an optional 3rd argument?

terrchen pushed a commit to terrchen/gitlab that referenced this issue Apr 25, 2020
The API helper `render_api_error!` previously would log a 400 error with
no details in `api_json.log`, which made it difficult to debug problems
in production. To fix this, we:

1. Store the intended status code in the request
environment. grape-logging doesn't pass this along to the loggers:
aserafin/grape_logging#71

2. In the logger, check the code. If it is 400, attach an `api_error`
field that contains the response from the server.

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/214879
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant