mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-07 03:00:29 +00:00
Add --debug global CLI flag to switch log level from INFO to DEBUG
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
63099b0526
commit
9e74e6f913
2 changed files with 9 additions and 3 deletions
|
|
@ -1,8 +1,10 @@
|
|||
use anyhow::{Context, Result};
|
||||
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
||||
|
||||
pub fn init_tracing() -> Result<()> {
|
||||
let filter = EnvFilter::try_from_env("ARC_LOG").unwrap_or_else(|_| EnvFilter::new("info"));
|
||||
pub fn init_tracing(debug: bool) -> Result<()> {
|
||||
let default_level = if debug { "debug" } else { "info" };
|
||||
let filter =
|
||||
EnvFilter::try_from_env("ARC_LOG").unwrap_or_else(|_| EnvFilter::new(default_level));
|
||||
|
||||
let log_dir = dirs::home_dir()
|
||||
.map(|h| h.join(".arc").join("logs"))
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ struct Cli {
|
|||
#[arg(long, global = true)]
|
||||
no_dotenv: bool,
|
||||
|
||||
/// Enable DEBUG-level logging (default is INFO)
|
||||
#[arg(long, global = true)]
|
||||
debug: bool,
|
||||
|
||||
#[command(subcommand)]
|
||||
command: Command,
|
||||
}
|
||||
|
|
@ -65,7 +69,7 @@ async fn main() -> Result<()> {
|
|||
dotenvy::dotenv().ok();
|
||||
}
|
||||
|
||||
if let Err(err) = logging::init_tracing() {
|
||||
if let Err(err) = logging::init_tracing(cli.debug) {
|
||||
eprintln!("Warning: failed to initialize logging: {err:#}");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue