Skip to content

Commit 98e2b24

Browse files
authored
fix: Enable lowering log level below startup value (#15)
`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]>
1 parent ef0f54a commit 98e2b24

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/logger.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ impl Logger {
169169
///
170170
/// See the module documentation for more details.
171171
pub fn parse_filters(&mut self, filters: &str) -> &mut Self {
172-
self.configuration.write().filter = Builder::default().parse(filters).build();
172+
let filter = Builder::default().parse(filters).build();
173+
log::set_max_level(filter.filter());
174+
self.configuration.write().filter = filter;
173175
self
174176
}
175177

0 commit comments

Comments
 (0)