-
-
Notifications
You must be signed in to change notification settings - Fork 4k
bevy_log: refactor how log layers are wired together #19248
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
bevy_log: refactor how log layers are wired together #19248
Conversation
b3a00f5
to
cb01aa1
Compare
No idea how to fix Edit: It was due to CI failing not my PR, so all good now |
cb01aa1
to
d187380
Compare
Originally posted by @JeanMertz in #17722 (comment) @JeanMertz, you might have a look at the solution I propose in this PR to solve that issue |
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.
Love it. I missed that part of the tracing document, and this is indeed a much cleaner implementation.
|
||
#[expect( |
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.
Which variable isn't used? Can't you just cfg it out?
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.
custom_format_layer
is not used when compiling for wasm32, android or ios.
As it is passed as an argument to the function, not possible to cfg that to my knowledge (function signature would change otherwise)
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.
There was already #19085 that tracks the fact that the way we configure things with custom_format_layer
is not optimal. I tried to keep the scope focused and manageable for this refactor in order to not change the way users need to configure things.
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.
custom_format_layer
is not used when compiling for wasm32, android or ios. As it is passed as an argument to the function, not possible to cfg that to my knowledge (function signature would change otherwise)
You can config a parameter out. There's no reason to make those platforms pass that parameter in, right?
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 is a really nice cleanup!
I tested it with tracing-wasm (working around the issue in tokio-rs/tracing#2720 by not printing time) and tracing-chrome, both work as expected.
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 is so much nicer than what we had before!
Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.com>
I think this broke our default log filters. All the examples are now dumping every shader to stdout. |
Yeah, this PR broke log filtering. There's a bit more detail in this issue #19689 |
Objective
Current way to wire
Layer
s together usinglayer.with(new_layer)
in thebevy_log
plugin is brittle and not flexible. As #17722 demonstrated, the current solution makes it very hard to do any kind of advanced wiring, as the type system oftracing::Subscriber
gets in the way very quickly (the type of each new layer depends on the type of the previous ones). We want to make it easier to have more complex wiring ofLayers
. It would be hard to solve #19085 without itSolution
It aims to be functionally equivalent.
layer.with(new_layer)
. We now addlayer.boxed()
to aVec<BoxedLayer>
. It is a solution recommended bytracing_subscriber::Layer
for complex wiring cases (See https://docs.rs/tracing-subscriber/latest/tracing_subscriber/layer/index.html#runtime-configuration-with-layers)Testing
trace
,tracing-chrome
,tracing-tracy
to check that it still works as expectedios
,android
andwasm
to check it as well.