Added the log level
CI / check (push) Successful in 1m10s
CI / docker (push) Successful in 3m11s

This commit is contained in:
Connor Johnstone
2026-03-22 13:05:10 -04:00
parent 88b280c2b2
commit 763774ac1e
3 changed files with 28 additions and 7 deletions
+18 -6
View File
@@ -56,18 +56,30 @@ async fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
// Load config early so we can use log_level from it
let mut config = AppConfig::load(cli.config.as_deref());
// CLI -v flags override config log_level
let filter = match cli.verbose {
0 => "info,shanty=info,shanty_web=info",
1 => "info,shanty=debug,shanty_web=debug",
_ => "debug,shanty=trace,shanty_web=trace",
0 => {
// Use config log_level
let level = config.log_level.to_lowercase();
match level.as_str() {
"error" => "error".to_string(),
"warn" => "warn".to_string(),
"debug" => "debug,shanty=debug,shanty_web=debug".to_string(),
"trace" => "trace,shanty=trace,shanty_web=trace".to_string(),
_ => "info,shanty=info,shanty_web=info".to_string(),
}
}
1 => "info,shanty=debug,shanty_web=debug".to_string(),
_ => "debug,shanty=trace,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;
}