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 ...
This commit is contained in:
Ben Kunkle 2025-05-26 10:48:50 -05:00 committed by GitHub
parent 0c27aaecb3
commit c0aa8f63fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 123 additions and 167 deletions

52
Cargo.lock generated
View file

@ -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]]

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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) {

View file

@ -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) {

View file

@ -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| {

View file

@ -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

View file

@ -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]

View file

@ -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"]

View file

@ -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);

View file

@ -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)]

View file

@ -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| {

View file

@ -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

View file

@ -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();
}

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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 {

View file

@ -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"

View file

@ -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]

View file

@ -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

View file

@ -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]

View file

@ -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

View file

@ -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);

View file

@ -1347,7 +1347,7 @@ mod tests {
#[ctor::ctor]
fn init_logger() {
env_logger::init();
zlog::init_test();
}
fn init_test(cx: &mut TestAppContext) {

View file

@ -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

View file

@ -39,9 +39,7 @@ pub static TRAILING_WHITESPACE_REGEX: LazyLock<regex::Regex> = 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]

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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]

View file

@ -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

View file

@ -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]

View file

@ -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"] }

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);
}

View file

@ -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

View file

@ -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<SshRemoteClient>, cx: &mut TestAppContext) -> Entity<Project> {

View file

@ -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"

View file

@ -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]

View file

@ -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

View file

@ -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)]

View file

@ -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

View file

@ -12,7 +12,7 @@ use std::{
};
fn main() {
env_logger::init();
zlog::init();
use clock::FakeSystemClock;

View file

@ -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);

View file

@ -20,5 +20,5 @@ workspace-hack.workspace = true
[dev-dependencies]
ctor.workspace = true
env_logger.workspace = true
rand.workspace = true
zlog.workspace = true

View file

@ -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]

View file

@ -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

View file

@ -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]

View file

@ -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

View file

@ -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]

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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();
}
}

View file

@ -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<String> {
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) {