From 60001e1e3f5bdbfed88a10ad658a7f717ccf67e0 Mon Sep 17 00:00:00 2001 From: zeroflaw Date: Tue, 11 May 2021 11:17:57 +0100 Subject: [PATCH] add write thread name support for termlog --- src/loggers/termlog.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/loggers/termlog.rs b/src/loggers/termlog.rs index cfdfb459..2d4c04c6 100644 --- a/src/loggers/termlog.rs +++ b/src/loggers/termlog.rs @@ -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), @@ -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 {