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 d81a6b3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/loggers/testlog.rs
Expand Up @@ -8,7 +8,7 @@
//! Module providing the TestLogger Implementation

use super::logging::should_skip;
use crate::{Config, LevelPadding, SharedLogger};
use crate::{Config, LevelPadding, SharedLogger, config::TimeFormat};
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 d81a6b3

Please sign in to comment.