Skip to content

Commit

Permalink
Add ability to panic to logs example
Browse files Browse the repository at this point in the history
  • Loading branch information
stepancheg committed Jan 2, 2024
1 parent 846a871 commit 724fb39
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 724fb39

Please sign in to comment.