Skip to content

Conversation

arkgil
Copy link
Contributor

@arkgil arkgil commented Apr 22, 2021

The configuration is done via application env, since there is no way to pass options to Logger translators. I called the option log_all, but it might be limiting if you'd like to expand this to allow more fine-grained filtering in the future.

Closes #67

When using a Unix socket, OTP 21+ is required for `Plug.Static` and
`Plug.Conn.send_file/3` to behave correctly.
## Application configuration
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that the right place for these docs? Let me know if I should move it.

Comment on lines 60 to 61
Application.put_env(:plug_cowboy, :log_all, true)
on_exit(fn -> Application.delete_env(:plug_cowboy, :log_all) end)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test suite is not async so this should be fine.

## Application configuration
* `:log_all` - A boolean that determines whether all exceptions are logged by the adapter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we call it log_exceptions_with_status_code_from which defaults to 500? This way people can opt-in to 400 but still leave others out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! 👍

Copy link
Contributor Author

@arkgil arkgil Apr 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we stretched this and allowed a range or a list? E.g. if I wanted to skip logging 415.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log_exceptions_with_status_code that expects a list of ranges work for me.

@arkgil arkgil requested a review from josevalim April 22, 2021 20:06
@josevalim josevalim merged commit e716ddf into elixir-plug:master Apr 22, 2021
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

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

Successfully merging this pull request may close these issues.

Logging non-500 exceptions

2 participants