-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Move from log
to tracing
#74726
Move from log
to tracing
#74726
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc_driver/Cargo.toml
Outdated
@@ -12,8 +12,8 @@ crate-type = ["dylib"] | |||
[dependencies] | |||
lazy_static = "1.0" | |||
libc = "0.2" | |||
log = "0.4" | |||
env_logger = { version = "0.7", default-features = false } | |||
log = { package = "tracing", version = "0.1" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The replacements seem like they could be pretty confusing, so we should try to move off of them pretty quickly, but I agree that for now this is probably the right way to do things, presuming it doesn't cause problems with tracing's own macros expanding to ::tracing::foo
and that not resolving.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I'll open an E-easy issue with checkboxes for each of the renames
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracing's macros should all use $crate::
, so this should be fine.
Once CI is passing here, could you kick off a perf run? I want to make sure this isn't a performance regression (which would be unexpected, but we should check). |
Looks like rustdoc had a dependency on
|
(that is actually good - any tools that have shared dependencies with rustc should ideally not declare them to save time in CI as loading from the sysroot is free, compared to recompiling) |
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit 2f7afb6d9058b3ebf7a059517ddc231da059ef0d with merge ec225facb960eff32c5290531b2dced3da219bdb... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-actions |
@bors try @rust-timer queue this time |
Awaiting bors try build completion |
⌛ Trying commit b9a3fd38bef4e62704cfefda80ccf67a815700d1 with merge 46c33324e985772632898d0f4c1b6d4c246496ec... |
☀️ Try build successful - checks-actions, checks-azure |
Queued 46c33324e985772632898d0f4c1b6d4c246496ec with parent 037d8e7, future comparison URL. |
Could you also make a PR to update the rustc-dev-guide, specifically with how to turn on and use logging? There is some existing content on how to enable the current logging system. |
Finished benchmarking try commit (46c33324e985772632898d0f4c1b6d4c246496ec): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
@hawkw any tips on debugging perf regressions due to migrating from EDIT 1: I believe this is all working correctly, as looking at a const-eval heavy test's perf result (https://perf.rust-lang.org/detailed-query.html?commit=46c33324e985772632898d0f4c1b6d4c246496ec&base_commit=037d8e747de5056f0202f29aa2b0353bdbbf5cfe&benchmark=wf-projection-stress-65510-check&run_name=full) still has a significant number of EDIT 2: I'm doing what you suggested originally now (I think?), and enabling the EDIT 3: Oh, that doesn't work with EDIT 4: Maybe we're losing perf because we stay compatible to |
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit e301587481705f5dd14df480a9f76c2432e3ad8e with merge 1b5adbdbb4a5be604061874ffc2dade72bf7ede0... |
☀️ Try build successful - checks-actions, checks-azure |
/// other than `RUSTC_LOG`. | ||
pub fn init_env_logger(env: &str) { | ||
// Don't register a dispatcher if there's no filter to print anything | ||
match std::env::var(env) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be var_os?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what would be the difference in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not checking utf8 validity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm true, let's change it
This broke my logging :( How do I get back the behavior of |
|
hmm, this works for |
This fixes it for me: diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 002c5f96710..4f08452767a 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -43,7 +43,7 @@ extern crate rustc_trait_selection;
extern crate rustc_typeck;
extern crate test as testing;
#[macro_use]
-extern crate log;
+extern crate tracing as log;
use std::default::Default;
use std::env; Other tools might need a similar fix. |
Sure, #74747 is the end goal and if tools want to do that first that's fine. But in the meantime logging is completely broken for rustdoc. |
👍 #75081 is a reasonable patch until rustdoc is ready for source renaming |
Fix logging for rustdoc rust-lang#74726 (comment)
Fix logging for rustdoc rust-lang#74726 (comment)
Fix logging for rustdoc rust-lang#74726 (comment)
Fix logging for rustdoc rust-lang#74726 (comment)
Yay! I'm really glad we were able to get this merged, and the optimizations should benefit other Please feel free to ping me if anyone has additional questions about migrating to |
Fix logging for rustdoc rust-lang#74726 (comment)
FWIW, it might be worth trying this again with the latest |
The only visible change is that we now get timestamps in our logs:
This PR was explicitly designed to be as low-impact as possible. We can now move to using the name
tracing
insteads oflog
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)