Skip to content

Commit

Permalink
Merge pull request valkey-io#453 from shachlanAmazon/logging
Browse files Browse the repository at this point in the history
Filter traces from other crates.
  • Loading branch information
shachlanAmazon authored Sep 19, 2023
2 parents 8b1da3b + 3fda2c5 commit 235b18b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions logger_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,18 @@ pub fn init(minimal_level: Option<Level>, file_name: Option<&str>) -> Level {
.with_writer(file_appender)
.with_filter(LevelFilter::OFF);
let (file_layer, file_reload) = reload::Layer::new(file_fmt);

// Enable logging only from allowed crates
let targets_filter = filter::Targets::new()
.with_target("babushka", LevelFilter::TRACE)
.with_target("redis", LevelFilter::TRACE)
.with_target("logger_core", LevelFilter::TRACE)
.with_target(std::env!("CARGO_PKG_NAME"), LevelFilter::TRACE);

tracing_subscriber::registry()
.with(stdout_layer)
.with(file_layer)
.with(targets_filter)
.init();

let reloads: Reloads = Reloads {
Expand Down

0 comments on commit 235b18b

Please sign in to comment.