Set max log level when changing the log directives via RPC (#8721)

Before this pr changing the log directives would not change the max log
level. This means that if the node was started with `info` logging and
some `trace` logging was enabled, this `trace` wouldn't be logged. To
fix this we also need to update the max log level. This max log level is
used by the log macros to early return.
This commit is contained in:
Bastian Köcher
2021-05-04 13:34:52 +02:00
committed by GitHub
parent 3cd9cfd57a
commit 1f21d77ad1
3 changed files with 46 additions and 45 deletions
@@ -81,11 +81,12 @@ pub fn reload_filter() -> Result<(), String> {
}
}
}
env_filter = env_filter.add_directive(
"sc_tracing=trace"
.parse()
.expect("provided directive is valid"),
);
// Set the max logging level for the `log` macros.
let max_level_hint =
tracing_subscriber::Layer::<tracing_subscriber::FmtSubscriber>::max_level_hint(&env_filter);
log::set_max_level(super::to_log_level_filter(max_level_hint));
log::debug!(target: "tracing", "Reloading log filter with: {}", env_filter);
FILTER_RELOAD_HANDLE
.get()