Skip to content

Commit 64efd08

Browse files
Prefer Display over Debug (#16112)
# Objective Fixes #16104 ## Solution I removed all instances of `:?` and put them back one by one where it caused an error. I removed some bevy_utils helper functions that were only used in 2 places and don't add value. See: #11478 ## Testing CI should catch the mistakes ## Migration Guide `bevy::utils::{dbg,info,warn,error}` were removed. Use `bevy::utils::tracing::{debug,info,warn,error}` instead. --------- Co-authored-by: SpecificProtagonist <[email protected]>
1 parent 80094c6 commit 64efd08

File tree

59 files changed

+155
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+155
-170
lines changed

crates/bevy_animation/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,8 @@ pub fn animate_targets(
10571057
(player, graph_handle.id())
10581058
} else {
10591059
trace!(
1060-
"Either an animation player {:?} or a graph was missing for the target \
1061-
entity {:?} ({:?}); no animations will play this frame",
1060+
"Either an animation player {} or a graph was missing for the target \
1061+
entity {} ({:?}); no animations will play this frame",
10621062
player_id,
10631063
entity_mut.id(),
10641064
entity_mut.get::<Name>(),

crates/bevy_asset/src/io/file/file_watcher.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ impl AssetWatcher for FileWatcher {}
4949
pub(crate) fn get_asset_path(root: &Path, absolute_path: &Path) -> (PathBuf, bool) {
5050
let relative_path = absolute_path.strip_prefix(root).unwrap_or_else(|_| {
5151
panic!(
52-
"FileWatcher::get_asset_path() failed to strip prefix from absolute path: absolute_path={:?}, root={:?}",
53-
absolute_path,
54-
root
52+
"FileWatcher::get_asset_path() failed to strip prefix from absolute path: absolute_path={}, root={}",
53+
absolute_path.display(),
54+
root.display()
5555
)
5656
});
5757
let is_meta = relative_path

crates/bevy_asset/src/io/file/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ impl FileAssetWriter {
7878
if create_root {
7979
if let Err(e) = std::fs::create_dir_all(&root_path) {
8080
error!(
81-
"Failed to create root directory {:?} for file asset writer: {:?}",
82-
root_path, e
81+
"Failed to create root directory {} for file asset writer: {}",
82+
root_path.display(),
83+
e
8384
);
8485
}
8586
}

crates/bevy_asset/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1684,9 +1684,9 @@ mod tests {
16841684
);
16851685
}
16861686
}
1687-
_ => panic!("Unexpected error type {:?}", read_error),
1687+
_ => panic!("Unexpected error type {}", read_error),
16881688
},
1689-
_ => panic!("Unexpected error type {:?}", error.error),
1689+
_ => panic!("Unexpected error type {}", error.error),
16901690
}
16911691
}
16921692
}

crates/bevy_asset/src/processor/mod.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -381,15 +381,18 @@ impl AssetProcessor {
381381
// Therefore, we shouldn't automatically delete the asset ... that is a
382382
// user-initiated action.
383383
debug!(
384-
"Meta for asset {:?} was removed. Attempting to re-process",
384+
"Meta for asset {} was removed. Attempting to re-process",
385385
AssetPath::from_path(&path).with_source(source.id())
386386
);
387387
self.process_asset(source, path).await;
388388
}
389389

