-
Notifications
You must be signed in to change notification settings - Fork 13.3k
RFC: Make RUST_LOG={error,warning,debug,all} work #2033
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
Comments
I support this proposal. We could still support the old syntax too, for those who like conciseness; I guess there's no harm in it. |
Your suggestion is a bit ambiguous. Let's try to be specific. I agree it's cumbersome at present. The existing scheme is:
There are ways we could improve this:
You pretty much never want |
So the proposal is to use the following pseudo-BNF to match the contents of
The semantics are as follows:
|
Shall we interpret silence as consensus in favor of @pcwalton 's last comment here? (I support it.) |
This seems to partially work. @astrieanna and I were trying to figure out how to fix this, and we got bogged down in the parsing code, trying to figure out how The manual indicates that numbers should be used to indicate the logging level, but that feature appears to have been removed (or perhaps it's incomplete): debug.rs
We also tried to format described in this issue, which partially works.
The help command doesn't seem to be implemented. There's a In rust_log.h, the different log levels are defined, and there are It seems like we could fix this by defining the appropriate If you understand the code associated with this issue, would you mind pointing us to the right things to look at, so we can take a crack at fixing it? |
I wrote that manual entry like a week ago, shortly after the 0.6 release. So it must have been a really recent changed :( |
@danluu, @astrieanna: RUST_LOG is kind of arcane. From https://github.com/mozilla/rust/wiki/Doc-usage-FAQ :
For your
The numbers, which indicate log levels, are optional, and you append them to the path with an equals sign (
It's admittedly kind of a pain to have to specify the crate name in the log spec, even when it's a single .rs file with no modules and there's only one path that could possibly be the one you mean. RUST_LOG is optimized for the case of debugging large Rust executables (like Take this file, for instance:
If I want to log everything, I can:
But maybe I just want to log module
Here we still get the error from module
So, @steveklabnik's manual entry looks OK to me, but perhaps it could stand to have some examples of logging specifications. (The examples in this comment are with rustc 0.5.) |
Also, I think it would make sense to close this bug, and instead open separate bugs (if they don't already exist) for the suggestions in graydon's comment above. |
The
RUST_LOG
syntax is very mysterious right now. I propose a syntax that looks like this:RUST_LOG=all
— logs everything.RUST_LOG=error
— logs errors.RUST_LOG=e
— same as above.RUST_LOG=warning
— logs errors and warnings.RUST_LOG=warning,typeck
— logs errors and warnings in modules nested somewhere within a module named "typeck" (including deeper modules).RUST_LOG=all,typeck,trans
— logs all messages coming from a module named "typeck" and all messages coming from a module named "trans"RUST_LOG=debug,rustc::middle::typeck
— logs errors and warnings in modules nested somewhere within a module named "typeck" inside a module named "middle" inside a module named "rustc"RUST_LOG=help
— displays a help message in the runtime, then exits.IMHO this would be easy to use.
Basically the
log
statement would pass a list of module names to the runtime, and the logging function would do a string comparison on each path component to determine which to print.The text was updated successfully, but these errors were encountered: