Skip to content

Commit 7e69050

Browse files
committed
refactor: setup tracing-subscriber
1 parent 23561f3 commit 7e69050

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

crates/xtask-bump-check/src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ mod xtask;
22

33
fn main() {
44
env_logger::init_from_env("CARGO_LOG");
5+
setup_logger();
6+
57
let cli = xtask::cli();
68
let matches = cli.get_matches();
79

@@ -13,3 +15,13 @@ fn main() {
1315
cargo::exit_with_error(e, &mut config.shell())
1416
}
1517
}
18+
19+
// In sync with `src/bin/cargo/main.rs@setup_logger`.
20+
fn setup_logger() {
21+
let env = tracing_subscriber::EnvFilter::from_env("CARGO_LOG");
22+
23+
tracing_subscriber::fmt()
24+
.with_writer(std::io::stderr)
25+
.with_env_filter(env)
26+
.init();
27+
}

src/bin/cargo/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ fn main() {
2525
#[cfg(not(feature = "pretty-env-logger"))]
2626
env_logger::init_from_env("CARGO_LOG");
2727

28+
setup_logger();
29+
2830
let mut config = cli::LazyConfig::new();
2931

3032
let result = if let Some(lock_addr) = cargo::ops::fix_get_proxy_lock_addr() {
@@ -40,6 +42,15 @@ fn main() {
4042
}
4143
}
4244

45+
fn setup_logger() {
46+
let env = tracing_subscriber::EnvFilter::from_env("CARGO_LOG");
47+
48+
tracing_subscriber::fmt()
49+
.with_writer(std::io::stderr)
50+
.with_env_filter(env)
51+
.init();
52+
}
53+
4354
/// Table for defining the aliases which come builtin in `Cargo`.
4455
/// The contents are structured as: `(alias, aliased_command, description)`.
4556
const BUILTIN_ALIASES: [(&str, &str, &str); 6] = [

0 commit comments

Comments
 (0)