diff --git a/Cargo.lock b/Cargo.lock index 490f25d396..a786b25c08 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 92433d905f..f703a753f5 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 667bc4f864..45465f8bb1 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 e903cb5358..a7b388a753 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 44c87c75b4..a5b350b518 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 cd7bd9270a..0d2a0be1fb 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 7aba0e1051..9b3ee0c2d2 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 cdc99f62f7..3d6c2a24e9 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 ad01af6f56..25ca57c3e1 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 52473da4bd..17119a9a95 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 9f42f8c69e..95a2e80ac4 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 20429c7038..196de765f3 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 10b362b095..f6e5c9218a 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 bfa0e15067..c859d912b4 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 4d1187497e..60bf15eb5f 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 67f2e4e4ec..01516353a9 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 d14439057d..fee54abf9a 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 ec2843531b..e306b7d76c 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 ccb74a1bb4..22ba0e0806 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 1b1e880498..53b5792e10 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 f22104ae53..22776d525f 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 ccaeee9dd6..718b7f0a00 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 da2011a0c6..f84db2990e 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 68cbd6a4a3..c933d253c6 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 c7332b3893..fdd6bf2332 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 bb31c7a2ce..3298a8c6bf 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 37d12562c6..71bfef2685 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 33f5a4e4fd..3447982d92 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 dad4c96478..43cc2283bc 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 dd81065ed5..5a10731bfd 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 8750480bb9..ef1b0c195b 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 86e8da4c3c..2ce50d37f4 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 33afbbd0c7..cb07b46215 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 a5f15790e9..ad2b653fdc 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 715049c59d..bc1f8b341b 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 cd810fb9a7..626a238604 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 ae6e4d266f..d5a38f5398 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 ffee4ed5f1..864b819a4c 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 0314a91721..552cbae975 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 3c05e93ab7..89a898d950 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 363a7b7d7d..f7aa263e40 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 a290c521d5..79f134b91a 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 37d0868770..5ba121ec08 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 8ec561f48e..c779f4e0d7 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 c0ec39c067..207f93cd32 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 9c4cfc6743..def14d12f5 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 d9714a23ae..682b9aad92 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 efd89a0f72..b049498ccb 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 bf84e15d29..81764917a7 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 41ca60b252..80a104641f 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 84ca559718..c5fe14d9cf 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 1b90de7749..da27b8ad22 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 080b8b9c46..d3dcc488e1 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 630db0ce02..63542b0615 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 5b53bf7cbf..d5f8deadad 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 027268e7d7..d578c76f34 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 2ea9d6d817..e227a0e453 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 20731a059e..e6c7d81494 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 3338fc5c00..f2a14d64b4 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 22ec62a2be..e1bda7ad36 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 ecb5bb0c90..406f37419d 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 e9cafdf136..db264fe3aa 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 c3f56af4c6..d4c309e5bc 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 8d3da636df..1609773339 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 f84ed5eb2f..7b2c49c512 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 7ccff6ff8c..d8b685e57f 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) {