Skip to content

Commit

Permalink
fix TestLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Feb 5, 2022
1 parent 89a7ff8 commit cf8fc32
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/loggers/testlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! Module providing the TestLogger Implementation
use super::logging::should_skip;
use crate::{Config, LevelPadding, SharedLogger};
use crate::{config::TimeFormat, Config, LevelPadding, SharedLogger};
use log::{set_boxed_logger, set_max_level, LevelFilter, Log, Metadata, Record, SetLoggerError};

use std::thread;
Expand Down Expand Up @@ -128,12 +128,18 @@ pub fn log(config: &Config, record: &Record<'_>) {

#[inline(always)]
pub fn write_time(config: &Config) {
let cur_time = if config.time_local {
chrono::Local::now().naive_local() + config.time_offset
} else {
chrono::Utc::now().naive_utc() + config.time_offset
use time::format_description::well_known::*;

let time = time::OffsetDateTime::now_utc().to_offset(config.time_offset);
let res = match config.time_format {
TimeFormat::Rfc2822 => time.format(&Rfc2822),
TimeFormat::Rfc3339 => time.format(&Rfc3339),
TimeFormat::Custom(format) => time.format(&format),
};
match res {
Ok(time) => println!("{} ", time),
Err(err) => panic!("Invalid time format: {}", err),
};
print!("{} ", cur_time.format(&*config.time_format));
}

#[inline(always)]
Expand Down

0 comments on commit cf8fc32

Please sign in to comment.