Skip to content

Commit

Permalink
update: chaining method instead of declaring 3 variables
Browse files Browse the repository at this point in the history
  • Loading branch information
theobori committed Jul 2, 2023
1 parent 70f4dcb commit e3ce782
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/loggers/logging.rs
Expand Up @@ -208,9 +208,10 @@ pub fn write_thread_id<W>(write: &mut W, config: &Config) -> Result<(), Error>
where
W: Write + Sized,
{
let id = format!("{:?}", thread::current().id());
let id = id.replace("ThreadId(", "");
let id = id.replace(")", "");
let id = format!("{:?}", thread::current().id())
.replace("ThreadId(", "")
.replace(")", "");

match config.thread_padding {
ThreadPadding::Left { 0: qty } => {
write!(write, "({id:>0$}) ", qty, id = id)?;
Expand Down
7 changes: 4 additions & 3 deletions src/loggers/testlog.rs
Expand Up @@ -158,9 +158,10 @@ pub fn write_level(record: &Record<'_>, config: &Config) {

#[inline(always)]
pub fn write_thread_id() {
let id = format!("{:?}", thread::current().id());
let id = id.replace("ThreadId(", "");
let id = id.replace(")", "");
let id = format!("{:?}", thread::current().id())
.replace("ThreadId(", "")
.replace(")", "");

print!("({}) ", id);
}

Expand Down

0 comments on commit e3ce782

Please sign in to comment.