-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Allow initializing logger with additional tracing Layer #140969
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
base: master
Are you sure you want to change the base?
Conversation
I don't understand why the build fails, locally it works. The CI logs are 400MB, but here are the last few lines:
|
Looks like something in this PR is causing a lot more debug messages to be emitted. Some of those debug messages use the "def path formatting" machinery, which is expensive and so there are safeguards that this machinery is only called when there are actual compilation errors to emit -- which isn't the case here, so we ultimately get an ICE. But the ICE isn't the actual problem, the actual problem is that debug tracing now seems to be enabled by default. |
@@ -104,7 +115,7 @@ pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> { | |||
}; | |||
|
|||
let mut layer = tracing_tree::HierarchicalLayer::default() | |||
.with_writer(io::stderr) | |||
.with_writer(io::stderr as fn() -> io::Stderr) |
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.
Why is there a fn ptr cast here now?
@@ -124,7 +135,8 @@ pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> { | |||
Err(_) => {} // no wraptree | |||
} | |||
|
|||
let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer); | |||
let subscriber = | |||
Registry::default().with(additional_tracing_layer).with(layer.with_filter(filter)); |
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.
This seems to change the way the filter is applied, which might explain the explosion of debug messages?
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
This PR adds functions to the
rustc_log
andrustc_driver_impl
crates to allow initializing the logger with an additionaltracing_subscriber::Layer
. This will be used in Miri to save trace events to file using e.g.tracing-chrome
's ortracing-tracy
'sLayer
s.Additional context on the choice of signature can be found in this Zulip thread.
I re-exported
tracing_subscriber::{Layer, Registry};
fromrustc_log
so thatrustc_driver_impl
can use them in the function signature without depending ontracing_subscriber
directly. I did this to avoid copy-pasting the dependency line with all of the enabled features from therustc_log
to therustc_driver_impl
's Cargo.toml, which would have possibly led to redundancies and inconsistencies.r? @RalfJung