Added the log level
This commit is contained in:
21
src/main.rs
21
src/main.rs
@@ -35,18 +35,27 @@ struct Cli {
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let cli = Cli::parse();
|
||||
|
||||
let mut config = AppConfig::load(cli.config.as_deref());
|
||||
|
||||
let filter = match cli.verbose {
|
||||
0 => "info,shanty_web=info",
|
||||
1 => "info,shanty_web=debug",
|
||||
_ => "debug,shanty_web=trace",
|
||||
0 => {
|
||||
let level = config.log_level.to_lowercase();
|
||||
match level.as_str() {
|
||||
"error" => "error".to_string(),
|
||||
"warn" => "warn".to_string(),
|
||||
"debug" => "debug,shanty_web=debug".to_string(),
|
||||
"trace" => "trace,shanty_web=trace".to_string(),
|
||||
_ => "info,shanty_web=info".to_string(),
|
||||
}
|
||||
}
|
||||
1 => "info,shanty_web=debug".to_string(),
|
||||
_ => "debug,shanty_web=trace".to_string(),
|
||||
};
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(filter)),
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(&filter)),
|
||||
)
|
||||
.init();
|
||||
|
||||
let mut config = AppConfig::load(cli.config.as_deref());
|
||||
if let Some(port) = cli.port {
|
||||
config.web.port = port;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user