Skip to content

Commit bb4d1bf

Browse files
committed
Use UTC timezone for ts consistently
Previously, slog would try to use the local timezone and fallback to UTC in multi-threaded programs. The check for `is_single_threaded` takes an non-negligible amount of time when there's lots of logging. This uses UTC unconditionally instead, which both makes the format consistent across programs and also speeds up logging slightly.
1 parent 2b57966 commit bb4d1bf

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ where
332332
pub fn add_default_keys(self) -> Self {
333333
self.add_key_value(o!(
334334
"ts" => FnValue(move |_ : &Record| {
335-
time::OffsetDateTime::now_local()
336-
.unwrap_or_else(|_| time::OffsetDateTime::now_utc())
335+
time::OffsetDateTime::now_utc()
337336
.format(&time::format_description::well_known::Rfc3339)
338337
.ok()
339338
}),

0 commit comments

Comments
 (0)