From d8d8bcfb21396a49af66066cf77f9169c1e0efed Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Tue, 2 Jan 2024 03:02:56 +0000 Subject: [PATCH] Add ability to panic to logs example (#11171) # Objective To debug issues like https://github.com/bevyengine/bevy/pull/11169. ## Solution When P is pressed in logs example, call `panic!()`. Screenshot 2024-01-02 at 01 10 16 --- examples/app/logs.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/app/logs.rs b/examples/app/logs.rs index 797fd85fc121b..851d55a2ab687 100644 --- a/examples/app/logs.rs +++ b/examples/app/logs.rs @@ -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>) { + 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)