mirror of
https://github.com/Xevion/banner.git
synced 2025-12-06 09:14:24 -06:00
refactor: remove 'auto' mode, just specify value via constant for better clap visibility
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -218,7 +218,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "banner"
|
name = "banner"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "banner"
|
name = "banner"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
default-run = "banner"
|
default-run = "banner"
|
||||||
|
|
||||||
|
|||||||
20
src/main.rs
20
src/main.rs
@@ -29,23 +29,26 @@ mod services;
|
|||||||
mod state;
|
mod state;
|
||||||
mod web;
|
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
|
/// Banner Discord Bot - Course availability monitoring
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Log formatter to use
|
/// Log formatter to use
|
||||||
#[arg(long, value_enum, default_value_t = LogFormatter::Auto)]
|
#[arg(long, value_enum, default_value_t = DEFAULT_TRACING_FORMAT)]
|
||||||
formatter: LogFormatter,
|
tracing: TracingFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::ValueEnum, Clone, Debug)]
|
#[derive(clap::ValueEnum, Clone, Debug)]
|
||||||
enum LogFormatter {
|
enum TracingFormat {
|
||||||
/// Use pretty formatter (default in debug mode)
|
/// Use pretty formatter (default in debug mode)
|
||||||
Pretty,
|
Pretty,
|
||||||
/// Use JSON formatter (default in release mode)
|
/// Use JSON formatter (default in release mode)
|
||||||
Json,
|
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> {
|
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
|
// Select formatter based on CLI args
|
||||||
let use_pretty = match args.formatter {
|
let use_pretty = match args.tracing {
|
||||||
LogFormatter::Pretty => true,
|
TracingFormat::Pretty => true,
|
||||||
LogFormatter::Json => false,
|
TracingFormat::Json => false,
|
||||||
LogFormatter::Auto => cfg!(debug_assertions),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let subscriber: Box<dyn tracing::Subscriber + Send + Sync> = if use_pretty {
|
let subscriber: Box<dyn tracing::Subscriber + Send + Sync> = if use_pretty {
|
||||||
|
|||||||
Reference in New Issue
Block a user