
# Objective - Contributes to #11478 ## Solution - Made `bevy_utils::tracing` `doc(hidden)` - Re-exported `tracing` from `bevy_log` for end-users - Added `tracing` directly to crates that need it. ## Testing - CI --- ## Migration Guide If you were importing `tracing` via `bevy::utils::tracing`, instead use `bevy::log::tracing`. Note that many items within `tracing` are also directly re-exported from `bevy::log` as well, so you may only need `bevy::log` for the most common items (e.g., `warn!`, `trace!`, etc.). This also applies to the `log_once!` family of macros. ## Notes - While this doesn't reduce the line-count in `bevy_utils`, it further decouples the internal crates from `bevy_utils`, making its eventual removal more feasible in the future. - I have just imported `tracing` as we do for all dependencies. However, a workspace dependency may be more appropriate for version management.
19 lines
690 B
Rust
19 lines
690 B
Rust
//! Tools for debugging states.
|
|
|
|
use bevy_ecs::event::EventReader;
|
|
use bevy_state::state::{StateTransitionEvent, States};
|
|
use tracing::info;
|
|
|
|
/// Logs state transitions into console.
|
|
///
|
|
/// This system is provided to make debugging easier by tracking state changes.
|
|
pub fn log_transitions<S: States>(mut transitions: EventReader<StateTransitionEvent<S>>) {
|
|
// State internals can generate at most one event (of type) per frame.
|
|
let Some(transition) = transitions.read().last() else {
|
|
return;
|
|
};
|
|
let name = core::any::type_name::<S>();
|
|
let StateTransitionEvent { exited, entered } = transition;
|
|
info!("{} transition: {:?} => {:?}", name, exited, entered);
|
|
}
|