Skip to content

Commit 811ff43

Browse files
grievejiafacebook-github-bot
authored andcommitted
Use anstream to auto-configure stderr in init_tracing
Summary: Now that we depend on `anstream` for color stripping, we no longer need the manual stripping logic implemented in `init_tracing()`. Reviewed By: rchen152 Differential Revision: D74350739 fbshipit-source-id: 047a79a4e7f194700fadfaf6cb0244b6f296b212
1 parent def0111 commit 811ff43

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

pyrefly/lib/commands/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn init_color(color: ColorChoice) {
5151

5252
impl CommonGlobalArgs {
5353
pub fn init(&self) {
54-
init_tracing(self.verbose, false, false);
54+
init_tracing(self.verbose, false);
5555
init_thread_pool(self.threads);
5656
init_color(self.color);
5757
}

pyrefly/lib/test/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ pub fn get_batched_lsp_operations_report_no_cursor(
384384
}
385385

386386
pub fn init_test() {
387-
init_tracing(true, true, true);
387+
init_tracing(true, true);
388388
// Enough threads to see parallelism bugs, but not too many to debug through.
389389
init_thread_pool(ThreadCount::NumThreads(NonZeroUsize::new(3).unwrap()));
390390
}

pyrefly/lib/util/trace.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77

88
//! Utilities for working with the `tracing` crate.
99
10-
use std::io::IsTerminal;
11-
use std::io::stderr;
1210
use std::sync::Once;
1311

12+
use anstream::stderr;
1413
use tracing_subscriber::Layer;
1514
use tracing_subscriber::filter::EnvFilter;
1615
use tracing_subscriber::filter::LevelFilter;
@@ -23,7 +22,7 @@ static INIT_TRACING_ONCE: Once = Once::new();
2322

2423
/// Set up tracing so it prints to stderr, and can be used for output.
2524
/// Most things should use `info` and `debug` level for showing messages.
26-
pub fn init_tracing(verbose: bool, force_ansi: bool, testing: bool) {
25+
pub fn init_tracing(verbose: bool, testing: bool) {
2726
INIT_TRACING_ONCE.call_once(|| {
2827
const ENV_VAR: &str = "PYREFLY_LOG";
2928
let mut env_filter = EnvFilter::from_env(ENV_VAR);
@@ -41,7 +40,6 @@ pub fn init_tracing(verbose: bool, force_ansi: bool, testing: bool) {
4140
.with_file(false)
4241
.without_time()
4342
.with_writer(stderr)
44-
.with_ansi(force_ansi || stderr().is_terminal())
4543
.with_target(false);
4644

4745
if testing {

0 commit comments

Comments
 (0)