Remove NoLog variant from Log enum and update stdout logging methods

This commit is contained in:
Greg Burri 2025-05-15 00:34:25 +02:00
parent 0201517e20
commit 9c2d89e981

View file

@ -35,7 +35,6 @@ pub enum Log {
directory: PathBuf,
},
StdoutOnly,
NoLog,
}
impl Log {
@ -86,8 +85,12 @@ impl Log {
}
pub fn new_to_stdout_only() -> Self {
Self::new_to_stdout_only_with_max_level(None)
}
pub fn new_to_stdout_only_with_max_level(level: Option<tracing::Level>) -> Self {
let layer_stdout = tracing_subscriber::fmt::layer()
.with_writer(std::io::stdout.with_max_level(TRACING_LEVEL))
.with_writer(std::io::stdout.with_max_level(level.unwrap_or(TRACING_LEVEL)))
.with_thread_ids(TRACING_DISPLAY_THREAD)
.with_thread_names(TRACING_DISPLAY_THREAD);
@ -98,10 +101,6 @@ impl Log {
Log::StdoutOnly
}
pub fn new_no_log() -> Self {
Log::NoLog
}
pub fn file_names(&self) -> std::io::Result<Vec<String>> {
match self {
Log::FileAndStdout { _guard, directory } => {
@ -130,7 +129,7 @@ impl Log {
.rev()
.collect())
}
Log::StdoutOnly | Log::NoLog => Ok(vec![]),
Log::StdoutOnly => Ok(vec![]),
}
}
@ -145,7 +144,7 @@ impl Log {
.map(|l| l.unwrap_or_default())
.collect())
}
Log::StdoutOnly | Log::NoLog => Ok(vec![]),
Log::StdoutOnly => Ok(vec![]),
}
}