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

Fix setting the default log level to WARN #306

Merged

Conversation

primeos-work
Copy link
Member

In 76150f0, we used with_max_level() to set the default log level but apparently the behaviour changed in the meantime (or we didn't test it correctly back then). The documentation of with_env_filter 0 states:

If a filter was previously set, or a maximum level was set by the
with_max_level method, that value is replaced by the new filter.

The idea in 76150f0 was that with_env_filter would only override the default from with_max_level if the $RUST_LOG environment variable is set but the EnvFilter::from_default_env() also had a default log level (unfortunately it defaults to ERROR instead of WARN). We now replace from_default_env() with the underlying code 1 but changed the default log level from ERROR to WARN.

primeos-work and others added 2 commits October 10, 2023 19:51
In 76150f0, we used `with_max_level()` to set the default log level but
apparently the behaviour changed in the meantime (or we didn't test it
correctly back then). The documentation of `with_env_filter` [0] states:
> If a filter was previously set, or a maximum level was set by the
with_max_level method, that value is replaced by the new filter.

The idea in 76150f0 was that `with_env_filter` would only override the
default from `with_max_level` if the `$RUST_LOG` environment variable is
set but the `EnvFilter::from_default_env()` also had a default log level
(unfortunately it defaults to ERROR instead of WARN).
We now replace `from_default_env()` with the underlying code [1] but
changed the default log level from ERROR to WARN.

[0]: https://docs.rs/tracing-subscriber/0.3.17/tracing_subscriber/fmt/struct.SubscriberBuilder.html#method.with_env_filter
[1]: https://docs.rs/tracing-subscriber/0.3.17/tracing_subscriber/filter/struct.EnvFilter.html#method.from_default_env

Signed-off-by: Michael Weiss <michael.weiss@atos.net>
Co-authored-by: Nico Steinle <nico.steinle@atos.net>
It was only used in `src/main.rs` and we can or rather should use the
`tracing` crate instead for consistency.
We switched to `tracing` (Tokio) in ff5666c and don't need the direct
dependency on `log` (it will still get pulled in transitively through
other dependencies though).

Signed-off-by: Michael Weiss <michael.weiss@atos.net>
@primeos-work primeos-work added this pull request to the merge queue Oct 19, 2023
Merged via the queue into science-computing:master with commit cea2d8b Oct 19, 2023
13 checks passed
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.

1 participant