Skip to content

Commit 0be1e95

Browse files
committed
Auto merge of rust-lang#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 6bb6fd8 + 929d5bc commit 0be1e95

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

src/tools/rust-analyzer/Cargo.lock

+24
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,15 @@ dependencies = [
11871187
"libc",
11881188
]
11891189

1190+
[[package]]
1191+
name = "num_threads"
1192+
version = "0.1.7"
1193+
source = "registry+https://github.com/rust-lang/crates.io-index"
1194+
checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9"
1195+
dependencies = [
1196+
"libc",
1197+
]
1198+
11901199
[[package]]
11911200
name = "object"
11921201
version = "0.33.0"
@@ -2093,10 +2102,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
20932102
checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
20942103
dependencies = [
20952104
"deranged",
2105+
"itoa",
2106+
"libc",
20962107
"num-conv",
2108+
"num_threads",
20972109
"powerfmt",
20982110
"serde",
20992111
"time-core",
2112+
"time-macros",
21002113
]
21012114

21022115
[[package]]
@@ -2105,6 +2118,16 @@ version = "0.1.2"
21052118
source = "registry+https://github.com/rust-lang/crates.io-index"
21062119
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
21072120

2121+
[[package]]
2122+
name = "time-macros"
2123+
version = "0.2.18"
2124+
source = "registry+https://github.com/rust-lang/crates.io-index"
2125+
checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf"
2126+
dependencies = [
2127+
"num-conv",
2128+
"time-core",
2129+
]
2130+
21082131
[[package]]
21092132
name = "tinyvec"
21102133
version = "1.8.0"
@@ -2213,6 +2236,7 @@ checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
22132236
dependencies = [
22142237
"sharded-slab",
22152238
"thread_local",
2239+
"time",
22162240
"tracing-core",
22172241
"tracing-log",
22182242
]

src/tools/rust-analyzer/Cargo.toml

+3
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"] }

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

+5-1
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)