Some things that are gonna get fixed with v2:
Move the `task_local!` stuff to the lib.rs file, that is[..] + +tokio::task_local! { + pub static LOGGER: RefCell<Option<FileLogger>>; + pub static WARN_COUNTER: RefCell<Option<u64>>; +}
We also need the `.with_filter(log_level)` on the `FilelogLayer`, so[..] + +pub fn init_logger( + env_var_name: &str, + default_log_level: LevelFilter, + application_name: &str, +) -> Result<(), anyhow::Error> { + let mut log_level = default_log_level; + if let Ok(v) = env::var(env_var_name) { + if let Ok(l) = v.parse::<LevelFilter>() { + log_level = l; + } + } + let registry = tracing_subscriber::registry() + .with(FilelogLayer::new().with_filter(filter_fn(|metadata| { + metadata.fields().field("tasklog").is_some() + }))) + .with(SyslogLayer::new(application_name.to_string()).with_filter(log_level)); +
+ tracing::subscriber::set_global_default(registry)?; + + LogTracer::init()?;
Use `init_with_filter` here, so that we also set the loglevel on
the (underlying) `log`
implementation. Like that a `log::info` call for example doesn't
even
forward the message to `tracing`.
+ Ok(()) +} [..]