mirror of
https://github.com/nushell/nushell.git
synced 2025-02-19 20:11:09 +01:00
Use local time for logger (#6132)
Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
parent
8c675a0d31
commit
f5856b0914
@ -1,4 +1,4 @@
|
|||||||
use chrono::{DateTime, FixedOffset, Utc};
|
use chrono::{DateTime, Local};
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use log::Level;
|
use log::Level;
|
||||||
use log::LevelFilter;
|
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()) {
|
let dt = match DateTime::parse_from_rfc3339(&f.timestamp_millis().to_string()) {
|
||||||
Ok(d) => d,
|
Ok(d) => d.with_timezone(&Local),
|
||||||
Err(_) => {
|
Err(_) => Local::now(),
|
||||||
let n = Utc::now();
|
|
||||||
DateTime::<FixedOffset>::from(n)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let time = dt.format("%Y-%m-%d %I:%M:%S%.3f %p");
|
let time = dt.format("%Y-%m-%d %I:%M:%S%.3f %p");
|
||||||
writeln!(f, "{}|{}|{}|{}", time, level, target, record.args(),)
|
writeln!(f, "{}|{}|{}|{}", time, level, target, record.args(),)
|
||||||
|
Loading…
Reference in New Issue
Block a user