Remove NoLog variant from Log enum and update stdout logging methods
This commit is contained in:
parent
0201517e20
commit
9c2d89e981
1 changed files with 7 additions and 8 deletions
|
|
@ -35,7 +35,6 @@ pub enum Log {
|
||||||
directory: PathBuf,
|
directory: PathBuf,
|
||||||
},
|
},
|
||||||
StdoutOnly,
|
StdoutOnly,
|
||||||
NoLog,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Log {
|
impl Log {
|
||||||
|
|
@ -86,8 +85,12 @@ impl Log {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_to_stdout_only() -> Self {
|
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()
|
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_ids(TRACING_DISPLAY_THREAD)
|
||||||
.with_thread_names(TRACING_DISPLAY_THREAD);
|
.with_thread_names(TRACING_DISPLAY_THREAD);
|
||||||
|
|
||||||
|
|
@ -98,10 +101,6 @@ impl Log {
|
||||||
Log::StdoutOnly
|
Log::StdoutOnly
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_no_log() -> Self {
|
|
||||||
Log::NoLog
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn file_names(&self) -> std::io::Result<Vec<String>> {
|
pub fn file_names(&self) -> std::io::Result<Vec<String>> {
|
||||||
match self {
|
match self {
|
||||||
Log::FileAndStdout { _guard, directory } => {
|
Log::FileAndStdout { _guard, directory } => {
|
||||||
|
|
@ -130,7 +129,7 @@ impl Log {
|
||||||
.rev()
|
.rev()
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
Log::StdoutOnly | Log::NoLog => Ok(vec![]),
|
Log::StdoutOnly => Ok(vec![]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,7 +144,7 @@ impl Log {
|
||||||
.map(|l| l.unwrap_or_default())
|
.map(|l| l.unwrap_or_default())
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
Log::StdoutOnly | Log::NoLog => Ok(vec![]),
|
Log::StdoutOnly => Ok(vec![]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue