Skip to content

Commit

Permalink
Replace bevy_log's tracing reexport with bevy_utils' (#12254)
Browse files Browse the repository at this point in the history
# Objective
Fixes #11298. Make the use of bevy_log vs bevy_utils::tracing more
consistent.

## Solution
Replace all uses of bevy_log's logging macros with the reexport from
bevy_utils. Remove bevy_log as a dependency where it's no longer needed
anymore.

Ideally we should just be using tracing directly, but given that all of
these crates are already using bevy_utils, this likely isn't that great
of a loss right now.
  • Loading branch information
james7132 committed Mar 2, 2024
1 parent 0d172b2 commit 5619bd0
Show file tree
Hide file tree
Showing 46 changed files with 47 additions and 55 deletions.
1 change: 0 additions & 1 deletion crates/bevy_animation/Cargo.toml
Expand Up @@ -13,7 +13,6 @@ keywords = ["bevy"]
bevy_app = { path = "../bevy_app", version = "0.14.0-dev" }
bevy_asset = { path = "../bevy_asset", version = "0.14.0-dev" }
bevy_core = { path = "../bevy_core", version = "0.14.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.14.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", features = [
"bevy",
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_animation/src/lib.rs
Expand Up @@ -14,14 +14,13 @@ use bevy_core::Name;
use bevy_ecs::entity::MapEntities;
use bevy_ecs::prelude::*;
use bevy_ecs::reflect::ReflectMapEntities;
use bevy_log::error;
use bevy_math::{FloatExt, Quat, Vec3};
use bevy_reflect::Reflect;
use bevy_render::mesh::morph::MorphWeights;
use bevy_time::Time;
use bevy_transform::{prelude::Transform, TransformSystem};
use bevy_utils::hashbrown::HashMap;
use bevy_utils::{NoOpHash, Uuid};
use bevy_utils::{tracing::error, NoOpHash, Uuid};
use sha1_smol::Sha1;

#[allow(missing_docs)]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/Cargo.toml
Expand Up @@ -21,7 +21,6 @@ watch = []
bevy_app = { path = "../bevy_app", version = "0.14.0-dev" }
bevy_asset_macros = { path = "macros", version = "0.14.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev" }
bevy_tasks = { path = "../bevy_tasks", version = "0.14.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
Expand Down Expand Up @@ -53,6 +52,7 @@ notify-debouncer-full = { version = "0.3.1", optional = true }

[dev-dependencies]
bevy_core = { path = "../bevy_core", version = "0.14.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/android.rs
@@ -1,7 +1,7 @@
use crate::io::{
get_meta_path, AssetReader, AssetReaderError, EmptyPathStream, PathStream, Reader, VecReader,
};
use bevy_log::error;
use bevy_utils::tracing::error;
use bevy_utils::BoxedFuture;
use std::{ffi::CString, path::Path};

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/embedded/embedded_watcher.rs
Expand Up @@ -3,7 +3,7 @@ use crate::io::{
memory::Dir,
AssetSourceEvent, AssetWatcher,
};
use bevy_log::warn;
use bevy_utils::tracing::warn;
use bevy_utils::{Duration, HashMap};
use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, FileIdMap};
use parking_lot::RwLock;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/file/file_watcher.rs
@@ -1,6 +1,6 @@
use crate::io::{AssetSourceEvent, AssetWatcher};
use crate::path::normalize_path;
use bevy_log::error;
use bevy_utils::tracing::error;
use bevy_utils::Duration;
use crossbeam_channel::Sender;
use notify_debouncer_full::{
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/file/mod.rs
Expand Up @@ -6,7 +6,7 @@ mod file_asset;
#[cfg(not(feature = "multi-threaded"))]
mod sync_file_asset;

use bevy_log::error;
use bevy_utils::tracing::error;
#[cfg(feature = "file_watcher")]
pub use file_watcher::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/processor_gated.rs
Expand Up @@ -4,7 +4,7 @@ use crate::{
AssetPath,
};
use async_lock::RwLockReadGuardArc;
use bevy_log::trace;
use bevy_utils::tracing::trace;
use bevy_utils::BoxedFuture;
use futures_io::AsyncRead;
use std::{path::Path, pin::Pin, sync::Arc};
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/source.rs
Expand Up @@ -6,7 +6,7 @@ use crate::{
processor::AssetProcessorData,
};
use bevy_ecs::system::Resource;
use bevy_log::{error, warn};
use bevy_utils::tracing::{error, warn};
use bevy_utils::{CowArc, Duration, HashMap};
use std::{fmt::Display, hash::Hash, sync::Arc};
use thiserror::Error;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/wasm.rs
@@ -1,7 +1,7 @@
use crate::io::{
get_meta_path, AssetReader, AssetReaderError, EmptyPathStream, PathStream, Reader, VecReader,
};
use bevy_log::error;
use bevy_utils::tracing::error;
use bevy_utils::BoxedFuture;
use js_sys::{Uint8Array, JSON};
use std::path::{Path, PathBuf};
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_asset/src/lib.rs
Expand Up @@ -55,9 +55,8 @@ use bevy_ecs::{
system::Resource,
world::FromWorld,
};
use bevy_log::error;
use bevy_reflect::{FromReflect, GetTypeRegistration, Reflect, TypePath};
use bevy_utils::HashSet;
use bevy_utils::{tracing::error, HashSet};
use std::{any::TypeId, sync::Arc};

#[cfg(all(feature = "file_watcher", not(feature = "multi-threaded")))]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/meta.rs
@@ -1,6 +1,6 @@
use crate::{self as bevy_asset, DeserializeMetaError, VisitAssetDependencies};
use crate::{loader::AssetLoader, processor::Process, Asset, AssetPath};
use bevy_log::error;
use bevy_utils::tracing::error;
use downcast_rs::{impl_downcast, Downcast};
use ron::ser::PrettyConfig;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/processor/log.rs
@@ -1,6 +1,6 @@
use crate::AssetPath;
use async_fs::File;
use bevy_log::error;
use bevy_utils::tracing::error;
use bevy_utils::HashSet;
use futures_lite::{AsyncReadExt, AsyncWriteExt};
use std::path::PathBuf;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/processor/mod.rs
Expand Up @@ -17,8 +17,8 @@ use crate::{
MissingAssetLoaderForExtensionError,
};
use bevy_ecs::prelude::*;
use bevy_log::{debug, error, trace, warn};
use bevy_tasks::IoTaskPool;
use bevy_utils::tracing::{debug, error, trace, warn};
use bevy_utils::{BoxedFuture, HashMap, HashSet};
use futures_io::ErrorKind;
use futures_lite::{AsyncReadExt, AsyncWriteExt, StreamExt};
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/server/info.rs
Expand Up @@ -5,7 +5,7 @@ use crate::{
UntypedAssetId, UntypedHandle,
};
use bevy_ecs::world::World;
use bevy_log::warn;
use bevy_utils::tracing::warn;
use bevy_utils::{Entry, HashMap, HashSet, TypeIdMap};
use crossbeam_channel::Sender;
use std::{
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/server/loaders.rs
Expand Up @@ -3,8 +3,8 @@ use crate::{
path::AssetPath,
};
use async_broadcast::RecvError;
use bevy_log::{error, warn};
use bevy_tasks::IoTaskPool;
use bevy_utils::tracing::{error, warn};
use bevy_utils::{HashMap, TypeIdMap};
use std::{any::TypeId, sync::Arc};
use thiserror::Error;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/server/mod.rs
Expand Up @@ -18,8 +18,8 @@ use crate::{
UntypedAssetLoadFailedEvent, UntypedHandle,
};
use bevy_ecs::prelude::*;
use bevy_log::{error, info};
use bevy_tasks::IoTaskPool;
use bevy_utils::tracing::{error, info};
use bevy_utils::{CowArc, HashSet};
use crossbeam_channel::{Receiver, Sender};
use futures_lite::StreamExt;
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_core_pipeline/Cargo.toml
Expand Up @@ -27,7 +27,6 @@ bevy_core = { path = "../bevy_core", version = "0.14.0-dev" }
bevy_color = { path = "../bevy_color", version = "0.14.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.14.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev" }
bevy_render = { path = "../bevy_render", version = "0.14.0-dev" }
bevy_transform = { path = "../bevy_transform", version = "0.14.0-dev" }
Expand Down
8 changes: 5 additions & 3 deletions crates/bevy_core_pipeline/src/tonemapping/mod.rs
Expand Up @@ -14,6 +14,8 @@ use bevy_render::renderer::RenderDevice;
use bevy_render::texture::{CompressedImageFormats, Image, ImageSampler, ImageType};
use bevy_render::view::{ViewTarget, ViewUniform};
use bevy_render::{render_resource::*, Render, RenderApp, RenderSet};
#[cfg(not(feature = "tonemapping_luts"))]
use bevy_utils::tracing::error;

mod node;

Expand Down Expand Up @@ -199,7 +201,7 @@ impl SpecializedRenderPipeline for TonemappingPipeline {
Tonemapping::AcesFitted => shader_defs.push("TONEMAP_METHOD_ACES_FITTED".into()),
Tonemapping::AgX => {
#[cfg(not(feature = "tonemapping_luts"))]
bevy_log::error!(
error!(
"AgX tonemapping requires the `tonemapping_luts` feature.
Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended),
or use a different `Tonemapping` method in your `Camera2dBundle`/`Camera3dBundle`."
Expand All @@ -211,7 +213,7 @@ impl SpecializedRenderPipeline for TonemappingPipeline {
}
Tonemapping::TonyMcMapface => {
#[cfg(not(feature = "tonemapping_luts"))]
bevy_log::error!(
error!(
"TonyMcMapFace tonemapping requires the `tonemapping_luts` feature.
Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended),
or use a different `Tonemapping` method in your `Camera2dBundle`/`Camera3dBundle`."
Expand All @@ -220,7 +222,7 @@ impl SpecializedRenderPipeline for TonemappingPipeline {
}
Tonemapping::BlenderFilmic => {
#[cfg(not(feature = "tonemapping_luts"))]
bevy_log::error!(
error!(
"BlenderFilmic tonemapping requires the `tonemapping_luts` feature.
Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended),
or use a different `Tonemapping` method in your `Camera2dBundle`/`Camera3dBundle`."
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_diagnostic/Cargo.toml
Expand Up @@ -19,7 +19,6 @@ features = []
bevy_app = { path = "../bevy_app", version = "0.14.0-dev" }
bevy_core = { path = "../bevy_core", version = "0.14.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }
bevy_time = { path = "../bevy_time", version = "0.14.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_diagnostic/src/log_diagnostics_plugin.rs
@@ -1,8 +1,8 @@
use super::{Diagnostic, DiagnosticPath, DiagnosticsStore};
use bevy_app::prelude::*;
use bevy_ecs::prelude::*;
use bevy_log::{debug, info};
use bevy_time::{Real, Time, Timer, TimerMode};
use bevy_utils::tracing::{debug, info};
use bevy_utils::Duration;

/// An App Plugin that logs diagnostics to the console.
Expand Down
Expand Up @@ -40,7 +40,7 @@ impl SystemInformationDiagnosticsPlugin {
))]
pub mod internal {
use bevy_ecs::{prelude::ResMut, system::Local};
use bevy_log::info;
use bevy_utils::tracing::info;
use sysinfo::{CpuRefreshKind, MemoryRefreshKind, RefreshKind, System};

use crate::{Diagnostic, Diagnostics, DiagnosticsStore};
Expand Down Expand Up @@ -136,7 +136,7 @@ pub mod internal {
)))]
pub mod internal {
pub(crate) fn setup_system() {
bevy_log::warn!("This platform and/or configuration is not supported!");
bevy_utils::tracing::warn!("This platform and/or configuration is not supported!");
}

pub(crate) fn diagnostic_system() {
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_gilrs/Cargo.toml
Expand Up @@ -13,7 +13,6 @@ keywords = ["bevy"]
bevy_app = { path = "../bevy_app", version = "0.14.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev" }
bevy_input = { path = "../bevy_input", version = "0.14.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
bevy_time = { path = "../bevy_time", version = "0.14.0-dev" }

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gilrs/src/rumble.rs
Expand Up @@ -4,8 +4,8 @@ use bevy_ecs::prelude::{EventReader, Res, ResMut, Resource};
#[cfg(target_arch = "wasm32")]
use bevy_ecs::system::NonSendMut;
use bevy_input::gamepad::{GamepadRumbleIntensity, GamepadRumbleRequest};
use bevy_log::{debug, warn};
use bevy_time::{Real, Time};
use bevy_utils::tracing::{debug, warn};
use bevy_utils::{synccell::SyncCell, Duration, HashMap};
use gilrs::{
ff::{self, BaseEffect, BaseEffectType, Repeat, Replay},
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_gizmos/Cargo.toml
Expand Up @@ -27,7 +27,6 @@ bevy_core = { path = "../bevy_core", version = "0.14.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev" }
bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.14.0-dev" }
bevy_transform = { path = "../bevy_transform", version = "0.14.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }
bevy_gizmos_macros = { path = "macros", version = "0.14.0-dev" }

[lints]
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_gizmos/src/lib.rs
Expand Up @@ -96,7 +96,9 @@ impl Plugin for GizmoPlugin {
fn build(&self, app: &mut bevy_app::App) {
// Gizmos cannot work without either a 3D or 2D renderer.
#[cfg(all(not(feature = "bevy_pbr"), not(feature = "bevy_sprite")))]
bevy_log::error!("bevy_gizmos requires either bevy_pbr or bevy_sprite. Please enable one.");
bevy_utils::tracing::error!(
"bevy_gizmos requires either bevy_pbr or bevy_sprite. Please enable one."
);

load_internal_asset!(app, LINE_SHADER_HANDLE, "lines.wgsl", Shader::from_wgsl);

Expand Down
1 change: 0 additions & 1 deletion crates/bevy_gltf/Cargo.toml
Expand Up @@ -22,7 +22,6 @@ bevy_core = { path = "../bevy_core", version = "0.14.0-dev" }
bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.14.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev" }
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.14.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.14.0-dev" }
bevy_pbr = { path = "../bevy_pbr", version = "0.14.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", features = [
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_gltf/src/loader.rs
Expand Up @@ -9,7 +9,6 @@ use bevy_core_pipeline::prelude::Camera3dBundle;
use bevy_ecs::entity::EntityHashMap;
use bevy_ecs::{entity::Entity, world::World};
use bevy_hierarchy::{BuildWorldChildren, WorldChildBuilder};
use bevy_log::{error, info_span, warn};
use bevy_math::{Affine2, Mat4, Vec3};
use bevy_pbr::{
DirectionalLight, DirectionalLightBundle, PbrBundle, PointLight, PointLightBundle, SpotLight,
Expand All @@ -36,6 +35,7 @@ use bevy_scene::Scene;
#[cfg(not(target_arch = "wasm32"))]
use bevy_tasks::IoTaskPool;
use bevy_transform::components::Transform;
use bevy_utils::tracing::{error, info_span, warn};
use bevy_utils::{
smallvec::{smallvec, SmallVec},
HashMap, HashSet,
Expand Down Expand Up @@ -474,9 +474,9 @@ async fn load_gltf<'a, 'b, 'c>(
let vertex_count_after = mesh.count_vertices();

if vertex_count_before != vertex_count_after {
bevy_log::debug!("Missing vertex normals in indexed geometry, computing them as flat. Vertex count increased from {} to {}", vertex_count_before, vertex_count_after);
bevy_utils::tracing::debug!("Missing vertex normals in indexed geometry, computing them as flat. Vertex count increased from {} to {}", vertex_count_before, vertex_count_after);
} else {
bevy_log::debug!(
bevy_utils::tracing::debug!(
"Missing vertex normals in indexed geometry, computing them as flat."
);
}
Expand All @@ -490,7 +490,7 @@ async fn load_gltf<'a, 'b, 'c>(
} else if mesh.attribute(Mesh::ATTRIBUTE_NORMAL).is_some()
&& primitive.material().normal_texture().is_some()
{
bevy_log::debug!(
bevy_utils::tracing::debug!(
"Missing vertex tangents for {}, computing them using the mikktspace algorithm. Consider using a tool such as Blender to pre-compute the tangents.", file_name
);

Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_hierarchy/Cargo.toml
Expand Up @@ -11,15 +11,14 @@ keywords = ["bevy"]
[features]
default = ["bevy_app"]
trace = []
bevy_app = ["reflect", "dep:bevy_app", "bevy_core", "bevy_log"]
bevy_app = ["reflect", "dep:bevy_app", "bevy_core"]
reflect = ["bevy_ecs/bevy_reflect", "bevy_reflect"]

[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.14.0-dev", optional = true }
bevy_core = { path = "../bevy_core", version = "0.14.0-dev", optional = true }
bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev", default-features = false }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev", optional = true }
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", features = [
"bevy",
], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_hierarchy/src/valid_parent_check_plugin.rs
Expand Up @@ -64,7 +64,7 @@ pub fn check_hierarchy_component_has_valid_parent<T: Component>(
let parent = parent.get();
if !component_query.contains(parent) && !already_diagnosed.contains(&entity) {
already_diagnosed.insert(entity);
bevy_log::warn!(
bevy_utils::tracing::warn!(
"warning[B0004]: {name} with the {ty_name} component has a parent without {ty_name}.\n\
This will cause inconsistent behaviors! See: https://bevyengine.org/learn/errors/#b0004",
ty_name = get_short_name(std::any::type_name::<T>()),
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_render/Cargo.toml
Expand Up @@ -46,7 +46,6 @@ bevy_derive = { path = "../bevy_derive", version = "0.14.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev" }
bevy_encase_derive = { path = "../bevy_encase_derive", version = "0.14.0-dev" }
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.14.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.14.0-dev" }
bevy_mikktspace = { path = "../bevy_mikktspace", version = "0.14.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", features = [
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/camera/camera.rs
Expand Up @@ -20,11 +20,11 @@ use bevy_ecs::{
reflect::ReflectComponent,
system::{Commands, Query, Res, ResMut, Resource},
};
use bevy_log::warn;
use bevy_math::{vec2, Dir3, Mat4, Ray3d, Rect, URect, UVec2, UVec4, Vec2, Vec3};
use bevy_reflect::prelude::*;
use bevy_render_macros::ExtractComponent;
use bevy_transform::components::GlobalTransform;
use bevy_utils::tracing::warn;
use bevy_utils::{HashMap, HashSet};
use bevy_window::{
NormalizedWindowRef, PrimaryWindow, Window, WindowCreated, WindowRef, WindowResized,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/extract_resource.rs
Expand Up @@ -51,7 +51,7 @@ pub fn extract_resource<R: ExtractResource>(
} else {
#[cfg(debug_assertions)]
if !main_resource.is_added() {
bevy_log::warn_once!(
bevy_utils::warn_once!(
"Removing resource {} from render world not expected, adding using `Commands`.
This may decrease performance",
std::any::type_name::<R>()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/mesh/mesh/mod.rs
Expand Up @@ -17,10 +17,10 @@ use bevy_ecs::system::{
lifetimeless::{SRes, SResMut},
SystemParamItem,
};
use bevy_log::warn;
use bevy_math::*;
use bevy_reflect::Reflect;
use bevy_utils::tracing::error;
use bevy_utils::tracing::warn;
use std::{collections::BTreeMap, hash::Hash, iter::FusedIterator};
use thiserror::Error;
use wgpu::{
Expand Down

0 comments on commit 5619bd0

Please sign in to comment.