Skip to content

Commit e3f6619

Browse files
committed
Ref debug log level settings
1 parent a413555 commit e3f6619

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ async fn main() -> io::Result<()> {
1818
}
1919
};
2020

21-
env_logger::init_from_env(
22-
env_logger::Env::default().default_filter_or(if !config.debug { "info" } else { "debug" }),
23-
);
21+
env_logger::init_from_env(env_logger::Env::default().default_filter_or(
22+
// Set log level to "debug" if enabled in config or environment; default is "info"
23+
if !config.debug && env::var("DEBUG").map(|v| v != "true").unwrap_or(true) {
24+
"info"
25+
} else {
26+
"debug"
27+
},
28+
));
2429

2530
let listener = TcpListener::bind(format!("{}:{}", config.host, config.port)).await?;
2631
info!("Server listening on port {}", config.port);

0 commit comments

Comments
 (0)