Skip to content

Commit

Permalink
Fix log timestamps not using local timezone (#16400)
Browse files Browse the repository at this point in the history
Get time offset by time crate will fail if there are mutli threads. So
call `config_builder.set_time_offset_to_local()` is useless.

Closes #16397

after:
<img width="664" alt="image"
src="https://github.com/user-attachments/assets/2b15fa06-c411-44f9-9ea1-871d25eb577f">

Release Notes:

- Fixed Local Timezone not showing Zed.log
  • Loading branch information
bestgopher authored Aug 22, 2024
1 parent 20f85b9 commit e17a5c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/zed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ tab_switcher.workspace = true
supermaven.workspace = true
task.workspace = true
tasks_ui.workspace = true
time.workspace = true
telemetry_events.workspace = true
terminal_view.workspace = true
theme.workspace = true
Expand Down
7 changes: 6 additions & 1 deletion crates/zed/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod zed;

use anyhow::{anyhow, Context as _, Result};
use assistant::PromptBuilder;
use chrono::Offset;
use clap::{command, Parser};
use cli::FORCE_CLI_MODE_ENV_VAR_NAME;
use client::{parse_zed_link, Client, DevServerToken, UserStore};
Expand Down Expand Up @@ -44,6 +45,7 @@ use std::{
sync::Arc,
};
use theme::{ActiveTheme, SystemAppearance, ThemeRegistry, ThemeSettings};
use time::UtcOffset;
use util::{maybe, parse_env_output, ResultExt, TryFutureExt};
use uuid::Uuid;
use welcome::{show_welcome_view, BaseKeymap, FIRST_OPEN};
Expand Down Expand Up @@ -886,7 +888,10 @@ fn init_logger() {
let mut config_builder = ConfigBuilder::new();

config_builder.set_time_format_rfc3339();
config_builder.set_time_offset_to_local().log_err();
let local_offset = chrono::Local::now().offset().fix().local_minus_utc();
if let Ok(offset) = UtcOffset::from_whole_seconds(local_offset) {
config_builder.set_time_offset(offset);
}

#[cfg(target_os = "linux")]
{
Expand Down

0 comments on commit e17a5c1

Please sign in to comment.