From c0aa8f63fd94a266d5619852cbbfcbe2e25c75c5 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Mon, 26 May 2025 10:48:50 -0500 Subject: [PATCH] zlog: Replace usages of `env_logger` in tests with `zlog` (#31436) Also fixes: https://github.com/zed-industries/zed/pull/31400#issuecomment-2908165249 Release Notes: - N/A *or* Added/Fixed/Improved ... --- Cargo.lock | 52 +++++++++---------- crates/assistant_slash_commands/Cargo.toml | 2 +- .../src/file_command.rs | 4 +- crates/assistant_tool/Cargo.toml | 2 +- crates/assistant_tool/src/action_log.rs | 4 +- .../fixtures/add_overwrite_test/before.rs | 4 +- crates/assistant_tools/src/terminal_tool.rs | 3 +- crates/buffer_diff/Cargo.toml | 2 +- crates/buffer_diff/src/buffer_diff.rs | 4 +- crates/collab/Cargo.toml | 2 +- crates/collab/src/tests/debug_panel_tests.rs | 4 +- crates/collab/src/tests/integration_tests.rs | 4 +- .../remote_editing_collaboration_tests.rs | 4 +- crates/copilot/Cargo.toml | 2 +- crates/copilot/src/copilot.rs | 4 +- crates/dap/Cargo.toml | 2 +- crates/dap/src/client.rs | 4 +- crates/debugger_ui/Cargo.toml | 4 +- crates/debugger_ui/src/tests.rs | 5 +- crates/diagnostics/Cargo.toml | 4 +- crates/diagnostics/src/diagnostics_tests.rs | 6 +-- crates/editor/Cargo.toml | 2 +- crates/editor/src/test.rs | 4 +- crates/extension_host/Cargo.toml | 2 +- .../src/extension_store_test.rs | 4 +- crates/file_finder/Cargo.toml | 2 +- crates/file_finder/src/file_finder_tests.rs | 4 +- crates/git_ui/Cargo.toml | 2 +- crates/git_ui/src/git_panel.rs | 4 +- crates/git_ui/src/project_diff.rs | 2 +- crates/language/Cargo.toml | 2 +- crates/language/src/buffer_tests.rs | 4 +- crates/language_tools/Cargo.toml | 2 +- crates/language_tools/src/lsp_log_tests.rs | 4 +- crates/lsp/Cargo.toml | 2 +- crates/lsp/src/lsp.rs | 4 +- crates/multi_buffer/Cargo.toml | 2 +- crates/multi_buffer/src/multi_buffer_tests.rs | 4 +- crates/project/Cargo.toml | 1 - crates/project/src/git_store/conflict_set.rs | 2 +- crates/project/src/git_store/git_traversal.rs | 4 +- crates/project/src/image_store.rs | 4 +- crates/project/src/project_tests.rs | 4 +- crates/project/src/task_inventory.rs | 4 +- crates/remote_server/Cargo.toml | 1 + .../remote_server/src/remote_editing_tests.rs | 4 +- crates/rope/Cargo.toml | 2 +- crates/rope/src/rope.rs | 4 +- crates/rpc/Cargo.toml | 2 +- crates/rpc/src/peer.rs | 4 +- crates/semantic_index/Cargo.toml | 2 +- crates/semantic_index/examples/index.rs | 2 +- crates/semantic_index/src/semantic_index.rs | 2 +- crates/sum_tree/Cargo.toml | 2 +- crates/sum_tree/src/sum_tree.rs | 4 +- crates/tab_switcher/Cargo.toml | 2 +- crates/tab_switcher/src/tab_switcher_tests.rs | 4 +- crates/text/Cargo.toml | 2 +- crates/text/src/tests.rs | 4 +- crates/workspace/Cargo.toml | 2 +- crates/workspace/src/persistence.rs | 18 +++---- crates/worktree/Cargo.toml | 2 +- crates/worktree/src/worktree_tests.rs | 4 +- crates/zeta/Cargo.toml | 2 +- crates/zeta/src/zeta.rs | 4 +- crates/zlog/src/zlog.rs | 26 ++++++++-- 66 files changed, 123 insertions(+), 167 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 490f25d3967602f1cbd8cbd4d54618d8ff30d9e0..a786b25c0825c3cd1f8be5f524b23c657d144f89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -593,7 +593,6 @@ dependencies = [ "collections", "context_server", "editor", - "env_logger 0.11.8", "feature_flags", "fs", "futures 0.3.31", @@ -619,6 +618,7 @@ dependencies = [ "workspace", "workspace-hack", "worktree", + "zlog", ] [[package]] @@ -631,7 +631,6 @@ dependencies = [ "collections", "ctor", "derive_more", - "env_logger 0.11.8", "futures 0.3.31", "gpui", "icons", @@ -650,6 +649,7 @@ dependencies = [ "util", "workspace", "workspace-hack", + "zlog", ] [[package]] @@ -2222,7 +2222,6 @@ dependencies = [ "anyhow", "clock", "ctor", - "env_logger 0.11.8", "futures 0.3.31", "git2", "gpui", @@ -2237,6 +2236,7 @@ dependencies = [ "unindent", "util", "workspace-hack", + "zlog", ] [[package]] @@ -3007,7 +3007,6 @@ dependencies = [ "debugger_ui", "derive_more", "editor", - "env_logger 0.11.8", "envy", "extension", "file_finder", @@ -3082,6 +3081,7 @@ dependencies = [ "workspace-hack", "worktree", "zed_llm_client", + "zlog", ] [[package]] @@ -3336,7 +3336,6 @@ dependencies = [ "command_palette_hooks", "ctor", "editor", - "env_logger 0.11.8", "fs", "futures 0.3.31", "gpui", @@ -3362,6 +3361,7 @@ dependencies = [ "util", "workspace", "workspace-hack", + "zlog", ] [[package]] @@ -4012,7 +4012,6 @@ dependencies = [ "client", "collections", "dap-types", - "env_logger 0.11.8", "fs", "futures 0.3.31", "gpui", @@ -4033,6 +4032,7 @@ dependencies = [ "telemetry", "util", "workspace-hack", + "zlog", ] [[package]] @@ -4219,7 +4219,6 @@ dependencies = [ "db", "debugger_tools", "editor", - "env_logger 0.11.8", "feature_flags", "file_icons", "futures 0.3.31", @@ -4248,6 +4247,7 @@ dependencies = [ "util", "workspace", "workspace-hack", + "zlog", ] [[package]] @@ -4364,7 +4364,6 @@ dependencies = [ "component", "ctor", "editor", - "env_logger 0.11.8", "futures 0.3.31", "gpui", "indoc", @@ -4385,6 +4384,7 @@ dependencies = [ "util", "workspace", "workspace-hack", + "zlog", ] [[package]] @@ -4683,7 +4683,6 @@ dependencies = [ "dap", "db", "emojis", - "env_logger 0.11.8", "feature_flags", "file_icons", "fs", @@ -4737,6 +4736,7 @@ dependencies = [ "workspace", "workspace-hack", "zed_actions", + "zlog", ] [[package]] @@ -5162,7 +5162,6 @@ dependencies = [ "criterion", "ctor", "dap", - "env_logger 0.11.8", "extension", "fs", "futures 0.3.31", @@ -5199,6 +5198,7 @@ dependencies = [ "wasmtime", "wasmtime-wasi", "workspace-hack", + "zlog", ] [[package]] @@ -5372,7 +5372,6 @@ dependencies = [ "collections", "ctor", "editor", - "env_logger 0.11.8", "file_icons", "futures 0.3.31", "fuzzy", @@ -5392,6 +5391,7 @@ dependencies = [ "util", "workspace", "workspace-hack", + "zlog", ] [[package]] @@ -6106,7 +6106,6 @@ dependencies = [ "ctor", "db", "editor", - "env_logger 0.11.8", "futures 0.3.31", "fuzzy", "git", @@ -6142,6 +6141,7 @@ dependencies = [ "workspace", "workspace-hack", "zed_actions", + "zlog", ] [[package]] @@ -8723,7 +8723,6 @@ dependencies = [ "ctor", "diffy", "ec4rs", - "env_logger 0.11.8", "fs", "futures 0.3.31", "fuzzy", @@ -8768,6 +8767,7 @@ dependencies = [ "unindent", "util", "workspace-hack", + "zlog", ] [[package]] @@ -8894,7 +8894,6 @@ dependencies = [ "collections", "copilot", "editor", - "env_logger 0.11.8", "futures 0.3.31", "gpui", "itertools 0.14.0", @@ -8911,6 +8910,7 @@ dependencies = [ "workspace", "workspace-hack", "zed_actions", + "zlog", ] [[package]] @@ -9433,7 +9433,6 @@ dependencies = [ "async-pipe", "collections", "ctor", - "env_logger 0.11.8", "futures 0.3.31", "gpui", "log", @@ -9447,6 +9446,7 @@ dependencies = [ "smol", "util", "workspace-hack", + "zlog", ] [[package]] @@ -9943,7 +9943,6 @@ dependencies = [ "clock", "collections", "ctor", - "env_logger 0.11.8", "gpui", "indoc", "itertools 0.14.0", @@ -9964,6 +9963,7 @@ dependencies = [ "tree-sitter", "util", "workspace-hack", + "zlog", ] [[package]] @@ -12030,7 +12030,6 @@ dependencies = [ "context_server", "dap", "dap_adapters", - "env_logger 0.11.8", "extension", "fancy-regex 0.14.0", "fs", @@ -13015,6 +13014,7 @@ dependencies = [ "unindent", "util", "worktree", + "zlog", ] [[package]] @@ -13356,7 +13356,6 @@ dependencies = [ "arrayvec", "criterion", "ctor", - "env_logger 0.11.8", "gpui", "log", "rand 0.8.5", @@ -13366,6 +13365,7 @@ dependencies = [ "unicode-segmentation", "util", "workspace-hack", + "zlog", ] [[package]] @@ -13383,7 +13383,6 @@ dependencies = [ "base64 0.22.1", "chrono", "collections", - "env_logger 0.11.8", "futures 0.3.31", "gpui", "parking_lot", @@ -13397,6 +13396,7 @@ dependencies = [ "tracing", "util", "workspace-hack", + "zlog", "zstd", ] @@ -14112,7 +14112,6 @@ dependencies = [ "client", "clock", "collections", - "env_logger 0.11.8", "feature_flags", "fs", "futures 0.3.31", @@ -14143,6 +14142,7 @@ dependencies = [ "workspace", "workspace-hack", "worktree", + "zlog", ] [[package]] @@ -15175,11 +15175,11 @@ version = "0.1.0" dependencies = [ "arrayvec", "ctor", - "env_logger 0.11.8", "log", "rand 0.8.5", "rayon", "workspace-hack", + "zlog", ] [[package]] @@ -15490,7 +15490,6 @@ dependencies = [ "collections", "ctor", "editor", - "env_logger 0.11.8", "fuzzy", "gpui", "language", @@ -15507,6 +15506,7 @@ dependencies = [ "util", "workspace", "workspace-hack", + "zlog", ] [[package]] @@ -15752,7 +15752,6 @@ dependencies = [ "clock", "collections", "ctor", - "env_logger 0.11.8", "gpui", "http_client", "log", @@ -15765,6 +15764,7 @@ dependencies = [ "sum_tree", "util", "workspace-hack", + "zlog", ] [[package]] @@ -19113,7 +19113,6 @@ dependencies = [ "component", "dap", "db", - "env_logger 0.11.8", "fs", "futures 0.3.31", "gpui", @@ -19145,6 +19144,7 @@ dependencies = [ "windows 0.61.1", "workspace-hack", "zed_actions", + "zlog", ] [[package]] @@ -19341,7 +19341,6 @@ dependencies = [ "anyhow", "clock", "collections", - "env_logger 0.11.8", "fs", "futures 0.3.31", "fuzzy", @@ -19368,6 +19367,7 @@ dependencies = [ "text", "util", "workspace-hack", + "zlog", ] [[package]] @@ -20061,7 +20061,6 @@ dependencies = [ "ctor", "db", "editor", - "env_logger 0.11.8", "feature_flags", "fs", "futures 0.3.31", @@ -20100,6 +20099,7 @@ dependencies = [ "worktree", "zed_actions", "zed_llm_client", + "zlog", ] [[package]] diff --git a/crates/assistant_slash_commands/Cargo.toml b/crates/assistant_slash_commands/Cargo.toml index 92433d905ff450bc92748a100643fc85aaa9fd68..f703a753f5d261f4151d0d6a47eb3753fd18afb8 100644 --- a/crates/assistant_slash_commands/Cargo.toml +++ b/crates/assistant_slash_commands/Cargo.toml @@ -44,6 +44,6 @@ worktree.workspace = true workspace-hack.workspace = true [dev-dependencies] -env_logger.workspace = true pretty_assertions.workspace = true settings.workspace = true +zlog.workspace = true diff --git a/crates/assistant_slash_commands/src/file_command.rs b/crates/assistant_slash_commands/src/file_command.rs index 667bc4f864058375bdc9c23f9101646c128a7ba9..45465f8bb134a7f7dc80aabf08814bf4f9b5eda0 100644 --- a/crates/assistant_slash_commands/src/file_command.rs +++ b/crates/assistant_slash_commands/src/file_command.rs @@ -587,9 +587,7 @@ mod test { use super::collect_files; pub fn init_test(cx: &mut gpui::TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); cx.update(|cx| { let settings_store = SettingsStore::test(cx); diff --git a/crates/assistant_tool/Cargo.toml b/crates/assistant_tool/Cargo.toml index e903cb535886ccd3b30e33b5cb8c3657d55ad9ca..a7b388a7530031017dc17de06f246b195c856f0d 100644 --- a/crates/assistant_tool/Cargo.toml +++ b/crates/assistant_tool/Cargo.toml @@ -37,7 +37,6 @@ buffer_diff = { workspace = true, features = ["test-support"] } collections = { workspace = true, features = ["test-support"] } clock = { workspace = true, features = ["test-support"] } ctor.workspace = true -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } language = { workspace = true, features = ["test-support"] } language_model = { workspace = true, features = ["test-support"] } @@ -48,3 +47,4 @@ rand.workspace = true settings = { workspace = true, features = ["test-support"] } text = { workspace = true, features = ["test-support"] } util = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/assistant_tool/src/action_log.rs b/crates/assistant_tool/src/action_log.rs index 44c87c75b42c9ac2ebff7f081a35adddc91717fe..a5b350b518620860e046e467f3af0a5b348ce708 100644 --- a/crates/assistant_tool/src/action_log.rs +++ b/crates/assistant_tool/src/action_log.rs @@ -717,9 +717,7 @@ mod tests { #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } fn init_test(cx: &mut TestAppContext) { diff --git a/crates/assistant_tools/src/edit_agent/evals/fixtures/add_overwrite_test/before.rs b/crates/assistant_tools/src/edit_agent/evals/fixtures/add_overwrite_test/before.rs index cd7bd9270aaeb394eed76135506eb5651cdf4fd7..0d2a0be1fb889a74d0251e1493e6988aaded068e 100644 --- a/crates/assistant_tools/src/edit_agent/evals/fixtures/add_overwrite_test/before.rs +++ b/crates/assistant_tools/src/edit_agent/evals/fixtures/add_overwrite_test/before.rs @@ -676,9 +676,7 @@ mod tests { #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } fn init_test(cx: &mut TestAppContext) { diff --git a/crates/assistant_tools/src/terminal_tool.rs b/crates/assistant_tools/src/terminal_tool.rs index 7aba0e1051a74a43f8e76dcce8d05afcfec36bca..9b3ee0c2d2ff69f91804381ac8c7f8c04760d574 100644 --- a/crates/assistant_tools/src/terminal_tool.rs +++ b/crates/assistant_tools/src/terminal_tool.rs @@ -673,8 +673,7 @@ mod tests { use super::*; fn init_test(executor: &BackgroundExecutor, cx: &mut TestAppContext) { - zlog::init(); - zlog::init_output_stdout(); + zlog::init_test(); executor.allow_parking(); cx.update(|cx| { diff --git a/crates/buffer_diff/Cargo.toml b/crates/buffer_diff/Cargo.toml index cdc99f62f7c84bb14dc0cc6089881a0f5f881a1f..3d6c2a24e9de8dfb6e5fab7cff250fb3f26ec24d 100644 --- a/crates/buffer_diff/Cargo.toml +++ b/crates/buffer_diff/Cargo.toml @@ -31,9 +31,9 @@ workspace-hack.workspace = true [dev-dependencies] ctor.workspace = true -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } rand.workspace = true serde_json.workspace = true text = { workspace = true, features = ["test-support"] } unindent.workspace = true +zlog.workspace = true diff --git a/crates/buffer_diff/src/buffer_diff.rs b/crates/buffer_diff/src/buffer_diff.rs index ad01af6f563de86c03f34024b94042d19506c817..25ca57c3e13a03f4a7bff1b6b9b3ee6e4c8b8b16 100644 --- a/crates/buffer_diff/src/buffer_diff.rs +++ b/crates/buffer_diff/src/buffer_diff.rs @@ -1346,9 +1346,7 @@ mod tests { #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[gpui::test] diff --git a/crates/collab/Cargo.toml b/crates/collab/Cargo.toml index 52473da4bd0da150e9b4fec84e0c06336c0bb648..17119a9a9567a613cfa60294bb02bba99ab18cb7 100644 --- a/crates/collab/Cargo.toml +++ b/crates/collab/Cargo.toml @@ -95,7 +95,6 @@ dap = { workspace = true, features = ["test-support"] } dap_adapters = { workspace = true, features = ["test-support"] } debugger_ui = { workspace = true, features = ["test-support"] } editor = { workspace = true, features = ["test-support"] } -env_logger.workspace = true extension.workspace = true file_finder.workspace = true fs = { workspace = true, features = ["test-support"] } @@ -133,6 +132,7 @@ unindent.workspace = true util.workspace = true workspace = { workspace = true, features = ["test-support"] } worktree = { workspace = true, features = ["test-support"] } +zlog.workspace = true [package.metadata.cargo-machete] ignored = ["async-stripe"] diff --git a/crates/collab/src/tests/debug_panel_tests.rs b/crates/collab/src/tests/debug_panel_tests.rs index 9f42f8c69e66d7e39c38fc31af5414ccd594bff6..95a2e80ac4f88295727e9fa314d0a752d0afc43e 100644 --- a/crates/collab/src/tests/debug_panel_tests.rs +++ b/crates/collab/src/tests/debug_panel_tests.rs @@ -18,9 +18,7 @@ use workspace::{Workspace, dock::Panel}; use super::{TestClient, TestServer}; pub fn init_test(cx: &mut gpui::TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); cx.update(|cx| { theme::init(theme::LoadThemes::JustBase, cx); diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 20429c7038093f3429983dd4288578108492a54c..196de765f3932371fad4355b0c25bcf22e1f1801 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -56,9 +56,7 @@ use workspace::Pane; #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[gpui::test(iterations = 10)] diff --git a/crates/collab/src/tests/remote_editing_collaboration_tests.rs b/crates/collab/src/tests/remote_editing_collaboration_tests.rs index 10b362b0957db769cc52e6cd91ff5d8ee97035d6..f6e5c9218a6ae1db20315e653a1aed77a304b7e5 100644 --- a/crates/collab/src/tests/remote_editing_collaboration_tests.rs +++ b/crates/collab/src/tests/remote_editing_collaboration_tests.rs @@ -589,9 +589,7 @@ async fn test_remote_server_debugger( cx_a.update(|cx| { release_channel::init(SemanticVersion::default(), cx); command_palette_hooks::init(cx); - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); dap_adapters::init(cx); }); server_cx.update(|cx| { diff --git a/crates/copilot/Cargo.toml b/crates/copilot/Cargo.toml index bfa0e15067bb3880fd385ca8d60bdac21e978f53..c859d912b416c4ef0dd00bb9735ff1d99230200e 100644 --- a/crates/copilot/Cargo.toml +++ b/crates/copilot/Cargo.toml @@ -61,7 +61,6 @@ clock = { workspace = true, features = ["test-support"] } collections = { workspace = true, features = ["test-support"] } ctor.workspace = true editor = { workspace = true, features = ["test-support"] } -env_logger.workspace = true fs = { workspace = true, features = ["test-support"] } gpui = { workspace = true, features = ["test-support"] } http_client = { workspace = true, features = ["test-support"] } @@ -76,3 +75,4 @@ settings = { workspace = true, features = ["test-support"] } theme = { workspace = true, features = ["test-support"] } util = { workspace = true, features = ["test-support"] } workspace = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 4d1187497e4319ca841c9bdb3f3fbe27b183de37..60bf15eb5ff010d8cb03f08ac59828eaf9f70dc4 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -1329,7 +1329,5 @@ mod tests { #[cfg(test)] #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } diff --git a/crates/dap/Cargo.toml b/crates/dap/Cargo.toml index 67f2e4e4ec13a7eac269bc3c7ef11eb74436616b..01516353a9d5ac612c5f651ff3fc8e2c1620260a 100644 --- a/crates/dap/Cargo.toml +++ b/crates/dap/Cargo.toml @@ -53,8 +53,8 @@ workspace-hack.workspace = true [dev-dependencies] async-pipe.workspace = true -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } settings = { workspace = true, features = ["test-support"] } task = { workspace = true, features = ["test-support"] } util = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/dap/src/client.rs b/crates/dap/src/client.rs index d14439057d535d739e2b34d0c9d7f5fcccbc1d80..fee54abf9a8f509d626318932ca4aac1141f4023 100644 --- a/crates/dap/src/client.rs +++ b/crates/dap/src/client.rs @@ -281,9 +281,7 @@ mod tests { }; pub fn init_test(cx: &mut gpui::TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); cx.update(|cx| { let settings = SettingsStore::test(cx); diff --git a/crates/debugger_ui/Cargo.toml b/crates/debugger_ui/Cargo.toml index ec2843531b79e4c176e856759123142d579edb2c..e306b7d76c24cb3b579e0d16d5c470443bb0be31 100644 --- a/crates/debugger_ui/Cargo.toml +++ b/crates/debugger_ui/Cargo.toml @@ -21,7 +21,6 @@ test-support = [ "project/test-support", "util/test-support", "workspace/test-support", - "env_logger", "unindent", "debugger_tools" ] @@ -62,7 +61,6 @@ ui.workspace = true util.workspace = true workspace.workspace = true workspace-hack.workspace = true -env_logger = { workspace = true, optional = true } debugger_tools = { workspace = true, optional = true } unindent = { workspace = true, optional = true } @@ -71,9 +69,9 @@ dap = { workspace = true, features = ["test-support"] } dap_adapters = { workspace = true, features = ["test-support"] } debugger_tools = { workspace = true, features = ["test-support"] } editor = { workspace = true, features = ["test-support"] } -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } project = { workspace = true, features = ["test-support"] } unindent.workspace = true util = { workspace = true, features = ["test-support"] } workspace = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/debugger_ui/src/tests.rs b/crates/debugger_ui/src/tests.rs index ccb74a1bb4967522fde8b3299edadb46bfffdcea..22ba0e0806386e1af98890704976d9d8a2855e4b 100644 --- a/crates/debugger_ui/src/tests.rs +++ b/crates/debugger_ui/src/tests.rs @@ -35,9 +35,8 @@ mod stack_frame_list; mod variable_list; pub fn init_test(cx: &mut gpui::TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + #[cfg(test)] + zlog::init_test(); cx.update(|cx| { let settings = SettingsStore::test(cx); diff --git a/crates/diagnostics/Cargo.toml b/crates/diagnostics/Cargo.toml index 1b1e880498ea36ab21aa9120e579430254ebcad1..53b5792e10e73d1629a104e345965547b6f2b25e 100644 --- a/crates/diagnostics/Cargo.toml +++ b/crates/diagnostics/Cargo.toml @@ -18,7 +18,6 @@ collections.workspace = true component.workspace = true ctor.workspace = true editor.workspace = true -env_logger.workspace = true futures.workspace = true gpui.workspace = true indoc.workspace = true @@ -44,9 +43,10 @@ editor = { workspace = true, features = ["test-support"] } gpui = { workspace = true, features = ["test-support"] } language = { workspace = true, features = ["test-support"] } markdown = { workspace = true, features = ["test-support"] } -lsp = { workspace = true, features = ["test-support"] } +lsp = { workspace = true, features=["test-support"] } serde_json.workspace = true theme = { workspace = true, features = ["test-support"] } unindent.workspace = true workspace = { workspace = true, features = ["test-support"] } pretty_assertions.workspace = true +zlog.workspace = true diff --git a/crates/diagnostics/src/diagnostics_tests.rs b/crates/diagnostics/src/diagnostics_tests.rs index f22104ae53b7975ca7beb4eda2d1d8d68c26e47b..22776d525fefe62eb51ba7ff9a4634701fed8954 100644 --- a/crates/diagnostics/src/diagnostics_tests.rs +++ b/crates/diagnostics/src/diagnostics_tests.rs @@ -27,9 +27,7 @@ use util::{RandomCharIter, path, post_inc}; #[ctor::ctor] fn init_logger() { - if env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[gpui::test] @@ -1413,7 +1411,7 @@ async fn test_diagnostics_with_code(cx: &mut TestAppContext) { fn init_test(cx: &mut TestAppContext) { cx.update(|cx| { - env_logger::try_init().ok(); + zlog::init_test(); let settings = SettingsStore::test(cx); cx.set_global(settings); theme::init(theme::LoadThemes::JustBase, cx); diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.toml index ccaeee9dd6269e4fab6c7a1a7c4c68ae1cab09b8..718b7f0a00096dcd160b026bbd5b97e8ef4a8270 100644 --- a/crates/editor/Cargo.toml +++ b/crates/editor/Cargo.toml @@ -93,7 +93,6 @@ workspace-hack.workspace = true [dev-dependencies] ctor.workspace = true -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } language = { workspace = true, features = ["test-support"] } languages = {workspace = true, features = ["test-support"] } @@ -113,3 +112,4 @@ unindent.workspace = true util = { workspace = true, features = ["test-support"] } workspace = { workspace = true, features = ["test-support"] } http_client = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/editor/src/test.rs b/crates/editor/src/test.rs index da2011a0c62cb095f45f6a3f2ae5b978b08ce3db..f84db2990e929972bc245dadcf1f3ef34801ffb3 100644 --- a/crates/editor/src/test.rs +++ b/crates/editor/src/test.rs @@ -25,9 +25,7 @@ use util::test::{marked_text_offsets, marked_text_ranges}; #[cfg(test)] #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } pub fn test_font() -> Font { diff --git a/crates/extension_host/Cargo.toml b/crates/extension_host/Cargo.toml index 68cbd6a4a3def3d8dbd2482231ee2445e976a11e..c933d253c65b525b29eb072ce6910514b15e5932 100644 --- a/crates/extension_host/Cargo.toml +++ b/crates/extension_host/Cargo.toml @@ -57,7 +57,6 @@ workspace-hack.workspace = true [dev-dependencies] criterion.workspace = true ctor.workspace = true -env_logger.workspace = true fs = { workspace = true, features = ["test-support"] } gpui = { workspace = true, features = ["test-support"] } language = { workspace = true, features = ["test-support"] } @@ -68,6 +67,7 @@ rand.workspace = true reqwest_client.workspace = true theme = { workspace = true, features = ["test-support"] } theme_extension.workspace = true +zlog.workspace = true [[bench]] name = "extension_compilation_benchmark" diff --git a/crates/extension_host/src/extension_store_test.rs b/crates/extension_host/src/extension_store_test.rs index c7332b3893627c89dd573a15c2fb0cae2582e14a..fdd6bf2332061e955fd2a63051fec84f642d281e 100644 --- a/crates/extension_host/src/extension_store_test.rs +++ b/crates/extension_host/src/extension_store_test.rs @@ -30,9 +30,7 @@ use util::test::TempTree; #[cfg(test)] #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[gpui::test] diff --git a/crates/file_finder/Cargo.toml b/crates/file_finder/Cargo.toml index bb31c7a2ce291fdf0ebd284e7db05ff4345d3bc1..3298a8c6bfa37f57f123d269b7810fc0b80c94ac 100644 --- a/crates/file_finder/Cargo.toml +++ b/crates/file_finder/Cargo.toml @@ -37,10 +37,10 @@ workspace-hack.workspace = true [dev-dependencies] ctor.workspace = true editor = { workspace = true, features = ["test-support"] } -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } language = { workspace = true, features = ["test-support"] } picker = { workspace = true, features = ["test-support"] } serde_json.workspace = true theme = { workspace = true, features = ["test-support"] } workspace = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/file_finder/src/file_finder_tests.rs b/crates/file_finder/src/file_finder_tests.rs index 37d12562c6d0454ac1e653bfda09fc39ebd6f66e..71bfef2685e204cca867f2af0224acda0dd4d638 100644 --- a/crates/file_finder/src/file_finder_tests.rs +++ b/crates/file_finder/src/file_finder_tests.rs @@ -11,9 +11,7 @@ use workspace::{AppState, OpenOptions, ToggleFileFinder, Workspace}; #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[test] diff --git a/crates/git_ui/Cargo.toml b/crates/git_ui/Cargo.toml index 33f5a4e4fd1e1b51ecb2af7ec2a4018655bdc0db..3447982d929294f01b3556b5d16e39cdda285e06 100644 --- a/crates/git_ui/Cargo.toml +++ b/crates/git_ui/Cargo.toml @@ -65,7 +65,6 @@ windows.workspace = true [dev-dependencies] ctor.workspace = true -env_logger.workspace = true editor = { workspace = true, features = ["test-support"] } gpui = { workspace = true, features = ["test-support"] } pretty_assertions.workspace = true @@ -73,3 +72,4 @@ project = { workspace = true, features = ["test-support"] } settings = { workspace = true, features = ["test-support"] } unindent.workspace = true workspace = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index dad4c9647827bda17bfde772e32a39a310ea09ec..43cc2283bc472a9c7e19d0082a82f93eafb03b2c 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -4779,9 +4779,7 @@ mod tests { use super::*; fn init_test(cx: &mut gpui::TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); cx.update(|cx| { let settings_store = SettingsStore::test(cx); diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs index dd81065ed57ee897e0ac1b458ac70fba60703f35..5a10731bfd5249d8943983313a141e818a38782a 100644 --- a/crates/git_ui/src/project_diff.rs +++ b/crates/git_ui/src/project_diff.rs @@ -1347,7 +1347,7 @@ mod tests { #[ctor::ctor] fn init_logger() { - env_logger::init(); + zlog::init_test(); } fn init_test(cx: &mut TestAppContext) { diff --git a/crates/language/Cargo.toml b/crates/language/Cargo.toml index 8750480bb915dd5a8a87ce0a2eb0ffa753b419b8..ef1b0c195b0111fb73df30e9c1e01797e3e2a67f 100644 --- a/crates/language/Cargo.toml +++ b/crates/language/Cargo.toml @@ -71,7 +71,6 @@ diffy = "0.4.2" [dev-dependencies] collections = { workspace = true, features = ["test-support"] } ctor.workspace = true -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } indoc.workspace = true lsp = { workspace = true, features = ["test-support"] } @@ -92,3 +91,4 @@ tree-sitter-rust.workspace = true tree-sitter-typescript.workspace = true unindent.workspace = true util = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/language/src/buffer_tests.rs b/crates/language/src/buffer_tests.rs index 86e8da4c3ccc5ef2861d3e31d7438886db81fc27..2ce50d37f4d2bea58e292817f5275f714b3db631 100644 --- a/crates/language/src/buffer_tests.rs +++ b/crates/language/src/buffer_tests.rs @@ -39,9 +39,7 @@ pub static TRAILING_WHITESPACE_REGEX: LazyLock = LazyLock::new(|| #[cfg(test)] #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[gpui::test] diff --git a/crates/language_tools/Cargo.toml b/crates/language_tools/Cargo.toml index 33afbbd0c7d4f6f21e69298a81dd9a644a0c0f30..cb07b46215d1bd207c91fd505f5042dbcb4d0463 100644 --- a/crates/language_tools/Cargo.toml +++ b/crates/language_tools/Cargo.toml @@ -36,6 +36,6 @@ workspace-hack.workspace = true client = { workspace = true, features = ["test-support"] } editor = { workspace = true, features = ["test-support"] } release_channel.workspace = true -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } util = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/language_tools/src/lsp_log_tests.rs b/crates/language_tools/src/lsp_log_tests.rs index a5f15790e990e4d2e7ac6a61b9cbc302ec0620ff..ad2b653fdcfd4dc228cac58da7ed15f844b4bb26 100644 --- a/crates/language_tools/src/lsp_log_tests.rs +++ b/crates/language_tools/src/lsp_log_tests.rs @@ -15,9 +15,7 @@ use util::path; #[gpui::test] async fn test_lsp_logs(cx: &mut TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); init_test(cx); diff --git a/crates/lsp/Cargo.toml b/crates/lsp/Cargo.toml index 715049c59d6f9244056a974553f311388a600a19..bc1f8b341b76b1be3e23824033f057a3a00201b3 100644 --- a/crates/lsp/Cargo.toml +++ b/crates/lsp/Cargo.toml @@ -36,6 +36,6 @@ workspace-hack.workspace = true [dev-dependencies] async-pipe.workspace = true ctor.workspace = true -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } util = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index cd810fb9a7da235858164e62d2e8fb2874fffcaf..626a238604e04da3996fe1d7024df4f27e35ec10 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -1668,9 +1668,7 @@ mod tests { #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[gpui::test] diff --git a/crates/multi_buffer/Cargo.toml b/crates/multi_buffer/Cargo.toml index ae6e4d266f2544a9bb2567836b6797efe2bef875..d5a38f539824c4b17f0c654148362ca5f906c8ba 100644 --- a/crates/multi_buffer/Cargo.toml +++ b/crates/multi_buffer/Cargo.toml @@ -27,7 +27,6 @@ clock.workspace = true collections.workspace = true ctor.workspace = true buffer_diff.workspace = true -env_logger.workspace = true gpui.workspace = true itertools.workspace = true language.workspace = true @@ -57,3 +56,4 @@ rand.workspace = true settings = { workspace = true, features = ["test-support"] } text = { workspace = true, features = ["test-support"] } util = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/multi_buffer/src/multi_buffer_tests.rs b/crates/multi_buffer/src/multi_buffer_tests.rs index ffee4ed5f157dc8b59f3257b806c024f8a6b08c5..864b819a4c07bb76d444b80e0691f9381a594266 100644 --- a/crates/multi_buffer/src/multi_buffer_tests.rs +++ b/crates/multi_buffer/src/multi_buffer_tests.rs @@ -11,9 +11,7 @@ use util::test::sample_text; #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[gpui::test] diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.toml index 0314a917213d2f38224978e90035ac9d365cdb0c..552cbae9755941c11eacc09ffeaf42cb277f1797 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -93,7 +93,6 @@ collections = { workspace = true, features = ["test-support"] } buffer_diff = { workspace = true, features = ["test-support"] } dap = { workspace = true, features = ["test-support"] } dap_adapters = { workspace = true, features = ["test-support"] } -env_logger.workspace = true fs = { workspace = true, features = ["test-support"] } git2.workspace = true gpui = { workspace = true, features = ["test-support"] } diff --git a/crates/project/src/git_store/conflict_set.rs b/crates/project/src/git_store/conflict_set.rs index 3c05e93ab75bea9ac2be2d03a403de5df9aadac2..89a898d950a8afdac909fc55e20263121058dd66 100644 --- a/crates/project/src/git_store/conflict_set.rs +++ b/crates/project/src/git_store/conflict_set.rs @@ -463,7 +463,7 @@ mod tests { #[gpui::test] async fn test_conflict_updates(executor: BackgroundExecutor, cx: &mut TestAppContext) { - env_logger::try_init().ok(); + zlog::init_test(); cx.update(|cx| { settings::init(cx); WorktreeSettings::register(cx); diff --git a/crates/project/src/git_store/git_traversal.rs b/crates/project/src/git_store/git_traversal.rs index 363a7b7d7d80fcbded9905b8b455d262d79c8de6..f7aa263e405a022213c146a00491383986f40eac 100644 --- a/crates/project/src/git_store/git_traversal.rs +++ b/crates/project/src/git_store/git_traversal.rs @@ -674,9 +674,7 @@ mod tests { } fn init_test(cx: &mut gpui::TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); cx.update(|cx| { let settings_store = SettingsStore::test(cx); diff --git a/crates/project/src/image_store.rs b/crates/project/src/image_store.rs index a290c521d566d13dc546ddb42730eb899b7a38ed..79f134b91a36a2f7d1f3f256506931b47ae8cf9c 100644 --- a/crates/project/src/image_store.rs +++ b/crates/project/src/image_store.rs @@ -739,9 +739,7 @@ mod tests { use std::path::PathBuf; pub fn init_test(cx: &mut TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); cx.update(|cx| { let settings_store = SettingsStore::test(cx); diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rs index 37d08687707bdd98c1e20a2cff32de5243fef099..5ba121ec08c145ebb5db358447ec4089fc5c5e84 100644 --- a/crates/project/src/project_tests.rs +++ b/crates/project/src/project_tests.rs @@ -8528,9 +8528,7 @@ async fn search( } pub fn init_test(cx: &mut gpui::TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); cx.update(|cx| { let settings_store = SettingsStore::test(cx); diff --git a/crates/project/src/task_inventory.rs b/crates/project/src/task_inventory.rs index 8ec561f48e44ec78a828f988db6470c4c7e9ef4a..c779f4e0d71ddd881d1b7a54e7889dd4db17628f 100644 --- a/crates/project/src/task_inventory.rs +++ b/crates/project/src/task_inventory.rs @@ -1191,9 +1191,7 @@ mod tests { } fn init_test(_cx: &mut TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); TaskStore::init(None); } diff --git a/crates/remote_server/Cargo.toml b/crates/remote_server/Cargo.toml index c0ec39c06707af4d26408fb28e16272235ca8015..207f93cd3265a4281fbea5d3d8bd4a92844d78de 100644 --- a/crates/remote_server/Cargo.toml +++ b/crates/remote_server/Cargo.toml @@ -86,6 +86,7 @@ language_model = { workspace = true, features = ["test-support"] } lsp = { workspace = true, features=["test-support"] } unindent.workspace = true serde_json.workspace = true +zlog.workspace = true [build-dependencies] cargo_toml.workspace = true diff --git a/crates/remote_server/src/remote_editing_tests.rs b/crates/remote_server/src/remote_editing_tests.rs index 9c4cfc6743b3c62d9c58ef69791e5f3ef0a52e7f..def14d12f595bc0ee745a3cc03f15c54de67a8d2 100644 --- a/crates/remote_server/src/remote_editing_tests.rs +++ b/crates/remote_server/src/remote_editing_tests.rs @@ -1663,9 +1663,7 @@ pub async fn init_test( } fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); } fn build_project(ssh: Entity, cx: &mut TestAppContext) -> Entity { diff --git a/crates/rope/Cargo.toml b/crates/rope/Cargo.toml index d9714a23ae5fcc12b88d6a224e06e53784a70efb..682b9aad92e355538333da358713d8c97f765b97 100644 --- a/crates/rope/Cargo.toml +++ b/crates/rope/Cargo.toml @@ -23,11 +23,11 @@ workspace-hack.workspace = true [dev-dependencies] ctor.workspace = true -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } rand.workspace = true util = { workspace = true, features = ["test-support"] } criterion.workspace = true +zlog.workspace = true [[bench]] name = "rope_benchmark" diff --git a/crates/rope/src/rope.rs b/crates/rope/src/rope.rs index efd89a0f72490010320209e0027c9a85c9f6ec68..b049498ccb44539cb2c1425c527214aa0dd83e5b 100644 --- a/crates/rope/src/rope.rs +++ b/crates/rope/src/rope.rs @@ -1435,9 +1435,7 @@ mod tests { #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[test] diff --git a/crates/rpc/Cargo.toml b/crates/rpc/Cargo.toml index bf84e15d293b1379084a4e7a117a971bac9b305b..81764917a7e888a766571e4114f614f7391bc000 100644 --- a/crates/rpc/Cargo.toml +++ b/crates/rpc/Cargo.toml @@ -40,6 +40,6 @@ workspace-hack.workspace = true [dev-dependencies] collections = { workspace = true, features = ["test-support"] } -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } proto = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/rpc/src/peer.rs b/crates/rpc/src/peer.rs index 41ca60b2522f81033ede4c613539bac81dd1f315..80a104641ff92888c5a21ec60e7f77a927427cd5 100644 --- a/crates/rpc/src/peer.rs +++ b/crates/rpc/src/peer.rs @@ -684,9 +684,7 @@ mod tests { use gpui::TestAppContext; fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[gpui::test(iterations = 50)] diff --git a/crates/semantic_index/Cargo.toml b/crates/semantic_index/Cargo.toml index 84ca5597185f06577dd554e51cf32e675cd46e7a..c5fe14d9cf9b79e55343b2943b49eb9d6f1a139b 100644 --- a/crates/semantic_index/Cargo.toml +++ b/crates/semantic_index/Cargo.toml @@ -54,7 +54,6 @@ workspace-hack.workspace = true [dev-dependencies] client = { workspace = true, features = ["test-support"] } -env_logger.workspace = true fs = { workspace = true, features = ["test-support"] } futures.workspace = true gpui = { workspace = true, features = ["test-support"] } @@ -67,3 +66,4 @@ reqwest_client.workspace = true util = { workspace = true, features = ["test-support"] } workspace = { workspace = true, features = ["test-support"] } worktree = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/semantic_index/examples/index.rs b/crates/semantic_index/examples/index.rs index 1b90de7749b1076603217e019b1ef817032c93b1..da27b8ad224d31c4e1de8b7d966a925bc52782d1 100644 --- a/crates/semantic_index/examples/index.rs +++ b/crates/semantic_index/examples/index.rs @@ -12,7 +12,7 @@ use std::{ }; fn main() { - env_logger::init(); + zlog::init(); use clock::FakeSystemClock; diff --git a/crates/semantic_index/src/semantic_index.rs b/crates/semantic_index/src/semantic_index.rs index 080b8b9c46ed0a52097fc585582dd3358f8df1dd..d3dcc488e184892674cf5e8352d742f3b0df5c2b 100644 --- a/crates/semantic_index/src/semantic_index.rs +++ b/crates/semantic_index/src/semantic_index.rs @@ -280,7 +280,7 @@ mod tests { use util::separator; fn init_test(cx: &mut TestAppContext) { - env_logger::try_init().ok(); + zlog::init_test(); cx.update(|cx| { let store = SettingsStore::test(cx); diff --git a/crates/sum_tree/Cargo.toml b/crates/sum_tree/Cargo.toml index 630db0ce02fd219cd1c58a8e61727c4cf6d388b7..63542b0615493125af4a72a8ab2bbe613e364ff3 100644 --- a/crates/sum_tree/Cargo.toml +++ b/crates/sum_tree/Cargo.toml @@ -20,5 +20,5 @@ workspace-hack.workspace = true [dev-dependencies] ctor.workspace = true -env_logger.workspace = true rand.workspace = true +zlog.workspace = true diff --git a/crates/sum_tree/src/sum_tree.rs b/crates/sum_tree/src/sum_tree.rs index 5b53bf7cbf71a841092e2cbaf14e8fb21f83c0b0..d5f8deadad4ff12bbbd1c79bc47c61891564d03c 100644 --- a/crates/sum_tree/src/sum_tree.rs +++ b/crates/sum_tree/src/sum_tree.rs @@ -998,9 +998,7 @@ mod tests { #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[test] diff --git a/crates/tab_switcher/Cargo.toml b/crates/tab_switcher/Cargo.toml index 027268e7d70aa8dcf6184c86f3cc141f46a418a5..d578c76f349d0f7b27764974ab2d1a9c84529dd6 100644 --- a/crates/tab_switcher/Cargo.toml +++ b/crates/tab_switcher/Cargo.toml @@ -32,9 +32,9 @@ workspace-hack.workspace = true [dev-dependencies] anyhow.workspace = true ctor.workspace = true -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } language = { workspace = true, features = ["test-support"] } serde_json.workspace = true theme = { workspace = true, features = ["test-support"] } workspace = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/tab_switcher/src/tab_switcher_tests.rs b/crates/tab_switcher/src/tab_switcher_tests.rs index 2ea9d6d817b03ebef3f53842d2c98b91f89dc8ef..e227a0e453d587db49076356ba0599706588bad7 100644 --- a/crates/tab_switcher/src/tab_switcher_tests.rs +++ b/crates/tab_switcher/src/tab_switcher_tests.rs @@ -10,9 +10,7 @@ use workspace::{AppState, Workspace}; #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[gpui::test] diff --git a/crates/text/Cargo.toml b/crates/text/Cargo.toml index 20731a059eea7122d1836b3e763f5a74530aebf1..e6c7d814948ea2657b2d7ef1786bd106fa4ea78a 100644 --- a/crates/text/Cargo.toml +++ b/crates/text/Cargo.toml @@ -33,8 +33,8 @@ workspace-hack.workspace = true [dev-dependencies] collections = { workspace = true, features = ["test-support"] } ctor.workspace = true -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } rand.workspace = true util = { workspace = true, features = ["test-support"] } http_client = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/text/src/tests.rs b/crates/text/src/tests.rs index 3338fc5c0082fb028797c6e0be58f7578dcd536d..f2a14d64b4fb33ec7f81db176ea4a0d9479236cf 100644 --- a/crates/text/src/tests.rs +++ b/crates/text/src/tests.rs @@ -11,9 +11,7 @@ use std::{ #[cfg(test)] #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } #[test] diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.toml index 22ec62a2be5b77eebd3c7cfccb227d6f18349cfd..e1bda7ad3621f308a5b1a9f2f465394e5200c583 100644 --- a/crates/workspace/Cargo.toml +++ b/crates/workspace/Cargo.toml @@ -74,7 +74,6 @@ call = { workspace = true, features = ["test-support"] } client = { workspace = true, features = ["test-support"] } dap = { workspace = true, features = ["test-support"] } db = { workspace = true, features = ["test-support"] } -env_logger.workspace = true fs = { workspace = true, features = ["test-support"] } gpui = { workspace = true, features = ["test-support"] } project = { workspace = true, features = ["test-support"] } @@ -82,3 +81,4 @@ session = { workspace = true, features = ["test-support"] } settings = { workspace = true, features = ["test-support"] } http_client = { workspace = true, features = ["test-support"] } tempfile.workspace = true +zlog.workspace = true diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index ecb5bb0c907f3ca333290ba69d7b36cebb9ad042..406f37419d1b02d14817ad165d4fa5cdd4c6d452 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -1466,7 +1466,7 @@ mod tests { #[gpui::test] async fn test_breakpoints() { - env_logger::try_init().ok(); + zlog::init_test(); let db = WorkspaceDb::open_test_db("test_breakpoints").await; let id = db.next_id().await.unwrap(); @@ -1651,7 +1651,7 @@ mod tests { #[gpui::test] async fn test_remove_last_breakpoint() { - env_logger::try_init().ok(); + zlog::init_test(); let db = WorkspaceDb::open_test_db("test_remove_last_breakpoint").await; let id = db.next_id().await.unwrap(); @@ -1738,7 +1738,7 @@ mod tests { #[gpui::test] async fn test_next_id_stability() { - env_logger::try_init().ok(); + zlog::init_test(); let db = WorkspaceDb::open_test_db("test_next_id_stability").await; @@ -1786,7 +1786,7 @@ mod tests { #[gpui::test] async fn test_workspace_id_stability() { - env_logger::try_init().ok(); + zlog::init_test(); let db = WorkspaceDb::open_test_db("test_workspace_id_stability").await; @@ -1880,7 +1880,7 @@ mod tests { #[gpui::test] async fn test_full_workspace_serialization() { - env_logger::try_init().ok(); + zlog::init_test(); let db = WorkspaceDb::open_test_db("test_full_workspace_serialization").await; @@ -1955,7 +1955,7 @@ mod tests { #[gpui::test] async fn test_workspace_assignment() { - env_logger::try_init().ok(); + zlog::init_test(); let db = WorkspaceDb::open_test_db("test_basic_functionality").await; @@ -2051,7 +2051,7 @@ mod tests { #[gpui::test] async fn test_session_workspaces() { - env_logger::try_init().ok(); + zlog::init_test(); let db = WorkspaceDb::open_test_db("test_serializing_workspaces_session_id").await; @@ -2488,7 +2488,7 @@ mod tests { #[gpui::test] async fn test_simple_split() { - env_logger::try_init().ok(); + zlog::init_test(); let db = WorkspaceDb::open_test_db("simple_split").await; @@ -2543,7 +2543,7 @@ mod tests { #[gpui::test] async fn test_cleanup_panes() { - env_logger::try_init().ok(); + zlog::init_test(); let db = WorkspaceDb::open_test_db("test_cleanup_panes").await; diff --git a/crates/worktree/Cargo.toml b/crates/worktree/Cargo.toml index e9cafdf136309d7661d606efce453ac4931998a4..db264fe3aab8c40686161a87e76cba21b2a8100f 100644 --- a/crates/worktree/Cargo.toml +++ b/crates/worktree/Cargo.toml @@ -52,7 +52,6 @@ workspace-hack.workspace = true [dev-dependencies] clock = { workspace = true, features = ["test-support"] } collections = { workspace = true, features = ["test-support"] } -env_logger.workspace = true git2.workspace = true gpui = { workspace = true, features = ["test-support"] } http_client.workspace = true @@ -61,3 +60,4 @@ rand.workspace = true rpc = { workspace = true, features = ["test-support"] } settings = { workspace = true, features = ["test-support"] } util = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index c3f56af4c6098df86d7c151307506b438e3eae4d..d4c309e5bc849696898da4812d5145ac2d9a70bf 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -2091,9 +2091,7 @@ fn check_worktree_entries( } fn init_test(cx: &mut gpui::TestAppContext) { - if std::env::var("RUST_LOG").is_ok() { - env_logger::try_init().ok(); - } + zlog::init_test(); cx.update(|cx| { let settings_store = SettingsStore::test(cx); diff --git a/crates/zeta/Cargo.toml b/crates/zeta/Cargo.toml index 8d3da636df2e18ec907c3af11627d00391528a14..1609773339a57df929ce317ce2a793fb8b067bca 100644 --- a/crates/zeta/Cargo.toml +++ b/crates/zeta/Cargo.toml @@ -64,7 +64,6 @@ client = { workspace = true, features = ["test-support"] } clock = { workspace = true, features = ["test-support"] } ctor.workspace = true editor = { workspace = true, features = ["test-support"] } -env_logger.workspace = true gpui = { workspace = true, features = ["test-support"] } http_client = { workspace = true, features = ["test-support"] } indoc.workspace = true @@ -79,3 +78,4 @@ unindent.workspace = true workspace = { workspace = true, features = ["test-support"] } worktree = { workspace = true, features = ["test-support"] } call = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rs index f84ed5eb2fab0fe492b3cb00dae26143922de27f..7b2c49c51282274373ace8b8c0066cfc7b78abf9 100644 --- a/crates/zeta/src/zeta.rs +++ b/crates/zeta/src/zeta.rs @@ -2140,8 +2140,6 @@ mod tests { #[ctor::ctor] fn init_logger() { - if std::env::var("RUST_LOG").is_ok() { - env_logger::init(); - } + zlog::init_test(); } } diff --git a/crates/zlog/src/zlog.rs b/crates/zlog/src/zlog.rs index 7ccff6ff8cb3875ec10bf91e0f878d33500f64b5..d8b685e57fbca7580d145e6fd172d8985b5ab906 100644 --- a/crates/zlog/src/zlog.rs +++ b/crates/zlog/src/zlog.rs @@ -5,18 +5,38 @@ mod env_config; pub mod filter; pub mod sink; +use anyhow::Context; pub use sink::{flush, init_output_file, init_output_stdout}; pub const SCOPE_DEPTH_MAX: usize = 4; pub fn init() { - process_env(); - log::set_logger(&ZLOG).expect("Logger should not be initialized twice"); + try_init().expect("Failed to initialize logger"); +} + +pub fn try_init() -> anyhow::Result<()> { + log::set_logger(&ZLOG).context("cannot be initialized twice")?; log::set_max_level(log::LevelFilter::max()); + process_env(); + Ok(()) +} + +pub fn init_test() { + if get_env_config().is_some() { + if try_init().is_ok() { + init_output_stdout(); + } + } +} + +fn get_env_config() -> Option { + std::env::var("ZED_LOG") + .or_else(|_| std::env::var("RUST_LOG")) + .ok() } pub fn process_env() { - let Ok(env_config) = std::env::var("ZED_LOG").or_else(|_| std::env::var("RUST_LOG")) else { + let Some(env_config) = get_env_config() else { return; }; match env_config::parse(&env_config) {