Skip to content

Commit

Permalink
add write thread name support for termlog
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroflaw committed May 11, 2021
1 parent adeb9cb commit 60001e1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/loggers/termlog.rs
Expand Up @@ -9,7 +9,7 @@ use termcolor::{ColorChoice, ColorSpec, StandardStream, WriteColor};

use super::logging::*;

use crate::{Config, SharedLogger};
use crate::{Config, SharedLogger, ThreadLogMode};

enum StdTerminal {
Stderr(Box<dyn WriteColor + Send>),
Expand Down Expand Up @@ -155,7 +155,14 @@ impl TermLogger {
}

if self.config.thread <= record.level() && self.config.thread != LevelFilter::Off {
write_thread_id(&mut *term_lock, &self.config)?;
match self.config.thread_log_mode {
ThreadLogMode::IDs => {
write_thread_id(&mut *term_lock, &self.config)?;
}
ThreadLogMode::Names | ThreadLogMode::Both => {
write_thread_name(&mut *term_lock, &self.config)?;
}
}
}

if self.config.target <= record.level() && self.config.target != LevelFilter::Off {
Expand Down

0 comments on commit 60001e1

Please sign in to comment.