Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustc should use a variable other than RUST_LOG for env_logger. #57985

Closed
zachlute opened this issue Jan 30, 2019 · 11 comments
Closed

Rustc should use a variable other than RUST_LOG for env_logger. #57985

zachlute opened this issue Jan 30, 2019 · 11 comments
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler C-enhancement Category: An issue proposing an enhancement or a PR with one. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@zachlute
Copy link
Contributor

This is related to Cargo Issue #6189.

In short, users generally don't expect tools to dump their debug output using the same mechanism their library or application uses to dump its debug output. As a user, when I do:

RUST_LOG=debug cargo run

I very much do not expect to be inundated with parse trees and such from cargo and rustc. This isn't a fabricated issue--I watched this confusion happen to numerous people in independent settings. While this can be mitigated by filtering your RUST_LOG by module, there's no obvious way to say "I want everything from my application and its dependencies, but nothing from the tooling."

I initially proposed fixing this for cargo by using a CARGO_LOG environment variable in Cargo PR #6605, but @alexcrichton rightly pointed out that that's only a partial solution to the problem and that to really get the behavior I want, we'd need to make a similar change at least to rustc, potentially sharing a new variable. (RUST_INTERNAL_LOG? Lots of bikeshedding possibilities here.)

To start determining if this is even feasible, I need to answer a few questions:

  1. Is the RUST_LOG environment variable considered part of the stable interface for rustc? Is changing this even a possibility, putting aside whether it's desired?
  2. If this is possible, is there a strong reason NOT to do this (other than inertia) that I'm not considering?

Thank you in advance for any consideration and input.

@jonas-schievink jonas-schievink added A-driver Area: rustc_driver that ties everything together into the `rustc` compiler C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 30, 2019
@pnkfelix
Copy link
Member

Does cargo build && RUST_LOG=debug cargo run not suffice here?

@zachlute
Copy link
Contributor Author

Does cargo build && RUST_LOG=debug cargo run not suffice here?

Yes and no. It solves part of the problem in that it would remove the rustc output if you remembered or even knew to do that. It obviously doesn't help with all of the cargo output, but my cargo PR would take care of that in either case.

At the end of the day, this issue is mostly about expectations. As mentioned, there are hoops you can already jump through to mitigate this somewhat by specifying module restrictions. There's just an unfortunate conflation of application interface and tooling interface here that leads to surprising results, so that's what I was hoping to mitigate if possible.

@pnkfelix
Copy link
Member

pnkfelix commented Feb 1, 2019

nominating for discussion at future T-compiler meeting (probably post all-hands, i.e. not for another two weeks).

@oli-obk
Copy link
Contributor

oli-obk commented Feb 1, 2019

I think we could rename it to RUSTC_LOG (similarly to how other internal compiler env vars are named)

@zachlute
Copy link
Contributor Author

zachlute commented Feb 1, 2019

Yeah, that makes sense to me. It probably makes sense for cargo to use CARGO_LOG and rustc to use RUSTC_LOG.

@pnkfelix
Copy link
Member

triage: P-medium, E-needs-mentor. Leaving nomination tag to try to ensure we discuss at T-compiler meeting in near future.

@pnkfelix pnkfelix added the P-medium Medium priority label Feb 28, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Mar 7, 2019

discussed at T-compiler meeting. no one present objected to the idea of each tool using its own specialized MYTOOL_LOG environment variable.

so we (informally at least) approve of this change and invite someone to post a PR for it. we do not believe this requires an RFC.

@zachlute
Copy link
Contributor Author

zachlute commented Mar 7, 2019

Awesome, I'll look into doing a PR for this shortly, then. Thanks!

@pnkfelix
Copy link
Member

(oh I should have removed nominated tag from this)

@davidtwco
Copy link
Member

For anyone who's interested in doing this issue, you'd just need to change this line:

env_logger::init();

to instead call init_from_env("RUSTC_LOG"). After that, I'd run all the tests and check that there's no other code that expects the variable to be RUST_LOG and do a grep to find any documentation that needs updated, also the rustc guide would need updated.

@davidtwco davidtwco added E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. and removed E-needs-mentor labels Apr 21, 2019
Centril added a commit to Centril/rust that referenced this issue May 2, 2019
Rename `RUST_LOG` to `RUSTC_LOG`

cc: rust-lang#57985

I think we should also change these submodules:

- rustc-guide
- Cargo (rename to `CARGO_LOG`, cc: rust-lang/cargo#6605)
- miri
- rls
- rustfmt

r? @davidtwco
Centril added a commit to Centril/rust that referenced this issue May 3, 2019
Rename `RUST_LOG` to `RUSTC_LOG`

cc: rust-lang#57985

I think we should also change these submodules:

- rustc-guide
- Cargo (rename to `CARGO_LOG`, cc: rust-lang/cargo#6605, rust-lang/cargo#6189)
- miri
- rls
- rustfmt

r? @davidtwco
@davidtwco
Copy link
Member

Closing as this was fixed in #60401.

cc @rust-lang/compiler so that everyone is aware the variable has changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler C-enhancement Category: An issue proposing an enhancement or a PR with one. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants