Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer Display over Debug #16112

Merged
merged 20 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,8 +1079,8 @@ pub fn animate_targets(
(player, graph_handle.id())
} else {
trace!(
"Either an animation player {:?} or a graph was missing for the target \
entity {:?} ({:?}); no animations will play this frame",
"Either an animation player {} or a graph was missing for the target \
entity {} ({:?}); no animations will play this frame",
player_id,
entity_mut.id(),
entity_mut.get::<Name>(),
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_asset/src/io/file/file_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ impl AssetWatcher for FileWatcher {}
pub(crate) fn get_asset_path(root: &Path, absolute_path: &Path) -> (PathBuf, bool) {
let relative_path = absolute_path.strip_prefix(root).unwrap_or_else(|_| {
panic!(
"FileWatcher::get_asset_path() failed to strip prefix from absolute path: absolute_path={:?}, root={:?}",
absolute_path,
root
"FileWatcher::get_asset_path() failed to strip prefix from absolute path: absolute_path={}, root={}",
absolute_path.display(),
root.display()
)
});
let is_meta = relative_path
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_asset/src/io/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ impl FileAssetWriter {
if create_root {
if let Err(e) = std::fs::create_dir_all(&root_path) {
error!(
"Failed to create root directory {:?} for file asset writer: {:?}",
root_path, e
"Failed to create root directory {} for file asset writer: {}",
root_path.display(),
e
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1672,9 +1672,9 @@ mod tests {
);
}
}
_ => panic!("Unexpected error type {:?}", read_error),
_ => panic!("Unexpected error type {}", read_error),
},
_ => panic!("Unexpected error type {:?}", error.error),
_ => panic!("Unexpected error type {}", error.error),
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions crates/bevy_asset/src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,18 @@ impl AssetProcessor {
// Therefore, we shouldn't automatically delete the asset ... that is a
// user-initiated action.
debug!(
"Meta for asset {:?} was removed. Attempting to re-process",
"Meta for asset {} was removed. Attempting to re-process",
AssetPath::from_path(&path).with_source(source.id())
);
self.process_asset(source, path).await;
}

/// Removes all processed assets stored at the given path (respecting transactionality), then removes the folder itself.
async fn handle_removed_folder(&self, source: &AssetSource, path: &Path) {
debug!("Removing folder {:?} because source was removed", path);
debug!(
"Removing folder {} because source was removed",
path.display()
);
let processed_reader = source.processed_reader().unwrap();
match processed_reader.read_directory(path).await {
Ok(mut path_stream) => {
Expand Down Expand Up @@ -739,7 +742,7 @@ impl AssetProcessor {
) -> Result<ProcessResult, ProcessError> {
// TODO: The extension check was removed now that AssetPath is the input. is that ok?
// TODO: check if already processing to protect against duplicate hot-reload events
debug!("Processing {:?}", asset_path);
debug!("Processing {}", asset_path);
let server = &self.server;
let path = asset_path.path();
let reader = source.reader();
Expand Down Expand Up @@ -1237,7 +1240,7 @@ impl ProcessorAssetInfos {
) {
match result {
Ok(ProcessResult::Processed(processed_info)) => {
debug!("Finished processing \"{:?}\"", asset_path);
debug!("Finished processing \"{}\"", asset_path);
// clean up old dependents
let old_processed_info = self
.infos
Expand All @@ -1260,7 +1263,7 @@ impl ProcessorAssetInfos {
}
}
Ok(ProcessResult::SkippedNotChanged) => {
debug!("Skipping processing (unchanged) \"{:?}\"", asset_path);
debug!("Skipping processing (unchanged) \"{}\"", asset_path);
let info = self.get_mut(&asset_path).expect("info should exist");
// NOTE: skipping an asset on a given pass doesn't mean it won't change in the future as a result
// of a dependency being re-processed. This means apps might receive an "old" (but valid) asset first.
Expand All @@ -1271,7 +1274,7 @@ impl ProcessorAssetInfos {
info.update_status(ProcessStatus::Processed).await;
}
Ok(ProcessResult::Ignored) => {
debug!("Skipping processing (ignored) \"{:?}\"", asset_path);
debug!("Skipping processing (ignored) \"{}\"", asset_path);
}
Err(ProcessError::ExtensionRequired) => {
// Skip assets without extensions
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/server/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl AssetInfos {
} else {
// the dependency id does not exist, which implies it was manually removed or never existed in the first place
warn!(
"Dependency {:?} from asset {:?} is unknown. This asset's dependency load status will not switch to 'Loaded' until the unknown dependency is loaded.",
"Dependency {} from asset {} is unknown. This asset's dependency load status will not switch to 'Loaded' until the unknown dependency is loaded.",
dep_id, loaded_asset_id
);
true
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ impl AssetServer {
.spawn(async move {
let Ok(source) = server.get_source(path.source()) else {
error!(
"Failed to load {path}. AssetSource {:?} does not exist",
"Failed to load {path}. AssetSource {} does not exist",
path.source()
);
return;
Expand All @@ -914,7 +914,7 @@ impl AssetServer {
Ok(reader) => reader,
Err(_) => {
error!(
"Failed to load {path}. AssetSource {:?} does not have a processed AssetReader",
"Failed to load {path}. AssetSource {} does not have a processed AssetReader",
path.source()
);
return;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_audio/src/audio_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub(crate) fn play_queued_audio_system<Source: Asset + Decodable>(
// the user may have made a mistake.
if ear_positions.multiple_listeners() {
warn!(
"Multiple SpatialListeners found. Using {:?}.",
"Multiple SpatialListeners found. Using {}.",
ear_positions.query.iter().next().unwrap().0
);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_color/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ macro_rules! assert_approx_eq {
if ($x - $y).abs() >= $d {
panic!(
"assertion failed: `(left !== right)` \
(left: `{:?}`, right: `{:?}`, tolerance: `{:?}`)",
(left: `{}`, right: `{}`, tolerance: `{}`)",
$x, $y, $d
);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_dev_tools/src/ui_debug_overlay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fn outline_roots(
{
let Ok(camera) = cam.cameras.get(camera_entity) else {
// The camera wasn't found. Either the Camera don't exist or the Camera is the debug Camera, that we want to skip and warn
warn_once!("Camera {:?} wasn't found for debug overlay", camera_entity);
warn_once!("Camera {} wasn't found for debug overlay", camera_entity);
continue;
};
match camera.target {
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_ecs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct Position { x: f32, y: f32 }

fn print_position(query: Query<(Entity, &Position)>) {
for (entity, position) in &query {
println!("Entity {:?} is at position: x {}, y {}", entity, position.x, position.y);
println!("Entity {} is at position: x {}, y {}", entity, position.x, position.y);
}
}
```
Expand Down Expand Up @@ -172,7 +172,7 @@ struct Player;
struct Alive;

// Gets the Position component of all Entities with Player component and without the Alive
// component.
// component.
fn system(query: Query<&Position, (With<Player>, Without<Alive>)>) {
for position in &query {
}
Expand Down Expand Up @@ -340,7 +340,7 @@ let mut world = World::new();
let entity = world.spawn_empty().id();

world.add_observer(|trigger: Trigger<Explode>, mut commands: Commands| {
println!("Entity {:?} goes BOOM!", trigger.entity());
println!("Entity {} goes BOOM!", trigger.entity());
commands.entity(trigger.entity()).despawn();
});

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/examples/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn sending_system(mut event_writer: EventWriter<MyEvent>) {
fn receiving_system(mut event_reader: EventReader<MyEvent>) {
for my_event in event_reader.read() {
println!(
" Received message {:?}, with random value of {}",
" Received message {}, with random value of {}",
my_event.message, my_event.random_value
);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ impl ComponentHooks {
/// Will panic if the component already has an `on_add` hook
pub fn on_add(&mut self, hook: ComponentHook) -> &mut Self {
self.try_on_add(hook)
.expect("Component id: {:?}, already has an on_add hook")
.expect("Component id: {}, already has an on_add hook")
}

/// Register a [`ComponentHook`] that will be run when this component is added (with `.insert`)
Expand All @@ -505,7 +505,7 @@ impl ComponentHooks {
/// Will panic if the component already has an `on_insert` hook
pub fn on_insert(&mut self, hook: ComponentHook) -> &mut Self {
self.try_on_insert(hook)
.expect("Component id: {:?}, already has an on_insert hook")
.expect("Component id: {}, already has an on_insert hook")
}

/// Register a [`ComponentHook`] that will be run when this component is about to be dropped,
Expand All @@ -527,7 +527,7 @@ impl ComponentHooks {
/// Will panic if the component already has an `on_replace` hook
pub fn on_replace(&mut self, hook: ComponentHook) -> &mut Self {
self.try_on_replace(hook)
.expect("Component id: {:?}, already has an on_replace hook")
.expect("Component id: {}, already has an on_replace hook")
}

/// Register a [`ComponentHook`] that will be run when this component is removed from an entity.
Expand All @@ -538,7 +538,7 @@ impl ComponentHooks {
/// Will panic if the component already has an `on_remove` hook
pub fn on_remove(&mut self, hook: ComponentHook) -> &mut Self {
self.try_on_remove(hook)
.expect("Component id: {:?}, already has an on_remove hook")
.expect("Component id: {}, already has an on_remove hook")
}

/// Attempt to register a [`ComponentHook`] that will be run when this component is added to an entity.
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/observer/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub type ObserverRunner = fn(DeferredWorld, ObserverTrigger, PtrMut, propagate:
/// struct Explode;
///
/// world.add_observer(|trigger: Trigger<Explode>, mut commands: Commands| {
/// println!("Entity {:?} goes BOOM!", trigger.entity());
/// println!("Entity {} goes BOOM!", trigger.entity());
/// commands.entity(trigger.entity()).despawn();
/// });
///
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/query/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ unsafe impl<T: Component> QueryFilter for Without<T> {
/// #
/// fn print_cool_entity_system(query: Query<Entity, Or<(Changed<Color>, Changed<Node>)>>) {
/// for entity in &query {
/// println!("Entity {:?} got a new style or color", entity);
/// println!("Entity {} got a new style or color", entity);
/// }
/// }
/// # bevy_ecs::system::assert_is_system(print_cool_entity_system);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/removal_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl RemovedComponentEvents {
/// # #[derive(Component)]
/// # struct MyComponent;
/// fn react_on_removal(mut removed: RemovedComponents<MyComponent>) {
/// removed.read().for_each(|removed_entity| println!("{:?}", removed_entity));
/// removed.read().for_each(|removed_entity| println!("{}", removed_entity));
/// }
/// # bevy_ecs::system::assert_is_system(react_on_removal);
/// ```
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/system/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ impl<'a> EntityCommands<'a> {
/// .spawn_empty()
/// // Closures with this signature implement `EntityCommand`.
/// .queue(|entity: EntityWorldMut| {
/// println!("Executed an EntityCommand for {:?}", entity.id());
/// println!("Executed an EntityCommand for {}", entity.id());
/// });
/// # }
/// # bevy_ecs::system::assert_is_system(my_system);
Expand Down Expand Up @@ -1967,7 +1967,7 @@ fn insert<T: Bundle>(bundle: T, mode: InsertMode) -> impl EntityCommand {
caller,
);
} else {
panic!("error[B0003]: {caller}: Could not insert a bundle (of type `{}`) for entity {:?} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<T>(), entity);
panic!("error[B0003]: {caller}: Could not insert a bundle (of type `{}`) for entity {} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<T>(), entity);
}
}
}
Expand All @@ -1986,7 +1986,7 @@ fn insert_from_world<T: Component + FromWorld>(mode: InsertMode) -> impl EntityC
caller,
);
} else {
panic!("error[B0003]: {caller}: Could not insert a bundle (of type `{}`) for entity {:?} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<T>(), entity);
panic!("error[B0003]: {caller}: Could not insert a bundle (of type `{}`) for entity {} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<T>(), entity);
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion crates/bevy_ecs/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,13 @@ mod tests {
assert_is_system(returning::<Option<()>>.map(drop));
assert_is_system(returning::<&str>.map(u64::from_str).map(Result::unwrap));
assert_is_system(static_system_param);
assert_is_system(exclusive_in_out::<(), Result<(), std::io::Error>>.map(bevy_utils::error));
assert_is_system(
exclusive_in_out::<(), Result<(), std::io::Error>>.map(|system| {
if let Err(err) = system {
BenjaminBrienen marked this conversation as resolved.
Show resolved Hide resolved
bevy_utils::tracing::error!("{err}");
}
}),
);
BenjaminBrienen marked this conversation as resolved.
Show resolved Hide resolved
assert_is_system(exclusive_with_state);
assert_is_system(returning::<bool>.pipe(exclusive_in_out::<bool, ()>));

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/system/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
/// ) {
/// for friends in &friends_query {
/// for counter in counter_query.iter_many(&friends.list) {
/// println!("Friend's counter: {:?}", counter.value);
/// println!("Friend's counter: {}", counter.value);
/// }
/// }
/// }
Expand Down Expand Up @@ -672,7 +672,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
/// for friends in &friends_query {
/// let mut iter = counter_query.iter_many_mut(&friends.list);
/// while let Some(mut counter) = iter.fetch_next() {
/// println!("Friend's counter: {:?}", counter.value);
/// println!("Friend's counter: {}", counter.value);
/// counter.value += 1;
/// }
/// }
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ impl World {
true
} else {
if log_warning {
warn!("error[B0003]: {caller}: Could not despawn entity {:?} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003", entity);
warn!("error[B0003]: {caller}: Could not despawn entity {} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003", entity);
}
false
}
Expand Down Expand Up @@ -2613,11 +2613,11 @@ impl World {
)
};
} else {
panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {:?} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<B>(), entity);
panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<B>(), entity);
}
}
} else {
panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {:?} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<B>(), first_entity);
panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<B>(), first_entity);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,13 @@ async fn load_gltf<'a, 'b, 'c>(
if [Semantic::Joints(0), Semantic::Weights(0)].contains(&semantic) {
if !meshes_on_skinned_nodes.contains(&gltf_mesh.index()) {
warn!(
"Ignoring attribute {:?} for skinned mesh {:?} used on non skinned nodes (NODE_SKINNED_MESH_WITHOUT_SKIN)",
"Ignoring attribute {:?} for skinned mesh {} used on non skinned nodes (NODE_SKINNED_MESH_WITHOUT_SKIN)",
semantic,
primitive_label
);
continue;
} else if meshes_on_non_skinned_nodes.contains(&gltf_mesh.index()) {
error!("Skinned mesh {:?} used on both skinned and non skin nodes, this is likely to cause an error (NODE_SKINNED_MESH_WITHOUT_SKIN)", primitive_label);
error!("Skinned mesh {} used on both skinned and non skin nodes, this is likely to cause an error (NODE_SKINNED_MESH_WITHOUT_SKIN)", primitive_label);
}
}
match convert_attribute(
Expand Down Expand Up @@ -699,9 +699,9 @@ async fn load_gltf<'a, 'b, 'c>(
generate_tangents_span.in_scope(|| {
if let Err(err) = mesh.generate_tangents() {
warn!(
"Failed to generate vertex tangents using the mikktspace algorithm: {:?}",
err
);
"Failed to generate vertex tangents using the mikktspace algorithm: {}",
err
);
}
});
}
Expand Down Expand Up @@ -1874,7 +1874,7 @@ impl<'a> GltfTreeIterator<'a> {
if skin.joints().len() > MAX_JOINTS && warned_about_max_joints.insert(skin.index())
{
warn!(
"The glTF skin {:?} has {} joints, but the maximum supported is {}",
"The glTF skin {} has {} joints, but the maximum supported is {}",
skin.name()
.map(ToString::to_string)
.unwrap_or_else(|| skin.index().to_string()),
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_hierarchy/src/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ fn despawn_with_children_recursive_inner(world: &mut World, entity: Entity, warn

if warn {
if !world.despawn(entity) {
debug!("Failed to despawn entity {:?}", entity);
debug!("Failed to despawn entity {}", entity);
}
} else if !world.try_despawn(entity) {
debug!("Failed to despawn entity {:?}", entity);
debug!("Failed to despawn entity {}", entity);
}
}

Expand Down
Loading
Loading