Geal / rust-syslog

Send syslog messages from Rust
MIT License
109 stars 55 forks source link

Make possible to customize filtering of messages according to crates #71

Open Dushistov opened 1 year ago

Dushistov commented 1 year ago

There are no clear criteria for separating messages according to the log level. So some crates log every byte in info level, while other more conveniently move such info to trace level. As example, in my project I have such config for env_logger:

debug,tokio=warn,request=warn,hyper=warn,
serde_xml_rs=warn,reqwest=warn,trust_dns_proto=warn,
trust_dns_resolver=warn,couchbase=warn 

So it would be nice if it is possible at least filter messages before send them to syslog via crate names.

One of possible variants of solution would be generalize solution from android_logger: https://docs.rs/android_logger/0.11.1/android_logger/struct.FilterBuilder.html

It make possible to construct via builder pattern, plus you can construct filter from RUST_LOG via let filter = android_logger::FilterBuilder::from_env("RUST_LOG").build();