Skip to content
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

Event Source Tracking #16776

Closed
Tracked by #16775
NthTensor opened this issue Dec 11, 2024 · 1 comment · Fixed by #16778
Closed
Tracked by #16775

Event Source Tracking #16776

NthTensor opened this issue Dec 11, 2024 · 1 comment · Fixed by #16778
Labels
A-Dev-Tools Tools used to debug Bevy applications. A-Diagnostics Logging, crash handling, error reporting and performance analysis A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@NthTensor
Copy link
Contributor

NthTensor commented Dec 11, 2024

Add source location tracking to event dispatch, store Location in the event queue, and make it possible to iterate events along with source locations.

@NthTensor NthTensor changed the title Add source location tracking to event dispatch, store Location in the event queue, and make it possible to iterate events along with source locations. Event Source Tracking Dec 11, 2024
@NthTensor NthTensor added C-Feature A new feature, making something new possible A-ECS Entities, components, systems, and events S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! A-Diagnostics Logging, crash handling, error reporting and performance analysis A-Dev-Tools Tools used to debug Bevy applications. D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Dec 11, 2024
@aevyrie
Copy link
Member

aevyrie commented Dec 12, 2024

Get out of my head. I just came to post this as well.

github-merge-queue bot pushed a commit that referenced this issue Dec 12, 2024
# Objective

Fixes #16776

## Solution

- reflect `&'static Location` as an opaque type
- I've added this to `impls/std.rs` because other core types are there
too. Maybe they should be split out into a `core.rs` in another PR.
- add source location to `EventId` (behind the
`tracking_change_detection` feature flag)

## Testing

---

## Showcase
```rust
fn apply_damage_to_health(
    mut dmg_events: EventReader<DealDamage>,
) {
    for (event, event_id) in dmg_events.read_with_id() {
        info!(
            "Applying {} damage, triggered by {}",
            event.amount, event_id.caller
        );
…
```
```
2024-12-12T01:21:50.126827Z  INFO event: Applying 9 damage, triggered by examples/ecs/event.rs:47:16
```

## Migration Guide

- If you manually construct a `SendEvent`, use `SendEvent::new()`

---------

Co-authored-by: Alice Cecile <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dev-Tools Tools used to debug Bevy applications. A-Diagnostics Logging, crash handling, error reporting and performance analysis A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants