diff options
| author | Laurențiu Nicola <lnicola@users.noreply.github.com> | 2024-10-23 17:15:23 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-23 17:15:23 +0000 |
| commit | 7dad963782d88205fffd206b4564bc3a03ff25cc (patch) | |
| tree | 03c79677ab4455c794fb6089826b8117acd64b4b | |
| parent | 1fbaccd893b8d0f393c14e94d8fbfe0c601c2e8f (diff) | |
| parent | 33f27d135e2d537b72adf8e67958a69e4fb81236 (diff) | |
| download | rust-7dad963782d88205fffd206b4564bc3a03ff25cc.tar.gz rust-7dad963782d88205fffd206b4564bc3a03ff25cc.zip | |
Merge pull request #18386 from Wilfred/missing_offset
fix: Handle missing time offsets gracefully
| -rw-r--r-- | src/tools/rust-analyzer/crates/rust-analyzer/src/tracing/config.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/tracing/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/tracing/config.rs index 5ab2dc2b67a..02ae4186ab6 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/tracing/config.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/tracing/config.rs @@ -58,14 +58,22 @@ 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) - .with_filter(targets_filter); + .with_writer(writer); + + let ra_fmt_layer = match time::OffsetTime::local_rfc_3339() { + Ok(timer) => { + // If we can get the time offset, format logs with the timezone. + ra_fmt_layer.with_timer(timer).boxed() + } + Err(_) => { + // Use system time if we can't get the time offset. This should + // never happen on Linux, but can happen on e.g. OpenBSD. + ra_fmt_layer.boxed() + } + } + .with_filter(targets_filter); let chalk_layer = match self.chalk_filter { Some(chalk_filter) => { |
