Added the log level

This commit is contained in:
Connor Johnstone
2026-03-22 13:05:09 -04:00
parent 3dba620c9b
commit 44c96d125a
3 changed files with 42 additions and 6 deletions

View File

@@ -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;
}