-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Add access to App
within LogPlugin::update_subscriber
#12045
Add access to App
within LogPlugin::update_subscriber
#12045
Conversation
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 the most elegant of communication mechanisms, but I can see the value.
Can you add a test and/or example demonstrating this?
I'm not sure if my current solution for app-layer communication is good enough to be featured in an example. My current solution is to use a |
I found a better solution using |
The generated |
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.
Ah, I get the point of this feature now! Really useful, and thanks for making an example.
So, I think we can sharpen this example further, and really focus on the specific common use case you demonstrated to showcase the value to users.
Namely, you want to be able to capture all of the logging events that you send in all of your random systems. But rather than duplicating the API to do this directly in the ECS, you're sending them to the logging code first, processing them, and then reading them back in. This is helpful because it works with arbitrary logging statements, you can take advantage of the parsing, and you don't need to add boilerplate anywhere. Great for things like error popups, in additional to your terminal logging.
Okay so:
- Swap names of example and structs to represent this specific use case (capturing logs in the ECS).
- Demonstrate that you can log in arbitrary systems: maybe add a couple of buttons that each produce a different log level when pressed?
- Respond to the produced log levels in the follow-up system, rather than just printing them. A pop-up would be ideal, but if that's too tricky maybe just change the text on screen to match.
- Swap the filter to show how to only catch errors.
The generated |
2 similar comments
The generated |
The generated |
I feel like this is a bit out of scope of the |
In isolation, this feature doesn't seem useful, either to maintainers or to users. They'll read the example, wonder "hmm I wonder what that would be good for" and move on (or try and delete the underlying functionality because it doesn't seem useful). Focusing on a specific tangible use case gives us the freedom to redesign the API to better support that use case, rather than having to guess about how it relates to the actual thing we want to do. It's okay to do a simplified version of this (no buttons, no pop-up), but I want to make sure the intent is preserved. |
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.
Great, I'm happy with this now. The small changes went a long way to clarifying intent. Thanks!
…#12045) # Objective In my library, [`bevy_dev_console`](https://github.com/doonv/bevy_dev_console) I need access to `App` within `LogPlugin::update_subscriber` in order to communicate with the `App` from my custom `Layer`. ## Solution Give access to `App`. --- ## Changelog - Added access to `App` within `LogPlugin::update_subscriber` ## Migration Guide `LogPlugin::update_subscriber` now has a `&mut App` parameter. If you don't need access to `App`, you can ignore the parameter with an underscore (`_`). ```diff,rust - fn update_subscriber(subscriber: BoxedSubscriber) -> BoxedSubscriber { + fn update_subscriber(_: &mut App, subscriber: BoxedSubscriber) -> BoxedSubscriber { Box::new(subscriber.with(CustomLayer)) } ```
# Objective - CI is green ## Solution - Fix typos (bevyengine#12045) - Correctly declare features (bevyengine#12100)
The release notes are incorrect (https://bevyengine.org/learn/migration-guides/0-13-to-0-14/#add-access-to-app-within-logplugin-update-subscriber) because this change has been superseded by #13159 |
The correct way to fix that is to file a PR request to the |
Objective
In my library,
bevy_dev_console
I need access toApp
withinLogPlugin::update_subscriber
in order to communicate with theApp
from my customLayer
.Solution
Give access to
App
.Changelog
App
withinLogPlugin::update_subscriber
Migration Guide
LogPlugin::update_subscriber
now has a&mut App
parameter. If you don't need access toApp
, you can ignore the parameter with an underscore (_
).