Skip to content

Commit 326af2b

Browse files
fee1-deadcalebcartwright
authored andcommitted
Switch to tracing for logging
1 parent 9a86da9 commit 326af2b

File tree

6 files changed

+147
-43
lines changed

6 files changed

+147
-43
lines changed

Cargo.lock

+129-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ cargo_metadata = "0.15.4"
4040
clap = { version = "4.2.1", features = ["derive"] }
4141
diff = "0.1"
4242
dirs = "4.0"
43-
env_logger = "0.10.0"
4443
getopts = "0.2"
4544
ignore = "0.4"
4645
itertools = "0.10"
4746
lazy_static = "1.4"
48-
log = "0.4"
49-
regex = "1.5"
47+
regex = "1.7"
5048
serde = { version = "1.0.160", features = ["derive"] }
5149
serde_json = "1.0"
5250
term = "0.7"
5351
thiserror = "1.0.40"
5452
toml = "0.7.4"
53+
tracing = "0.1.37"
54+
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
5555
unicode-segmentation = "1.9"
5656
unicode-width = "0.1"
5757
unicode_categories = "0.1"

src/bin/main.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use io::Error as IoError;
66
use thiserror::Error;
77

88
use rustfmt_nightly as rustfmt;
9+
use tracing_subscriber::EnvFilter;
910

1011
use std::collections::HashMap;
1112
use std::env;
@@ -29,7 +30,9 @@ extern crate rustc_driver;
2930
fn main() {
3031
rustc_driver::install_ice_hook(BUG_REPORT_URL, |_| ());
3132

32-
env_logger::Builder::from_env("RUSTFMT_LOG").init();
33+
tracing_subscriber::fmt()
34+
.with_env_filter(EnvFilter::from_env("RUSTFMT_LOG"))
35+
.init();
3336
let opts = make_opts();
3437

3538
let exit_code = match execute(&opts) {

src/format-diff/main.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
#![deny(warnings)]
66

77
#[macro_use]
8-
extern crate log;
8+
extern crate tracing;
99

1010
use serde::{Deserialize, Serialize};
1111
use serde_json as json;
1212
use thiserror::Error;
13+
use tracing_subscriber::EnvFilter;
1314

1415
use std::collections::HashSet;
1516
use std::env;
@@ -63,7 +64,9 @@ pub struct Opts {
6364
}
6465

6566
fn main() {
66-
env_logger::Builder::from_env("RUSTFMT_LOG").init();
67+
tracing_subscriber::fmt()
68+
.with_env_filter(EnvFilter::from_env("RUSTFMT_LOG"))
69+
.init();
6770
let opts = Opts::parse();
6871
if let Err(e) = run(opts) {
6972
println!("{}", e);

src/git-rustfmt/main.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[macro_use]
2-
extern crate log;
2+
extern crate tracing;
33

44
use std::env;
55
use std::io::stdout;
@@ -9,6 +9,7 @@ use std::str::FromStr;
99

1010
use getopts::{Matches, Options};
1111
use rustfmt_nightly as rustfmt;
12+
use tracing_subscriber::EnvFilter;
1213

1314
use crate::rustfmt::{load_config, CliOptions, FormatReportFormatterBuilder, Input, Session};
1415

@@ -170,7 +171,9 @@ impl Config {
170171
}
171172

172173
fn main() {
173-
env_logger::Builder::from_env("RUSTFMT_LOG").init();
174+
tracing_subscriber::fmt()
175+
.with_env_filter(EnvFilter::from_env("RUSTFMT_LOG"))
176+
.init();
174177

175178
let opts = make_opts();
176179
let matches = opts

src/test/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const FILE_SKIP_LIST: &[&str] = &[
4747
];
4848

4949
fn init_log() {
50-
let _ = env_logger::builder().is_test(true).try_init();
50+
let _ = tracing_subscriber::fmt().with_test_writer().try_init();
5151
}
5252

5353
struct TestSetting {

0 commit comments

Comments
 (0)