mirror of
https://github.com/nushell/nushell
synced 2024-11-16 09:47:57 +00:00
Use local time for logger (#6132)
Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
parent
8c675a0d31
commit
f5856b0914
1 changed files with 3 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
|||
use chrono::{DateTime, FixedOffset, Utc};
|
||||
use chrono::{DateTime, Local};
|
||||
use core::fmt;
|
||||
use log::Level;
|
||||
use log::LevelFilter;
|
||||
|
@ -32,11 +32,8 @@ pub fn my_formatted_timed_builder() -> Builder {
|
|||
});
|
||||
|
||||
let dt = match DateTime::parse_from_rfc3339(&f.timestamp_millis().to_string()) {
|
||||
Ok(d) => d,
|
||||
Err(_) => {
|
||||
let n = Utc::now();
|
||||
DateTime::<FixedOffset>::from(n)
|
||||
}
|
||||
Ok(d) => d.with_timezone(&Local),
|
||||
Err(_) => Local::now(),
|
||||
};
|
||||
let time = dt.format("%Y-%m-%d %I:%M:%S%.3f %p");
|
||||
writeln!(f, "{}|{}|{}|{}", time, level, target, record.args(),)
|
||||
|
|
Loading…
Reference in a new issue