Skip to content

Commit d8d8bcf

Browse files
authored
Add ability to panic to logs example (#11171)
# Objective To debug issues like #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">
1 parent 846a871 commit d8d8bcf

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/app/logs.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,33 @@ fn main() {
1111
// filter: "wgpu=warn,bevy_ecs=info".to_string(),
1212
..default()
1313
}))
14+
.add_systems(Startup, setup)
1415
.add_systems(Update, log_system)
1516
.add_systems(Update, log_once_system)
17+
.add_systems(Update, panic_on_p)
1618
.run();
1719
}
1820

21+
fn setup(mut commands: Commands) {
22+
commands.spawn(Camera2dBundle::default());
23+
commands.spawn(TextBundle {
24+
text: Text::from_section(
25+
"Press P to panic",
26+
TextStyle {
27+
font_size: 60.0,
28+
..default()
29+
},
30+
),
31+
..default()
32+
});
33+
}
34+
35+
fn panic_on_p(keys: Res<ButtonInput<KeyCode>>) {
36+
if keys.just_pressed(KeyCode::KeyP) {
37+
panic!("P pressed, panicking");
38+
}
39+
}
40+
1941
fn log_system() {
2042
// here is how you write new logs at each "log level" (in "least important" to "most important"
2143
// order)

0 commit comments

Comments
 (0)