Skip to content

Commit

Permalink
Auto merge of #6918 - ehuss:env_logger_var2, r=alexcrichton
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed May 8, 2019
2 parents 345d570 + 782266a commit 7c99542
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ to nightly rustc).
## Logging

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

```
# Outputs all logs with levels debug and higher
$ RUST_LOG=debug cargo generate-lockfile
$ CARGO_LOG=debug cargo generate-lockfile
# Don't forget that you can filter by module as well
$ RUST_LOG=cargo::core::resolver=trace cargo generate-lockfile
$ CARGO_LOG=cargo::core::resolver=trace cargo generate-lockfile
# Output first three levels of profiling info
$ CARGO_PROFILE=3 cargo generate-lockfile
Expand Down
4 changes: 2 additions & 2 deletions src/bin/cargo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use crate::command_prelude::*;

fn main() {
#[cfg(feature = "pretty-env-logger")]
pretty_env_logger::init();
pretty_env_logger::init_custom_env("CARGO_LOG");
#[cfg(not(feature = "pretty-env-logger"))]
env_logger::init();
env_logger::init_from_env("CARGO_LOG");
cargo::core::maybe_allow_nightly_features();

let mut config = match Config::default() {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl TargetInfo {
.arg("___")
.arg("--print=file-names")
.args(&rustflags)
.env_remove("RUST_LOG");
.env_remove("RUSTC_LOG");

let target_triple = requested_target
.as_ref()
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
//! quick loading and comparison.
//! - A `.json` file that contains details about the Fingerprint. This is only
//! used to log details about *why* a fingerprint is considered dirty.
//! `RUST_LOG=cargo::core::compiler::fingerprint=trace cargo build` can be
//! `CARGO_LOG=cargo::core::compiler::fingerprint=trace cargo build` can be
//! used to display this log information.
//! - A "dep-info" file which contains a list of source filenames for the
//! target. This is produced by reading the output of `rustc
Expand Down Expand Up @@ -936,7 +936,7 @@ impl DepFingerprint {
impl StaleFile {
/// Use the `log` crate to log a hopefully helpful message in diagnosing
/// what file is considered stale and why. This is intended to be used in
/// conjunction with `RUST_LOG` to determine why Cargo is recompiling
/// conjunction with `CARGO_LOG` to determine why Cargo is recompiling
/// something. Currently there's no user-facing usage of this other than
/// that.
fn log(&self) {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/src/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ multiplexing = true # whether or not to use HTTP/2 multiplexing where possible
# This setting can be used to help debug what's going on with HTTP requests made
# by Cargo. When set to `true` then Cargo's normal debug logging will be filled
# in with HTTP information, which you can extract with
# `RUST_LOG=cargo::ops::registry=debug` (and `trace` may print more).
# `CARGO_LOG=cargo::ops::registry=debug` (and `trace` may print more).
#
# Be wary when posting these logs elsewhere though, it may be the case that a
# header has an authentication token in it you don't want leaked! Be sure to
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ fn simple_staticlib() {
.build();

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

#[test]
Expand Down
6 changes: 3 additions & 3 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,13 +1547,13 @@ fn build_script_with_dynamic_native_dependency() {

build
.cargo("build -v")
.env("RUST_LOG", "cargo::ops::cargo_rustc")
.env("CARGO_LOG", "cargo::ops::cargo_rustc")
.run();

let root = build.root().join("target").join("debug");
foo.cargo("build -v")
.env("BUILDER_ROOT", root)
.env("RUST_LOG", "cargo::ops::cargo_rustc")
.env("CARGO_LOG", "cargo::ops::cargo_rustc")
.run();
}

Expand Down Expand Up @@ -2460,7 +2460,7 @@ fn fresh_builds_possible_with_multiple_metadata_overrides() {
.run();

p.cargo("build -v")
.env("RUST_LOG", "cargo::ops::cargo_rustc::fingerprint=info")
.env("CARGO_LOG", "cargo::ops::cargo_rustc::fingerprint=info")
.with_stderr(
"\
[FRESH] foo v0.5.0 ([..])
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ fn proc_macro() {
"#,
)
.build();
p.cargo("check -v").env("RUST_LOG", "cargo=trace").run();
p.cargo("check -v").env("CARGO_LOG", "cargo=trace").run();
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions tests/testsuite/corrupt_git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn deleting_database_files() {
}
println!("deleting {}", file.display());
cargopaths::remove_file(&file).unwrap();
project.cargo("build -v").env("RUST_LOG", log).run();
project.cargo("build -v").env("CARGO_LOG", log).run();

if !file.exists() {
continue;
Expand All @@ -60,7 +60,7 @@ fn deleting_database_files() {
.unwrap()
.set_len(2)
.unwrap();
project.cargo("build -v").env("RUST_LOG", log).run();
project.cargo("build -v").env("CARGO_LOG", log).run();
}
}

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

if !file.exists() {
continue;
Expand All @@ -137,7 +137,7 @@ fn deleting_checkout_files() {
.unwrap()
.set_len(2)
.unwrap();
project.cargo("build -v").env("RUST_LOG", log).run();
project.cargo("build -v").env("CARGO_LOG", log).run();
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn doc_deps() {
assert_eq!(p.glob("target/debug/deps/libbar-*.rmeta").count(), 1);

p.cargo("doc")
.env("RUST_LOG", "cargo::ops::cargo_rustc::fingerprint")
.env("CARGO_LOG", "cargo::ops::cargo_rustc::fingerprint")
.with_stdout("")
.run();

Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ fn rebuild_if_build_artifacts_move_forward_in_time() {
p.root().move_into_the_future();

p.cargo("build")
.env("RUST_LOG", "")
.env("CARGO_LOG", "")
.with_stdout("")
.with_stderr(
"\
Expand Down
14 changes: 7 additions & 7 deletions tests/testsuite/rustc_info_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ fn rustc_info_cache() {
let update = "[..]updated rustc info cache[..]";

p.cargo("build")
.env("RUST_LOG", "cargo::util::rustc=info")
.env("CARGO_LOG", "cargo::util::rustc=info")
.with_stderr_contains("[..]failed to read rustc info cache[..]")
.with_stderr_contains(miss)
.with_stderr_does_not_contain(hit)
.with_stderr_contains(update)
.run();

p.cargo("build")
.env("RUST_LOG", "cargo::util::rustc=info")
.env("CARGO_LOG", "cargo::util::rustc=info")
.with_stderr_contains("[..]reusing existing rustc info cache[..]")
.with_stderr_contains(hit)
.with_stderr_does_not_contain(miss)
.with_stderr_does_not_contain(update)
.run();

p.cargo("build")
.env("RUST_LOG", "cargo::util::rustc=info")
.env("CARGO_LOG", "cargo::util::rustc=info")
.env("CARGO_CACHE_RUSTC_INFO", "0")
.with_stderr_contains("[..]rustc info cache disabled[..]")
.with_stderr_does_not_contain(update)
Expand Down Expand Up @@ -63,7 +63,7 @@ fn rustc_info_cache() {
};

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

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

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

p.cargo("build")
.env("RUST_LOG", "cargo::util::rustc=info")
.env("CARGO_LOG", "cargo::util::rustc=info")
.env("RUSTC", other_rustc.display().to_string())
.with_stderr_contains("[..]reusing existing rustc info cache[..]")
.with_stderr_contains(hit)
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/small_fd_limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn run_test(path_env: Option<&OsStr>) {
if let Some(path) = path_env {
cmd.env("PATH", path);
}
cmd.env("RUST_LOG", "trace");
cmd.env("CARGO_LOG", "trace");
cmd.run();
let after = find_index()
.join(".git/objects/pack")
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3578,7 +3578,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
",
)
.env("RUST_LOG", "cargo=trace")
.env("CARGO_LOG", "cargo=trace")
.run();

p.cargo("test --lib --doc")
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ fn update_via_new_dep() {
Package::new("log", "0.1.1").publish();

p.uncomment_root_manifest();
p.cargo("build").env("RUST_LOG", "cargo=trace").run();
p.cargo("build").env("CARGO_LOG", "cargo=trace").run();
}

#[test]
Expand Down

0 comments on commit 7c99542

Please sign in to comment.