Skip to content

Commit

Permalink
disable the logs by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Icerath committed Jan 11, 2025
1 parent 681743d commit 975bf67
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,32 @@ use petty_chess::{
prelude::*,
uci::{GoCommand, TimeControl, UciMessage, UciResponse},
};
use tracing::level_filters::LevelFilter;
#[cfg(feature = "tracing")]
use {
tracing::{debug, Level},
tracing::debug,
tracing_appender::rolling::{RollingFileAppender, Rotation},
};

#[derive(clap::Parser)]
struct Args {
#[arg(long = "run")]
message: Option<String>,
#[arg(long, default_value = "OFF")]
log_level: LevelFilter,
}

fn main() {
let args = Args::parse();

#[cfg(feature = "tracing")]
{
if args.log_level != LevelFilter::OFF {
let writer = RollingFileAppender::builder()
.rotation(Rotation::DAILY)
.filename_suffix("log")
.build("./logs")
.unwrap();
tracing_subscriber::fmt().with_max_level(Level::DEBUG).with_writer(writer).init();
tracing_subscriber::fmt().with_max_level(args.log_level).with_writer(writer).init();
}
let mut line = String::new();
let mut stdin = std::io::stdin().lock();
Expand Down

0 comments on commit 975bf67

Please sign in to comment.