use_utc() in v0.24.0 doesn't seem to work anymore
tdudz opened this issue · 3 comments
i updated my stack to 0.24.0
and even though i set use_utc()
when making the Logger
handle, it still prints out using my local time
i create the logger using the following:
Logger::try_with_str("info")
.unwrap()
.log_to_stdout()
.write_mode(WriteMode::Async)
.format(
|w: &mut dyn std::io::Write,
now: &mut flexi_logger::DeferredNow,
record: &log::Record| {
write!(
w,
"{} [{}] {}",
now.now().format("%Y-%m-%d %H:%M:%S%.6f"),
record.level(),
&record.args()
)
},
)
.use_utc()
.start()
.unwrap()
i tested it by reverting to the previous flexi_logger
version and the timestamps were UTC again. i suspect it might have something to do with the removal of time
and re-addition of chrono
use_utc()
is now implemented in DeferredNow::format()
, while the rest of DeferredNow
only uses local time. Especially DeferredNow::now()
returns DateTime<Local>
.
If you change your code snippet from
now.now().format("%Y-%m-%d %H:%M:%S%.6f"),
to
now.format("%Y-%m-%d %H:%M:%S%.6f"),
then it works as intended.
The behavior is a bit unclear, though. I need to improve the docu.
And more: I just saw that DeferredNow::format_rfc3164()
is not going through format()
and thus ignores use_utc()
, which is of course a real bug.
thanks, that worked!
Version 0.24.1 fixes also the bug in deferredNow::format_rfc3164()
.