feat: aware RUST_LOG

This commit is contained in:
sigoden
2022-05-28 20:42:32 +08:00
parent d9a917176a
commit 3673a64ec7
5 changed files with 14 additions and 12 deletions

View File

@@ -25,14 +25,18 @@ async fn main() {
async fn run() -> BoxResult<()> {
let args = Args::parse(matches())?;
let level = if args.log {
LevelFilter::Info
if std::env::var("RUST_LOG").is_ok() {
simple_logger::init()?;
} else {
LevelFilter::Error
};
simple_logger::SimpleLogger::default()
.with_level(level)
.init()?;
let level = if args.log {
LevelFilter::Info
} else {
LevelFilter::Error
};
simple_logger::SimpleLogger::default()
.with_level(level)
.init()?;
}
serve(args).await
}