diff --git a/Cargo.lock b/Cargo.lock index a294b8c..71e0024 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "banner" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index c67af27..aa7b0b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "banner" -version = "0.2.1" +version = "0.2.2" edition = "2024" default-run = "banner" @@ -54,4 +54,4 @@ clap = { version = "4.5", features = ["derive"] } # A 'release mode' profile that compiles quickly, but still 'appears' like a release build, useful for debugging [profile.dev-release] inherits = "dev" -debug-assertions = false \ No newline at end of file +debug-assertions = false diff --git a/src/main.rs b/src/main.rs index ed72a7c..7e419bb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,23 +29,26 @@ mod services; mod state; mod web; +#[cfg(debug_assertions)] +const DEFAULT_TRACING_FORMAT: TracingFormat = TracingFormat::Pretty; +#[cfg(not(debug_assertions))] +const DEFAULT_TRACING_FORMAT: TracingFormat = TracingFormat::Json; + /// Banner Discord Bot - Course availability monitoring #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { /// Log formatter to use - #[arg(long, value_enum, default_value_t = LogFormatter::Auto)] - formatter: LogFormatter, + #[arg(long, value_enum, default_value_t = DEFAULT_TRACING_FORMAT)] + tracing: TracingFormat, } #[derive(clap::ValueEnum, Clone, Debug)] -enum LogFormatter { +enum TracingFormat { /// Use pretty formatter (default in debug mode) Pretty, /// Use JSON formatter (default in release mode) Json, - /// Auto-select based on build mode (debug=pretty, release=json) - Auto, } async fn update_bot_status(ctx: &Context, app_state: &AppState) -> Result<(), anyhow::Error> { @@ -89,10 +92,9 @@ async fn main() { }); // Select formatter based on CLI args - let use_pretty = match args.formatter { - LogFormatter::Pretty => true, - LogFormatter::Json => false, - LogFormatter::Auto => cfg!(debug_assertions), + let use_pretty = match args.tracing { + TracingFormat::Pretty => true, + TracingFormat::Json => false, }; let subscriber: Box = if use_pretty {