mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Merge pull request #18386 from Wilfred/missing_offset
fix: Handle missing time offsets gracefully
This commit is contained in:
commit
f8ef75aa45
1 changed files with 14 additions and 6 deletions
|
@ -58,13 +58,21 @@ where
|
||||||
let writer = self.writer;
|
let writer = self.writer;
|
||||||
|
|
||||||
let ra_fmt_layer = tracing_subscriber::fmt::layer()
|
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_target(false)
|
||||||
.with_ansi(false)
|
.with_ansi(false)
|
||||||
.with_writer(writer)
|
.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);
|
.with_filter(targets_filter);
|
||||||
|
|
||||||
let chalk_layer = match self.chalk_filter {
|
let chalk_layer = match self.chalk_filter {
|
||||||
|
|
Loading…
Reference in a new issue