Skip to content

Commit 05762e3

Browse files
committed
Auto merge of #74726 - oli-obk:tracing, r=Mark-Simulacrum
Move from `log` to `tracing` The only visible change is that we now get timestamps in our logs: ``` Jul 24 18:41:01.065 TRACE rustc_mir::transform::const_prop: skipping replace of Rvalue::Use(const () because it is already a const Jul 24 18:41:01.065 TRACE rustc_mir::transform::const_prop: propagated into _2 Jul 24 18:41:01.065 TRACE rustc_mir::transform::const_prop: visit_constant: const () ``` This PR was explicitly designed to be as low-impact as possible. We can now move to using the name `tracing` insteads of `log` on a crate-by-crate basis and use any of the other tracing features where desirable. As far as I can tell this will allow tools to seamlessly keep working (since they are using `rustc_driver::init_log...`). This is the first half of step 1 of the accepted `tracing` MCP (rust-lang/compiler-team#331)
2 parents de10abf + c729037 commit 05762e3

File tree

41 files changed

+161
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+161
-89
lines changed

Diff for: Cargo.lock

+98-45
Large diffs are not rendered by default.

Diff for: src/librustc_ast/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_serialize = { path = "../librustc_serialize" }
14-
log = "0.4"
14+
log = { package = "tracing", version = "0.1" }
1515
scoped-tls = "1.0"
1616
rustc_span = { path = "../librustc_span" }
1717
rustc_data_structures = { path = "../librustc_data_structures" }

Diff for: src/librustc_ast_lowering/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_arena = { path = "../librustc_arena" }
14-
log = { version = "0.4", features = ["release_max_level_info", "std"] }
14+
log = { package = "tracing", version = "0.1" }
1515
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
1616
rustc_hir = { path = "../librustc_hir" }
1717
rustc_target = { path = "../librustc_target" }

Diff for: src/librustc_ast_passes/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ path = "lib.rs"
1010

1111
[dependencies]
1212
itertools = "0.8"
13-
log = "0.4"
13+
log = { package = "tracing", version = "0.1" }
1414
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
1515
rustc_attr = { path = "../librustc_attr" }
1616
rustc_data_structures = { path = "../librustc_data_structures" }

Diff for: src/librustc_ast_pretty/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ path = "lib.rs"
1010
doctest = false
1111

1212
[dependencies]
13-
log = "0.4"
13+
log = { package = "tracing", version = "0.1" }
1414
rustc_span = { path = "../librustc_span" }
1515
rustc_ast = { path = "../librustc_ast" }
1616
rustc_target = { path = "../librustc_target" }

Diff for: src/librustc_builtin_macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_parse_format = { path = "../librustc_parse_format" }
14-
log = "0.4"
14+
log = { package = "tracing", version = "0.1" }
1515
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
1616
rustc_attr = { path = "../librustc_attr" }
1717
rustc_data_structures = { path = "../librustc_data_structures" }

Diff for: src/librustc_codegen_llvm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bitflags = "1.0"
1515
flate2 = "1.0"
1616
libc = "0.2"
1717
measureme = "0.7.1"
18-
log = "0.4"
18+
log = { package = "tracing", version = "0.1" }
1919
rustc_middle = { path = "../librustc_middle" }
2020
rustc-demangle = "0.1"
2121
rustc_attr = { path = "../librustc_attr" }

Diff for: src/librustc_codegen_ssa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bitflags = "1.2.1"
1414
cc = "1.0.1"
1515
num_cpus = "1.0"
1616
memmap = "0.7"
17-
log = "0.4.5"
17+
log = { package = "tracing", version = "0.1" }
1818
libc = "0.2.50"
1919
jobserver = "0.1.11"
2020
tempfile = "3.1"

Diff for: src/librustc_data_structures/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212
[dependencies]
1313
ena = "0.14"
1414
indexmap = "1"
15-
log = "0.4"
15+
log = { package = "tracing", version = "0.1" }
1616
jobserver_crate = { version = "0.1.13", package = "jobserver" }
1717
lazy_static = "1"
1818
once_cell = { version = "1", features = ["parking_lot"] }

Diff for: src/librustc_driver/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ crate-type = ["dylib"]
1212
[dependencies]
1313
lazy_static = "1.0"
1414
libc = "0.2"
15-
log = "0.4"
16-
env_logger = { version = "0.7", default-features = false }
15+
log = { package = "tracing", version = "0.1.18", features = ["release_max_level_info"] }
16+
tracing-subscriber = { version = "0.2.10", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
1717
rustc_middle = { path = "../librustc_middle" }
1818
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
1919
rustc_target = { path = "../librustc_target" }

Diff for: src/librustc_driver/lib.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -1224,9 +1224,26 @@ pub fn install_ice_hook() {
12241224
}
12251225

12261226
/// This allows tools to enable rust logging without having to magically match rustc's
1227-
/// log crate version
1227+
/// log crate version.
12281228
pub fn init_rustc_env_logger() {
1229-
env_logger::init_from_env("RUSTC_LOG");
1229+
init_env_logger("RUSTC_LOG")
1230+
}
1231+
1232+
/// This allows tools to enable rust logging without having to magically match rustc's
1233+
/// log crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var
1234+
/// other than `RUSTC_LOG`.
1235+
pub fn init_env_logger(env: &str) {
1236+
// Don't register a dispatcher if there's no filter to print anything
1237+
match std::env::var(env) {
1238+
Err(_) => return,
1239+
Ok(s) if s.is_empty() => return,
1240+
Ok(_) => {}
1241+
}
1242+
let builder = tracing_subscriber::FmtSubscriber::builder();
1243+
1244+
let builder = builder.with_env_filter(tracing_subscriber::EnvFilter::from_env(env));
1245+
1246+
builder.init()
12301247
}
12311248

12321249
pub fn main() -> ! {

Diff for: src/librustc_errors/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ path = "lib.rs"
1010
doctest = false
1111

1212
[dependencies]
13-
log = "0.4"
13+
log = { package = "tracing", version = "0.1" }
1414
rustc_serialize = { path = "../librustc_serialize" }
1515
rustc_span = { path = "../librustc_span" }
1616
rustc_data_structures = { path = "../librustc_data_structures" }

Diff for: src/librustc_expand/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212

1313
[dependencies]
1414
rustc_serialize = { path = "../librustc_serialize" }
15-
log = "0.4"
15+
log = { package = "tracing", version = "0.1" }
1616
rustc_span = { path = "../librustc_span" }
1717
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
1818
rustc_ast_passes = { path = "../librustc_ast_passes" }

Diff for: src/librustc_hir/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ rustc_span = { path = "../librustc_span" }
1818
rustc_serialize = { path = "../librustc_serialize" }
1919
rustc_ast = { path = "../librustc_ast" }
2020
lazy_static = "1"
21-
log = { version = "0.4", features = ["release_max_level_info", "std"] }
21+
log = { package = "tracing", version = "0.1" }
2222
smallvec = { version = "1.0", features = ["union", "may_dangle"] }

Diff for: src/librustc_incremental/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_graphviz = { path = "../librustc_graphviz" }
14-
log = "0.4"
14+
log = { package = "tracing", version = "0.1" }
1515
rand = "0.7"
1616
rustc_middle = { path = "../librustc_middle" }
1717
rustc_data_structures = { path = "../librustc_data_structures" }

Diff for: src/librustc_infer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_graphviz = { path = "../librustc_graphviz" }
14-
log = { version = "0.4", features = ["release_max_level_info", "std"] }
14+
log = { package = "tracing", version = "0.1" }
1515
rustc_middle = { path = "../librustc_middle" }
1616
rustc_data_structures = { path = "../librustc_data_structures" }
1717
rustc_errors = { path = "../librustc_errors" }

Diff for: src/librustc_interface/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
libc = "0.2"
14-
log = "0.4"
14+
log = { package = "tracing", version = "0.1" }
1515
rayon = { version = "0.3.0", package = "rustc-rayon" }
1616
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
1717
rustc_ast = { path = "../librustc_ast" }

Diff for: src/librustc_lint/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rustc_lint"
99
path = "lib.rs"
1010

1111
[dependencies]
12-
log = "0.4"
12+
log = { package = "tracing", version = "0.1" }
1313
unicode-security = "0.0.5"
1414
rustc_middle = { path = "../librustc_middle" }
1515
rustc_ast_pretty = { path = "../librustc_ast_pretty" }

Diff for: src/librustc_metadata/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212
[dependencies]
1313
flate2 = "1.0"
1414
libc = "0.2"
15-
log = "0.4"
15+
log = { package = "tracing", version = "0.1" }
1616
memmap = "0.7"
1717
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
1818
rustc_middle = { path = "../librustc_middle" }

Diff for: src/librustc_middle/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ doctest = false
1313
rustc_arena = { path = "../librustc_arena" }
1414
bitflags = "1.2.1"
1515
scoped-tls = "1.0"
16-
log = { version = "0.4", features = ["release_max_level_info", "std"] }
16+
log = { package = "tracing", version = "0.1" }
1717
rustc-rayon-core = "0.3.0"
1818
polonius-engine = "0.12.0"
1919
rustc_apfloat = { path = "../librustc_apfloat" }

Diff for: src/librustc_mir/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ doctest = false
1313
either = "1.5.0"
1414
rustc_graphviz = { path = "../librustc_graphviz" }
1515
itertools = "0.8"
16-
log = "0.4"
16+
log = { package = "tracing", version = "0.1" }
1717
log_settings = "0.1.1"
1818
polonius-engine = "0.12.0"
1919
rustc_middle = { path = "../librustc_middle" }

Diff for: src/librustc_mir/interpret/eval_context.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
822822
) -> InterpResult<'tcx> {
823823
// FIXME: should we tell the user that there was a local which was never written to?
824824
if let LocalValue::Live(Operand::Indirect(MemPlace { ptr, .. })) = local {
825-
trace!("deallocating local");
826825
// All locals have a backing allocation, even if the allocation is empty
827826
// due to the local having ZST type.
828827
let ptr = ptr.assert_ptr();
829-
trace!("{:?}", self.memory.dump_alloc(ptr.alloc_id));
828+
trace!("deallocating local: {:?}", self.memory.dump_alloc(ptr.alloc_id));
830829
self.memory.deallocate_local(ptr)?;
831830
};
832831
Ok(())

Diff for: src/librustc_mir_build/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_arena = { path = "../librustc_arena" }
14-
log = "0.4"
14+
log = { package = "tracing", version = "0.1" }
1515
rustc_middle = { path = "../librustc_middle" }
1616
rustc_apfloat = { path = "../librustc_apfloat" }
1717
rustc_attr = { path = "../librustc_attr" }

Diff for: src/librustc_parse/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
bitflags = "1.0"
14-
log = "0.4"
14+
log = { package = "tracing", version = "0.1" }
1515
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
1616
rustc_data_structures = { path = "../librustc_data_structures" }
1717
rustc_feature = { path = "../librustc_feature" }

Diff for: src/librustc_passes/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rustc_passes"
99
path = "lib.rs"
1010

1111
[dependencies]
12-
log = "0.4"
12+
log = { package = "tracing", version = "0.1" }
1313
rustc_middle = { path = "../librustc_middle" }
1414
rustc_attr = { path = "../librustc_attr" }
1515
rustc_data_structures = { path = "../librustc_data_structures" }

Diff for: src/librustc_privacy/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ rustc_typeck = { path = "../librustc_typeck" }
1717
rustc_session = { path = "../librustc_session" }
1818
rustc_span = { path = "../librustc_span" }
1919
rustc_data_structures = { path = "../librustc_data_structures" }
20-
log = "0.4"
20+
log = { package = "tracing", version = "0.1" }

Diff for: src/librustc_query_system/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_arena = { path = "../librustc_arena" }
14-
log = { version = "0.4", features = ["release_max_level_info", "std"] }
14+
log = { package = "tracing", version = "0.1" }
1515
rustc-rayon-core = "0.3.0"
1616
rustc_data_structures = { path = "../librustc_data_structures" }
1717
rustc_errors = { path = "../librustc_errors" }

Diff for: src/librustc_resolve/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212

1313
[dependencies]
1414
bitflags = "1.2.1"
15-
log = "0.4"
15+
log = { package = "tracing", version = "0.1" }
1616
rustc_ast = { path = "../librustc_ast" }
1717
rustc_arena = { path = "../librustc_arena" }
1818
rustc_middle = { path = "../librustc_middle" }

Diff for: src/librustc_save_analysis/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rustc_save_analysis"
99
path = "lib.rs"
1010

1111
[dependencies]
12-
log = "0.4"
12+
log = { package = "tracing", version = "0.1" }
1313
rustc_middle = { path = "../librustc_middle" }
1414
rustc_ast = { path = "../librustc_ast" }
1515
rustc_ast_pretty = { path = "../librustc_ast_pretty" }

Diff for: src/librustc_session/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ path = "lib.rs"
1111
[dependencies]
1212
bitflags = "1.2.1"
1313
getopts = "0.2"
14-
log = "0.4"
14+
log = { package = "tracing", version = "0.1" }
1515
rustc_errors = { path = "../librustc_errors" }
1616
rustc_feature = { path = "../librustc_feature" }
1717
rustc_target = { path = "../librustc_target" }

Diff for: src/librustc_span/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ rustc_arena = { path = "../librustc_arena" }
1818
scoped-tls = "1.0"
1919
unicode-width = "0.1.4"
2020
cfg-if = "0.1.2"
21-
log = "0.4"
21+
log = { package = "tracing", version = "0.1" }
2222
sha-1 = "0.8"
2323
md-5 = "0.8"

Diff for: src/librustc_symbol_mangling/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ path = "lib.rs"
1010
doctest = false
1111

1212
[dependencies]
13-
log = "0.4"
13+
log = { package = "tracing", version = "0.1" }
1414
punycode = "0.4.0"
1515
rustc-demangle = "0.1.16"
1616

Diff for: src/librustc_target/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ path = "lib.rs"
1010

1111
[dependencies]
1212
bitflags = "1.2.1"
13-
log = "0.4"
13+
log = { package = "tracing", version = "0.1" }
1414
rustc_data_structures = { path = "../librustc_data_structures" }
1515
rustc_macros = { path = "../librustc_macros" }
1616
rustc_serialize = { path = "../librustc_serialize" }

Diff for: src/librustc_trait_selection/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111

1212
[dependencies]
1313
rustc_parse_format = { path = "../librustc_parse_format" }
14-
log = { version = "0.4", features = ["release_max_level_info", "std"] }
14+
log = { package = "tracing", version = "0.1" }
1515
rustc_attr = { path = "../librustc_attr" }
1616
rustc_middle = { path = "../librustc_middle" }
1717
rustc_ast = { path = "../librustc_ast" }

Diff for: src/librustc_traits/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rustc_traits"
99
path = "lib.rs"
1010

1111
[dependencies]
12-
log = { version = "0.4" }
12+
log = { package = "tracing", version = "0.1" }
1313
rustc_middle = { path = "../librustc_middle" }
1414
rustc_data_structures = { path = "../librustc_data_structures" }
1515
rustc_hir = { path = "../librustc_hir" }

Diff for: src/librustc_ty/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rustc_ty"
99
path = "lib.rs"
1010

1111
[dependencies]
12-
log = "0.4"
12+
log = { package = "tracing", version = "0.1" }
1313
rustc_middle = { path = "../librustc_middle" }
1414
rustc_data_structures = { path = "../librustc_data_structures" }
1515
rustc_errors = { path = "../librustc_errors" }

Diff for: src/librustc_typeck/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212

1313
[dependencies]
1414
rustc_arena = { path = "../librustc_arena" }
15-
log = "0.4"
15+
log = { package = "tracing", version = "0.1" }
1616
rustc_middle = { path = "../librustc_middle" }
1717
rustc_attr = { path = "../librustc_attr" }
1818
rustc_data_structures = { path = "../librustc_data_structures" }

Diff for: src/librustdoc/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#![feature(never_type)]
1515
#![recursion_limit = "256"]
1616

17-
extern crate env_logger;
1817
#[macro_use]
1918
extern crate lazy_static;
2019
extern crate rustc_ast;
@@ -90,7 +89,8 @@ pub fn main() {
9089
};
9190
rustc_driver::set_sigpipe_handler();
9291
rustc_driver::install_ice_hook();
93-
env_logger::init_from_env("RUSTDOC_LOG");
92+
rustc_driver::init_env_logger("RUSTDOC_LOG");
93+
9494
let res = std::thread::Builder::new()
9595
.stack_size(thread_stack_size)
9696
.spawn(move || get_args().map(|args| main_args(&args)).unwrap_or(1))

Diff for: src/tools/compiletest/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2018"
88
diff = "0.1.10"
99
env_logger = { version = "0.7", default-features = false }
1010
getopts = "0.2"
11-
log = "0.4"
11+
log = { package = "tracing", version = "0.1" }
1212
regex = "1.0"
1313
serde = { version = "1.0", features = ["derive"] }
1414
serde_json = "1.0"

Diff for: src/tools/error_index_generator/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(rustc_private)]
22

3-
extern crate env_logger;
43
extern crate rustc_ast;
4+
extern crate rustc_driver;
55
extern crate rustc_span;
66

77
use std::cell::RefCell;
@@ -282,7 +282,7 @@ fn parse_args() -> (OutputFormat, PathBuf) {
282282
}
283283

284284
fn main() {
285-
env_logger::init();
285+
rustc_driver::init_env_logger("RUST_LOG");
286286
let (format, dst) = parse_args();
287287
let result = rustc_ast::with_default_session_globals(move || main_with_result(format, &dst));
288288
if let Err(e) = result {

Diff for: src/tools/tidy/src/deps.rs

+3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
166166
"termcolor",
167167
"termize",
168168
"thread_local",
169+
"tracing",
170+
"tracing-attributes",
171+
"tracing-core",
169172
"typenum",
170173
"unicode-normalization",
171174
"unicode-script",

0 commit comments

Comments
 (0)