Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8eef452

Browse files
committed
Auto merge of rust-lang#15089 - Veykril:slow-test-logs, r=Veykril
fix: Use RA_LOG in slow tests logging infra again
2 parents 0fe5266 + 8d33b39 commit 8eef452

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

crates/rust-analyzer/tests/slow-tests/support.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rust_analyzer::{config::Config, lsp_ext, main_loop};
1313
use serde::Serialize;
1414
use serde_json::{json, to_string_pretty, Value};
1515
use test_utils::FixtureWithProjectMeta;
16+
use tracing_subscriber::{prelude::*, Layer};
1617
use vfs::AbsPathBuf;
1718

1819
use crate::testdir::TestDir;
@@ -76,13 +77,11 @@ impl<'a> Project<'a> {
7677
let tmp_dir = self.tmp_dir.unwrap_or_else(TestDir::new);
7778
static INIT: Once = Once::new();
7879
INIT.call_once(|| {
79-
tracing_subscriber::fmt()
80-
.with_test_writer()
81-
// FIXME: I am not smart enough to figure out how to use this with
82-
// `tracing_subscriber::filter::Targets`.
83-
//
84-
// .with_env_filter(tracing_subscriber::EnvFilter::from_env("RA_LOG"))
85-
.init();
80+
let filter: tracing_subscriber::filter::Targets =
81+
std::env::var("RA_LOG").ok().and_then(|it| it.parse().ok()).unwrap_or_default();
82+
let layer =
83+
tracing_subscriber::fmt::Layer::new().with_test_writer().with_filter(filter);
84+
tracing_subscriber::Registry::default().with(layer).init();
8685
profile::init_from(crate::PROFILE);
8786
});
8887

0 commit comments

Comments
 (0)