Skip to content

Commit 7c99542

Browse files
committed
Auto merge of #6918 - ehuss:env_logger_var2, r=alexcrichton
Changed RUST_LOG usage to CARGO_LOG to avoid confusion. This is a repost of #6605 now that rust-lang/rust#60401 has been merged. This also includes a fix in `TargetInfo::new` to remove the **RUSTC_LOG** var.
2 parents 345d570 + 782266a commit 7c99542

File tree

15 files changed

+30
-30
lines changed

15 files changed

+30
-30
lines changed

ARCHITECTURE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,16 @@ to nightly rustc).
132132
## Logging
133133

134134
Cargo uses [`env_logger`], so you can set
135-
`RUST_LOG` environment variable to get the logs. This is useful both for diagnosing
135+
`CARGO_LOG` environment variable to get the logs. This is useful both for diagnosing
136136
bugs in stable Cargo and for local development. Cargo also has internal hierarchical
137137
profiling infrastructure, which is activated via `CARGO_PROFILE` variable
138138

139139
```
140140
# Outputs all logs with levels debug and higher
141-
$ RUST_LOG=debug cargo generate-lockfile
141+
$ CARGO_LOG=debug cargo generate-lockfile
142142
143143
# Don't forget that you can filter by module as well
144-
$ RUST_LOG=cargo::core::resolver=trace cargo generate-lockfile
144+
$ CARGO_LOG=cargo::core::resolver=trace cargo generate-lockfile
145145
146146
# Output first three levels of profiling info
147147
$ CARGO_PROFILE=3 cargo generate-lockfile

src/bin/cargo/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use crate::command_prelude::*;
2020

2121
fn main() {
2222
#[cfg(feature = "pretty-env-logger")]
23-
pretty_env_logger::init();
23+
pretty_env_logger::init_custom_env("CARGO_LOG");
2424
#[cfg(not(feature = "pretty-env-logger"))]
25-
env_logger::init();
25+
env_logger::init_from_env("CARGO_LOG");
2626
cargo::core::maybe_allow_nightly_features();
2727

2828
let mut config = match Config::default() {

src/cargo/core/compiler/build_context/target_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl TargetInfo {
7575
.arg("___")
7676
.arg("--print=file-names")
7777
.args(&rustflags)
78-
.env_remove("RUST_LOG");
78+
.env_remove("RUSTC_LOG");
7979

8080
let target_triple = requested_target
8181
.as_ref()

src/cargo/core/compiler/fingerprint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
//! quick loading and comparison.
8080
//! - A `.json` file that contains details about the Fingerprint. This is only
8181
//! used to log details about *why* a fingerprint is considered dirty.
82-
//! `RUST_LOG=cargo::core::compiler::fingerprint=trace cargo build` can be
82+
//! `CARGO_LOG=cargo::core::compiler::fingerprint=trace cargo build` can be
8383
//! used to display this log information.
8484
//! - A "dep-info" file which contains a list of source filenames for the
8585
//! target. This is produced by reading the output of `rustc
@@ -936,7 +936,7 @@ impl DepFingerprint {
936936
impl StaleFile {
937937
/// Use the `log` crate to log a hopefully helpful message in diagnosing
938938
/// what file is considered stale and why. This is intended to be used in
939-
/// conjunction with `RUST_LOG` to determine why Cargo is recompiling
939+
/// conjunction with `CARGO_LOG` to determine why Cargo is recompiling
940940
/// something. Currently there's no user-facing usage of this other than
941941
/// that.
942942
fn log(&self) {

src/doc/src/reference/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ multiplexing = true # whether or not to use HTTP/2 multiplexing where possible
113113
# This setting can be used to help debug what's going on with HTTP requests made
114114
# by Cargo. When set to `true` then Cargo's normal debug logging will be filled
115115
# in with HTTP information, which you can extract with
116-
# `RUST_LOG=cargo::ops::registry=debug` (and `trace` may print more).
116+
# `CARGO_LOG=cargo::ops::registry=debug` (and `trace` may print more).
117117
#
118118
# Be wary when posting these logs elsewhere though, it may be the case that a
119119
# header has an authentication token in it you don't want leaked! Be sure to

tests/testsuite/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ fn simple_staticlib() {
20282028
.build();
20292029

20302030
// env var is a test for #1381
2031-
p.cargo("build").env("RUST_LOG", "nekoneko=trace").run();
2031+
p.cargo("build").env("CARGO_LOG", "nekoneko=trace").run();
20322032
}
20332033

20342034
#[test]

tests/testsuite/build_script.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,13 +1547,13 @@ fn build_script_with_dynamic_native_dependency() {
15471547

15481548
build
15491549
.cargo("build -v")
1550-
.env("RUST_LOG", "cargo::ops::cargo_rustc")
1550+
.env("CARGO_LOG", "cargo::ops::cargo_rustc")
15511551
.run();
15521552

15531553
let root = build.root().join("target").join("debug");
15541554
foo.cargo("build -v")
15551555
.env("BUILDER_ROOT", root)
1556-
.env("RUST_LOG", "cargo::ops::cargo_rustc")
1556+
.env("CARGO_LOG", "cargo::ops::cargo_rustc")
15571557
.run();
15581558
}
15591559

@@ -2460,7 +2460,7 @@ fn fresh_builds_possible_with_multiple_metadata_overrides() {
24602460
.run();
24612461

24622462
p.cargo("build -v")
2463-
.env("RUST_LOG", "cargo::ops::cargo_rustc::fingerprint=info")
2463+
.env("CARGO_LOG", "cargo::ops::cargo_rustc::fingerprint=info")
24642464
.with_stderr(
24652465
"\
24662466
[FRESH] foo v0.5.0 ([..])

tests/testsuite/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ fn proc_macro() {
730730
"#,
731731
)
732732
.build();
733-
p.cargo("check -v").env("RUST_LOG", "cargo=trace").run();
733+
p.cargo("check -v").env("CARGO_LOG", "cargo=trace").run();
734734
}
735735

736736
#[test]

tests/testsuite/corrupt_git.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn deleting_database_files() {
4747
}
4848
println!("deleting {}", file.display());
4949
cargopaths::remove_file(&file).unwrap();
50-
project.cargo("build -v").env("RUST_LOG", log).run();
50+
project.cargo("build -v").env("CARGO_LOG", log).run();
5151

5252
if !file.exists() {
5353
continue;
@@ -60,7 +60,7 @@ fn deleting_database_files() {
6060
.unwrap()
6161
.set_len(2)
6262
.unwrap();
63-
project.cargo("build -v").env("RUST_LOG", log).run();
63+
project.cargo("build -v").env("CARGO_LOG", log).run();
6464
}
6565
}
6666

@@ -124,7 +124,7 @@ fn deleting_checkout_files() {
124124
}
125125
println!("deleting {}", file.display());
126126
cargopaths::remove_file(&file).unwrap();
127-
project.cargo("build -v").env("RUST_LOG", log).run();
127+
project.cargo("build -v").env("CARGO_LOG", log).run();
128128

129129
if !file.exists() {
130130
continue;
@@ -137,7 +137,7 @@ fn deleting_checkout_files() {
137137
.unwrap()
138138
.set_len(2)
139139
.unwrap();
140-
project.cargo("build -v").env("RUST_LOG", log).run();
140+
project.cargo("build -v").env("CARGO_LOG", log).run();
141141
}
142142
}
143143

tests/testsuite/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn doc_deps() {
115115
assert_eq!(p.glob("target/debug/deps/libbar-*.rmeta").count(), 1);
116116

117117
p.cargo("doc")
118-
.env("RUST_LOG", "cargo::ops::cargo_rustc::fingerprint")
118+
.env("CARGO_LOG", "cargo::ops::cargo_rustc::fingerprint")
119119
.with_stdout("")
120120
.run();
121121

tests/testsuite/freshness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ fn rebuild_if_build_artifacts_move_forward_in_time() {
760760
p.root().move_into_the_future();
761761

762762
p.cargo("build")
763-
.env("RUST_LOG", "")
763+
.env("CARGO_LOG", "")
764764
.with_stdout("")
765765
.with_stderr(
766766
"\

tests/testsuite/rustc_info_cache.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ fn rustc_info_cache() {
1313
let update = "[..]updated rustc info cache[..]";
1414

1515
p.cargo("build")
16-
.env("RUST_LOG", "cargo::util::rustc=info")
16+
.env("CARGO_LOG", "cargo::util::rustc=info")
1717
.with_stderr_contains("[..]failed to read rustc info cache[..]")
1818
.with_stderr_contains(miss)
1919
.with_stderr_does_not_contain(hit)
2020
.with_stderr_contains(update)
2121
.run();
2222

2323
p.cargo("build")
24-
.env("RUST_LOG", "cargo::util::rustc=info")
24+
.env("CARGO_LOG", "cargo::util::rustc=info")
2525
.with_stderr_contains("[..]reusing existing rustc info cache[..]")
2626
.with_stderr_contains(hit)
2727
.with_stderr_does_not_contain(miss)
2828
.with_stderr_does_not_contain(update)
2929
.run();
3030

3131
p.cargo("build")
32-
.env("RUST_LOG", "cargo::util::rustc=info")
32+
.env("CARGO_LOG", "cargo::util::rustc=info")
3333
.env("CARGO_CACHE_RUSTC_INFO", "0")
3434
.with_stderr_contains("[..]rustc info cache disabled[..]")
3535
.with_stderr_does_not_contain(update)
@@ -63,7 +63,7 @@ fn rustc_info_cache() {
6363
};
6464

6565
p.cargo("build")
66-
.env("RUST_LOG", "cargo::util::rustc=info")
66+
.env("CARGO_LOG", "cargo::util::rustc=info")
6767
.env("RUSTC", other_rustc.display().to_string())
6868
.with_stderr_contains("[..]different compiler, creating new rustc info cache[..]")
6969
.with_stderr_contains(miss)
@@ -72,7 +72,7 @@ fn rustc_info_cache() {
7272
.run();
7373

7474
p.cargo("build")
75-
.env("RUST_LOG", "cargo::util::rustc=info")
75+
.env("CARGO_LOG", "cargo::util::rustc=info")
7676
.env("RUSTC", other_rustc.display().to_string())
7777
.with_stderr_contains("[..]reusing existing rustc info cache[..]")
7878
.with_stderr_contains(hit)
@@ -83,7 +83,7 @@ fn rustc_info_cache() {
8383
other_rustc.move_into_the_future();
8484

8585
p.cargo("build")
86-
.env("RUST_LOG", "cargo::util::rustc=info")
86+
.env("CARGO_LOG", "cargo::util::rustc=info")
8787
.env("RUSTC", other_rustc.display().to_string())
8888
.with_stderr_contains("[..]different compiler, creating new rustc info cache[..]")
8989
.with_stderr_contains(miss)
@@ -92,7 +92,7 @@ fn rustc_info_cache() {
9292
.run();
9393

9494
p.cargo("build")
95-
.env("RUST_LOG", "cargo::util::rustc=info")
95+
.env("CARGO_LOG", "cargo::util::rustc=info")
9696
.env("RUSTC", other_rustc.display().to_string())
9797
.with_stderr_contains("[..]reusing existing rustc info cache[..]")
9898
.with_stderr_contains(hit)

tests/testsuite/small_fd_limits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn run_test(path_env: Option<&OsStr>) {
7373
if let Some(path) = path_env {
7474
cmd.env("PATH", path);
7575
}
76-
cmd.env("RUST_LOG", "trace");
76+
cmd.env("CARGO_LOG", "trace");
7777
cmd.run();
7878
let after = find_index()
7979
.join(".git/objects/pack")

tests/testsuite/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3578,7 +3578,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
35783578
35793579
",
35803580
)
3581-
.env("RUST_LOG", "cargo=trace")
3581+
.env("CARGO_LOG", "cargo=trace")
35823582
.run();
35833583

35843584
p.cargo("test --lib --doc")

tests/testsuite/update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ fn update_via_new_dep() {
205205
Package::new("log", "0.1.1").publish();
206206

207207
p.uncomment_root_manifest();
208-
p.cargo("build").env("RUST_LOG", "cargo=trace").run();
208+
p.cargo("build").env("CARGO_LOG", "cargo=trace").run();
209209
}
210210

211211
#[test]

0 commit comments

Comments
 (0)