Skip to content

Commit

Permalink
Auto merge of #17990 - Wilfred:local_time_logs, r=Veykril
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Oct 16, 2024
2 parents 6bb6fd8 + 929d5bc commit 0be1e95
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,15 @@ dependencies = [
"libc",
]

[[package]]
name = "num_threads"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9"
dependencies = [
"libc",
]

[[package]]
name = "object"
version = "0.33.0"
Expand Down Expand Up @@ -2093,10 +2102,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
dependencies = [
"deranged",
"itoa",
"libc",
"num-conv",
"num_threads",
"powerfmt",
"serde",
"time-core",
"time-macros",
]

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

[[package]]
name = "time-macros"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf"
dependencies = [
"num-conv",
"time-core",
]

[[package]]
name = "tinyvec"
version = "1.8.0"
Expand Down Expand Up @@ -2213,6 +2236,7 @@ checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
dependencies = [
"sharded-slab",
"thread_local",
"time",
"tracing-core",
"tracing-log",
]
Expand Down
3 changes: 3 additions & 0 deletions src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ tracing-tree = "0.3.0"
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
"registry",
"fmt",
"local-time",
"std",
"time",
"tracing-log",
] }
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use anyhow::Context;
use tracing::level_filters::LevelFilter;
use tracing_subscriber::{
filter::{filter_fn, Targets},
fmt::MakeWriter,
fmt::{time, MakeWriter},
layer::SubscriberExt,
Layer, Registry,
};
Expand Down Expand Up @@ -58,6 +58,10 @@ where
let writer = self.writer;

let ra_fmt_layer = tracing_subscriber::fmt::layer()
.with_timer(
time::OffsetTime::local_rfc_3339()
.expect("Could not get local offset, make sure you're on the main thread"),
)
.with_target(false)
.with_ansi(false)
.with_writer(writer)
Expand Down

0 comments on commit 0be1e95

Please sign in to comment.