Skip to content

Commit

Permalink
internal: Use local time when formatting logs
Browse files Browse the repository at this point in the history
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
Wilfred committed Oct 16, 2024
1 parent 418c136 commit 36b9f09
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions 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
6 changes: 5 additions & 1 deletion crates/rust-analyzer/src/tracing/config.rs
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 36b9f09

Please sign in to comment.