Skip to content

Commit

Permalink
Add ability to panic to logs example (bevyengine#11171)
Browse files Browse the repository at this point in the history
# Objective

To debug issues like bevyengine#11169.

## Solution

When P is pressed in logs example, call `panic!()`.

<img width="1392" alt="Screenshot 2024-01-02 at 01 10 16"
src="https://github.com/bevyengine/bevy/assets/28969/a788737e-d23c-43a3-bc68-d6c5b0ab88ad">
  • Loading branch information
stepancheg committed Jan 2, 2024
1 parent 846a871 commit d8d8bcf
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/app/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,33 @@ fn main() {
// filter: "wgpu=warn,bevy_ecs=info".to_string(),
..default()
}))
.add_systems(Startup, setup)
.add_systems(Update, log_system)
.add_systems(Update, log_once_system)
.add_systems(Update, panic_on_p)
.run();
}

fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(TextBundle {
text: Text::from_section(
"Press P to panic",
TextStyle {
font_size: 60.0,
..default()
},
),
..default()
});
}

fn panic_on_p(keys: Res<ButtonInput<KeyCode>>) {
if keys.just_pressed(KeyCode::KeyP) {
panic!("P pressed, panicking");
}
}

fn log_system() {
// here is how you write new logs at each "log level" (in "least important" to "most important"
// order)
Expand Down

0 comments on commit d8d8bcf

Please sign in to comment.