Skip to content

Commit 70bbe55

Browse files
committed
The option --log-debug should only enable debug logging for this crate
1 parent 1f7c555 commit 70bbe55

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/main.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,14 @@ enum CliCommand {
114114
async fn main() -> anyhow::Result<()> {
115115
let cli = Cli::parse();
116116

117-
let level_filter = if cli.log_debug {
118-
LevelFilter::DEBUG
119-
} else {
120-
LevelFilter::WARN
121-
};
117+
let crate_name = env!("CARGO_PKG_NAME");
122118

123119
let env_filter = tracing_subscriber::EnvFilter::builder()
124-
.with_default_directive(level_filter.into())
125-
.from_env_lossy();
120+
.with_default_directive(LevelFilter::WARN.into()) // global default
121+
.parse_lossy(format!(
122+
"{crate_name}={}",
123+
if cli.log_debug { "debug" } else { "warn" }
124+
));
126125

127126
let subscriber = tracing_subscriber::fmt::Subscriber::builder().with_env_filter(env_filter);
128127

0 commit comments

Comments
 (0)