390390
/// Removes all processed assets stored at the given path (respecting transactionality), then removes the folder itself.
391391
async fn handle_removed_folder(&self, source: &AssetSource, path: &Path) {
392-
debug!("Removing folder {:?} because source was removed", path);
392+
debug!(
393+
"Removing folder {} because source was removed",
394+
path.display()
395+
);
393396
let processed_reader = source.processed_reader().unwrap();
394397
match processed_reader.read_directory(path).await {
395398
Ok(mut path_stream) => {
@@ -739,7 +742,7 @@ impl AssetProcessor {
739742
) -> Result<ProcessResult, ProcessError> {
740743
// TODO: The extension check was removed now that AssetPath is the input. is that ok?
741744
// TODO: check if already processing to protect against duplicate hot-reload events
742-
debug!("Processing {:?}", asset_path);
745+
debug!("Processing {}", asset_path);
743746
let server = &self.server;
744747
let path = asset_path.path();
745748
let reader = source.reader();
@@ -1237,7 +1240,7 @@ impl ProcessorAssetInfos {
12371240
) {
12381241
match result {
12391242
Ok(ProcessResult::Processed(processed_info)) => {
1240-
debug!("Finished processing \"{:?}\"", asset_path);
1243+
debug!("Finished processing \"{}\"", asset_path);
12411244
// clean up old dependents
12421245
let old_processed_info = self
12431246
.infos
@@ -1260,7 +1263,7 @@ impl ProcessorAssetInfos {
12601263
}
12611264
}
12621265
Ok(ProcessResult::SkippedNotChanged) => {
1263-
debug!("Skipping processing (unchanged) \"{:?}\"", asset_path);
1266+
debug!("Skipping processing (unchanged) \"{}\"", asset_path);
12641267
let info = self.get_mut(&asset_path).expect("info should exist");
12651268
// NOTE: skipping an asset on a given pass doesn't mean it won't change in the future as a result
12661269
// of a dependency being re-processed. This means apps might receive an "old" (but valid) asset first.
@@ -1271,7 +1274,7 @@ impl ProcessorAssetInfos {
12711274
info.update_status(ProcessStatus::Processed).await;
12721275
}
12731276
Ok(ProcessResult::Ignored) => {
1274-
debug!("Skipping processing (ignored) \"{:?}\"", asset_path);
1277+
debug!("Skipping processing (ignored) \"{}\"", asset_path);
12751278
}
12761279
Err(ProcessError::ExtensionRequired) => {
12771280
// Skip assets without extensions

crates/bevy_asset/src/server/info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl AssetInfos {
443443
} else {
444444
// the dependency id does not exist, which implies it was manually removed or never existed in the first place
445445
warn!(
446-
"Dependency {:?} from asset {:?} is unknown. This asset's dependency load status will not switch to 'Loaded' until the unknown dependency is loaded.",
446+
"Dependency {} from asset {} is unknown. This asset's dependency load status will not switch to 'Loaded' until the unknown dependency is loaded.",
447447
dep_id, loaded_asset_id
448448
);
449449
true

crates/bevy_asset/src/server/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ impl AssetServer {
906906
.spawn(async move {
907907
let Ok(source) = server.get_source(path.source()) else {
908908
error!(
909-
"Failed to load {path}. AssetSource {:?} does not exist",
909+
"Failed to load {path}. AssetSource {} does not exist",
910910
path.source()
911911
);
912912
return;
@@ -918,7 +918,7 @@ impl AssetServer {
918918
Ok(reader) => reader,
919919
Err(_) => {
920920
error!(
921-
"Failed to load {path}. AssetSource {:?} does not have a processed AssetReader",
921+
"Failed to load {path}. AssetSource {} does not have a processed AssetReader",
922922
path.source()
923923
);
924924
return;

crates/bevy_audio/src/audio_output.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub(crate) fn play_queued_audio_system<Source: Asset + Decodable>(
130130
// the user may have made a mistake.
131131
if ear_positions.multiple_listeners() {
132132
warn!(
133-
"Multiple SpatialListeners found. Using {:?}.",
133+
"Multiple SpatialListeners found. Using {}.",
134134
ear_positions.query.iter().next().unwrap().0
135135
);
136136
}

crates/bevy_color/src/testing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ macro_rules! assert_approx_eq {
44
if ($x - $y).abs() >= $d {
55
panic!(
66
"assertion failed: `(left !== right)` \
7-
(left: `{:?}`, right: `{:?}`, tolerance: `{:?}`)",
7+
(left: `{}`, right: `{}`, tolerance: `{}`)",
88
$x, $y, $d
99
);
1010
}

crates/bevy_ecs/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct Position { x: f32, y: f32 }
8080

8181
fn print_position(query: Query<(Entity, &Position)>) {
8282
for (entity, position) in &query {
83-
println!("Entity {:?} is at position: x {}, y {}", entity, position.x, position.y);
83+
println!("Entity {} is at position: x {}, y {}", entity, position.x, position.y);
8484
}
8585
}
8686
```
@@ -172,7 +172,7 @@ struct Player;
172172
struct Alive;
173173

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

342342
world.add_observer(|trigger: Trigger<Explode>, mut commands: Commands| {
343-
println!("Entity {:?} goes BOOM!", trigger.target());
343+
println!("Entity {} goes BOOM!", trigger.target());
344344
commands.entity(trigger.target()).despawn();
345345
});
346346

crates/bevy_ecs/examples/change_detection.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ fn print_changed_entities(
8080
entity_with_mutated_component: Query<(Entity, &Age), Changed<Age>>,
8181
) {
8282
for entity in &entity_with_added_component {
83-
println!(" {entity:?} has it's first birthday!");
83+
println!(" {entity} has it's first birthday!");
8484
}
8585
for (entity, value) in &entity_with_mutated_component {
86-
println!(" {entity:?} is now {value:?} frames old");
86+
println!(" {entity} is now {value:?} frames old");
8787
}
8888
}
8989

@@ -98,7 +98,7 @@ fn age_all_entities(mut entities: Query<&mut Age>) {
9898
fn remove_old_entities(mut commands: Commands, entities: Query<(Entity, &Age)>) {
9999
for (entity, age) in &entities {
100100
if age.frames > 2 {
101-
println!(" despawning {entity:?} due to age > 2");
101+
println!(" despawning {entity} due to age > 2");
102102
commands.entity(entity).despawn();
103103
}
104104
}

crates/bevy_ecs/examples/events.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn sending_system(mut event_writer: EventWriter<MyEvent>) {
5757
fn receiving_system(mut event_reader: EventReader<MyEvent>) {
5858
for my_event in event_reader.read() {
5959
println!(
60-
" Received message {:?}, with random value of {}",
60+
" Received message {}, with random value of {}",
6161
my_event.message, my_event.random_value
6262
);
6363
}

crates/bevy_ecs/src/observer/runner.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub type ObserverRunner = fn(DeferredWorld, ObserverTrigger, PtrMut, propagate:
198198
/// struct Explode;
199199
///
200200
/// world.add_observer(|trigger: Trigger<Explode>, mut commands: Commands| {
201-
/// println!("Entity {:?} goes BOOM!", trigger.target());
201+
/// println!("Entity {} goes BOOM!", trigger.target());
202202
/// commands.entity(trigger.target()).despawn();
203203
/// });
204204
///

crates/bevy_ecs/src/query/filter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ unsafe impl<T: Component> QueryFilter for Without<T> {
356356
/// #
357357
/// fn print_cool_entity_system(query: Query<Entity, Or<(Changed<Color>, Changed<Node>)>>) {
358358
/// for entity in &query {
359-
/// println!("Entity {:?} got a new style or color", entity);
359+
/// println!("Entity {} got a new style or color", entity);
360360
/// }
361361
/// }
362362
/// # bevy_ecs::system::assert_is_system(print_cool_entity_system);

crates/bevy_ecs/src/removal_detection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl RemovedComponentEvents {
134134
/// # #[derive(Component)]
135135
/// # struct MyComponent;
136136
/// fn react_on_removal(mut removed: RemovedComponents<MyComponent>) {
137-
/// removed.read().for_each(|removed_entity| println!("{:?}", removed_entity));
137+
/// removed.read().for_each(|removed_entity| println!("{}", removed_entity));
138138
/// }
139139
/// # bevy_ecs::system::assert_is_system(react_on_removal);
140140
/// ```

crates/bevy_ecs/src/system/commands/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ impl<'w, 's> Commands<'w, 's> {
452452
#[track_caller]
453453
fn panic_no_entity(entities: &Entities, entity: Entity) -> ! {
454454
panic!(
455-
"Attempting to create an EntityCommands for entity {entity:?}, which {}",
455+
"Attempting to create an EntityCommands for entity {entity}, which {}",
456456
entities.entity_does_not_exist_error_details_message(entity)
457457
);
458458
}
@@ -1405,7 +1405,7 @@ impl<'a> EntityCommands<'a> {
14051405
entity.insert_by_id(component_id, ptr);
14061406
});
14071407
} else {
1408-
panic!("error[B0003]: {caller}: Could not insert a component {component_id:?} (with type {}) for entity {entity:?}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<T>(), world.entities().entity_does_not_exist_error_details_message(entity));
1408+
panic!("error[B0003]: {caller}: Could not insert a component {component_id:?} (with type {}) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<T>(), world.entities().entity_does_not_exist_error_details_message(entity));
14091409
}
14101410
})
14111411
}
@@ -1739,7 +1739,7 @@ impl<'a> EntityCommands<'a> {
17391739
/// .spawn_empty()
17401740
/// // Closures with this signature implement `EntityCommand`.
17411741
/// .queue(|entity: EntityWorldMut| {
1742-
/// println!("Executed an EntityCommand for {:?}", entity.id());
1742+
/// println!("Executed an EntityCommand for {}", entity.id());
17431743
/// });
17441744
/// # }
17451745
/// # bevy_ecs::system::assert_is_system(my_system);
@@ -2119,7 +2119,7 @@ impl<'a, T: Component> EntityEntryCommands<'a, T> {
21192119
caller,
21202120
);
21212121
} else {
2122-
panic!("error[B0003]: {caller}: Could not insert a bundle (of type `{}`) for {entity:?}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<T>(), world.entities().entity_does_not_exist_error_details_message(entity) );
2122+
panic!("error[B0003]: {caller}: Could not insert a bundle (of type `{}`) for {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<T>(), world.entities().entity_does_not_exist_error_details_message(entity) );
21232123
}
21242124
});
21252125
self
@@ -2225,7 +2225,7 @@ fn insert<T: Bundle>(bundle: T, mode: InsertMode) -> impl EntityCommand {
22252225
caller,
22262226
);
22272227
} else {
2228-
panic!("error[B0003]: {caller}: Could not insert a bundle (of type `{}`) for entity {entity:?}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<T>(), world.entities().entity_does_not_exist_error_details_message(entity));
2228+
panic!("error[B0003]: {caller}: Could not insert a bundle (of type `{}`) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<T>(), world.entities().entity_does_not_exist_error_details_message(entity));
22292229
}
22302230
}
22312231
}

crates/bevy_ecs/src/system/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1652,9 +1652,10 @@ mod tests {
16521652
assert_is_system(returning::<&str>.map(u64::from_str).map(Result::unwrap));
16531653
assert_is_system(static_system_param);
16541654
assert_is_system(
1655-
exclusive_in_out::<(), Result<(), std::io::Error>>.map(|result| {
1656-
if let Err(error) = result {
1657-
log::error!("{:?}", error);
1655+
exclusive_in_out::<(), Result<(), std::io::Error>>.map(|_out| {
1656+
#[cfg(feature = "trace")]
1657+
if let Err(error) = _out {
1658+
tracing::error!("{}", error);
16581659
}
16591660
}),
16601661
);

crates/bevy_ecs/src/system/query.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
620620
/// ) {
621621
/// for friends in &friends_query {
622622
/// for counter in counter_query.iter_many(&friends.list) {
623-
/// println!("Friend's counter: {:?}", counter.value);
623+
/// println!("Friend's counter: {}", counter.value);
624624
/// }
625625
/// }
626626
/// }
@@ -674,7 +674,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
674674
/// for friends in &friends_query {
675675
/// let mut iter = counter_query.iter_many_mut(&friends.list);
676676
/// while let Some(mut counter) = iter.fetch_next() {
677-
/// println!("Friend's counter: {:?}", counter.value);
677+
/// println!("Friend's counter: {}", counter.value);
678678
/// counter.value += 1;
679679
/// }
680680
/// }

crates/bevy_ecs/src/world/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ impl World {
710710
#[track_caller]
711711
fn panic_no_entity(world: &World, entity: Entity) -> ! {
712712
panic!(
713-
"Entity {entity:?} {}",
713+
"Entity {entity} {}",
714714
world
715715
.entities
716716
.entity_does_not_exist_error_details_message(entity)
@@ -862,7 +862,7 @@ impl World {
862862
let entity_location = self
863863
.entities()
864864
.get(entity)
865-
.unwrap_or_else(|| panic!("Entity {entity:?} does not exist"));
865+
.unwrap_or_else(|| panic!("Entity {entity} does not exist"));
866866

867867
let archetype = self
868868
.archetypes()
@@ -1336,7 +1336,7 @@ impl World {
13361336
true
13371337
} else {
13381338
if log_warning {
1339-
warn!("error[B0003]: {caller}: Could not despawn entity {entity:?}, which {}. See: https://bevyengine.org/learn/errors/b0003", self.entities.entity_does_not_exist_error_details_message(entity));
1339+
warn!("error[B0003]: {caller}: Could not despawn entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", self.entities.entity_does_not_exist_error_details_message(entity));
13401340
}
13411341
false
13421342
}
@@ -2498,11 +2498,11 @@ impl World {
24982498
)
24992499
};
25002500
} else {
2501-
panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {entity:?}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<B>(), self.entities.entity_does_not_exist_error_details_message(entity));
2501+
panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<B>(), self.entities.entity_does_not_exist_error_details_message(entity));
25022502
}
25032503
}
25042504
} else {
2505-
panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {first_entity:?}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<B>(), self.entities.entity_does_not_exist_error_details_message(first_entity));
2505+
panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {first_entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::<B>(), self.entities.entity_does_not_exist_error_details_message(first_entity));
25062506
}
25072507
}
25082508
}

crates/bevy_ecs/src/world/reflect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub enum GetComponentReflectError {
213213
NoCorrespondingComponentId(TypeId),
214214

215215
/// The given [`Entity`] does not have a [`Component`] corresponding to the given [`TypeId`].
216-
#[error("The given `Entity` {entity:?} does not have a `{component_name:?}` component ({component_id:?}, which corresponds to {type_id:?})")]
216+
#[error("The given `Entity` {entity} does not have a `{component_name:?}` component ({component_id:?}, which corresponds to {type_id:?})")]
217217
EntityDoesNotHaveComponent {
218218
/// The given [`Entity`].
219219
entity: Entity,

0 commit comments

Comments
 (0)