Skip to content

Commit

Permalink
fix: Enable lowering log level below startup value (#15)
Browse files Browse the repository at this point in the history
`Logger::parse_filters` allows to change the log filter even after the
logger has been initialized. However, it was not possible to see logs
which were above the level set at startup. E.g. if the logger was
initialized with `debug`, setting it to `trace` at runtime did not work
since the filter of the global logging facade filtered out the `trace`
logs.

This commit fixes the issue by calling `log::set_max_level` with the
level from the updated log filter.

Co-authored-by: Simon B. Gasse <[email protected]>
  • Loading branch information
sgasse and sgasse authored Oct 8, 2024
1 parent ef0f54a commit 98e2b24
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ impl Logger {
///
/// See the module documentation for more details.
pub fn parse_filters(&mut self, filters: &str) -> &mut Self {
self.configuration.write().filter = Builder::default().parse(filters).build();
let filter = Builder::default().parse(filters).build();
log::set_max_level(filter.filter());
self.configuration.write().filter = filter;
self
}

Expand Down

0 comments on commit 98e2b24

Please sign in to comment.