Skip to content

Commit a439ed8

Browse files
committed
Auto merge of #17990 - Wilfred:local_time_logs, r=Veykril
internal: Use local time when formatting logs When debugging rust-analyzer and looking at logs, it's much easier to read when the timestamp is in the local timezone. Before: 2024-08-28T20:55:38.792321Z INFO ParseQuery: invoked at R18460 After: 2024-08-28T13:55:38.792321-07:00 INFO ParseQuery: invoked at R18460
2 parents 418c136 + 36b9f09 commit a439ed8

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

Cargo.lock

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ tracing-tree = "0.3.0"
153153
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
154154
"registry",
155155
"fmt",
156+
"local-time",
157+
"std",
158+
"time",
156159
"tracing-log",
157160
] }
158161
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }

crates/rust-analyzer/src/tracing/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use anyhow::Context;
77
use tracing::level_filters::LevelFilter;
88
use tracing_subscriber::{
99
filter::{filter_fn, Targets},
10-
fmt::MakeWriter,
10+
fmt::{time, MakeWriter},
1111
layer::SubscriberExt,
1212
Layer, Registry,
1313
};
@@ -58,6 +58,10 @@ where
5858
let writer = self.writer;
5959

6060
let ra_fmt_layer = tracing_subscriber::fmt::layer()
61+
.with_timer(
62+
time::OffsetTime::local_rfc_3339()
63+
.expect("Could not get local offset, make sure you're on the main thread"),
64+
)
6165
.with_target(false)
6266
.with_ansi(false)
6367
.with_writer(writer)

0 commit comments

Comments
 (0)