From a371ee3019348d35e2a4c6e14477c46802f8b1ca Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Mon, 6 Jan 2025 10:06:34 +1100 Subject: [PATCH] Remove `tracing` re-export from `bevy_utils` (#17161) # 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. --- crates/bevy_animation/Cargo.toml | 1 + crates/bevy_animation/src/lib.rs | 6 +- crates/bevy_asset/Cargo.toml | 1 + crates/bevy_asset/src/asset_changed.rs | 2 +- crates/bevy_asset/src/io/android.rs | 2 +- .../src/io/embedded/embedded_watcher.rs | 3 +- crates/bevy_asset/src/io/file/file_watcher.rs | 2 +- crates/bevy_asset/src/io/file/mod.rs | 2 +- crates/bevy_asset/src/io/processor_gated.rs | 2 +- crates/bevy_asset/src/io/source.rs | 6 +- crates/bevy_asset/src/io/wasm.rs | 2 +- crates/bevy_asset/src/lib.rs | 3 +- crates/bevy_asset/src/meta.rs | 2 +- crates/bevy_asset/src/processor/log.rs | 3 +- crates/bevy_asset/src/processor/mod.rs | 10 +-- crates/bevy_asset/src/server/info.rs | 3 +- crates/bevy_asset/src/server/loaders.rs | 7 +- crates/bevy_asset/src/server/mod.rs | 6 +- crates/bevy_audio/Cargo.toml | 2 +- crates/bevy_audio/src/audio_output.rs | 2 +- crates/bevy_core_pipeline/Cargo.toml | 1 + .../src/core_2d/main_opaque_pass_2d_node.rs | 4 +- .../core_2d/main_transparent_pass_2d_node.rs | 4 +- .../src/core_3d/main_opaque_pass_3d_node.rs | 4 +- .../core_3d/main_transmissive_pass_3d_node.rs | 6 +- .../core_3d/main_transparent_pass_3d_node.rs | 4 +- crates/bevy_core_pipeline/src/core_3d/mod.rs | 3 +- .../bevy_core_pipeline/src/deferred/node.rs | 4 +- crates/bevy_core_pipeline/src/dof/mod.rs | 15 ++-- crates/bevy_core_pipeline/src/oit/mod.rs | 6 +- .../bevy_core_pipeline/src/oit/resolve/mod.rs | 2 +- crates/bevy_core_pipeline/src/prepass/node.rs | 4 +- crates/bevy_core_pipeline/src/taa/mod.rs | 2 +- .../bevy_core_pipeline/src/tonemapping/mod.rs | 4 +- crates/bevy_dev_tools/Cargo.toml | 2 +- .../bevy_dev_tools/src/ci_testing/systems.rs | 2 +- crates/bevy_dev_tools/src/fps_overlay.rs | 5 +- crates/bevy_dev_tools/src/states.rs | 2 +- crates/bevy_diagnostic/Cargo.toml | 2 + .../src/log_diagnostics_plugin.rs | 2 +- .../system_information_diagnostics_plugin.rs | 4 +- crates/bevy_ecs/Cargo.toml | 2 +- crates/bevy_ecs/src/query/state.rs | 4 +- crates/bevy_gilrs/Cargo.toml | 1 + crates/bevy_gilrs/src/lib.rs | 3 +- crates/bevy_gilrs/src/rumble.rs | 7 +- crates/bevy_gizmos/Cargo.toml | 2 + crates/bevy_gizmos/src/lib.rs | 13 ++-- crates/bevy_gizmos/src/pipeline_2d.rs | 2 +- crates/bevy_gizmos/src/pipeline_3d.rs | 2 +- crates/bevy_gizmos/src/retained.rs | 7 +- crates/bevy_gltf/Cargo.toml | 1 + crates/bevy_gltf/src/loader.rs | 16 ++-- crates/bevy_image/Cargo.toml | 1 + crates/bevy_image/src/dds.rs | 8 +- crates/bevy_image/src/image.rs | 2 +- crates/bevy_input_focus/Cargo.toml | 4 +- crates/bevy_input_focus/src/tab_navigation.rs | 2 +- crates/bevy_log/Cargo.toml | 3 + crates/bevy_log/src/android_tracing.rs | 4 +- crates/bevy_log/src/lib.rs | 25 ++++--- crates/bevy_log/src/once.rs | 49 ++++++++++++ crates/bevy_mesh/Cargo.toml | 4 +- crates/bevy_mesh/src/mesh.rs | 2 +- crates/bevy_pbr/Cargo.toml | 2 +- crates/bevy_pbr/src/cluster/assign.rs | 3 +- crates/bevy_pbr/src/cluster/mod.rs | 3 +- crates/bevy_pbr/src/light_probe/mod.rs | 3 +- crates/bevy_pbr/src/lightmap/mod.rs | 3 +- crates/bevy_pbr/src/material.rs | 3 +- crates/bevy_pbr/src/material_bind_groups.rs | 3 +- crates/bevy_pbr/src/meshlet/mod.rs | 2 +- crates/bevy_pbr/src/prepass/mod.rs | 2 +- crates/bevy_pbr/src/render/gpu_preprocess.rs | 2 +- crates/bevy_pbr/src/render/light.rs | 11 +-- crates/bevy_pbr/src/render/mesh.rs | 8 +- .../bevy_pbr/src/render/mesh_view_bindings.rs | 18 ++--- crates/bevy_pbr/src/ssao/mod.rs | 6 +- crates/bevy_pbr/src/ssr/mod.rs | 7 +- crates/bevy_picking/Cargo.toml | 3 + crates/bevy_picking/src/events.rs | 3 +- crates/bevy_picking/src/input.rs | 3 +- .../src/mesh_picking/ray_cast/mod.rs | 2 +- crates/bevy_render/Cargo.toml | 1 + .../src/batching/gpu_preprocessing.rs | 3 +- .../src/batching/no_gpu_preprocessing.rs | 2 +- crates/bevy_render/src/camera/camera.rs | 3 +- .../src/camera/camera_driver_node.rs | 2 +- crates/bevy_render/src/diagnostic/internal.rs | 2 +- crates/bevy_render/src/extract_resource.rs | 10 ++- crates/bevy_render/src/gpu_readback.rs | 3 +- crates/bevy_render/src/lib.rs | 4 +- crates/bevy_render/src/mesh/allocator.rs | 3 +- crates/bevy_render/src/pipelined_rendering.rs | 7 +- crates/bevy_render/src/render_asset.rs | 6 +- crates/bevy_render/src/render_graph/app.rs | 2 +- .../src/render_phase/draw_state.rs | 74 +++++++++++++------ .../bind_group_layout_entries.rs | 2 +- .../src/render_resource/pipeline_cache.rs | 8 +- .../render_resource/pipeline_specializer.rs | 2 +- .../bevy_render/src/renderer/graph_runner.rs | 4 +- crates/bevy_render/src/renderer/mod.rs | 6 +- crates/bevy_render/src/view/window/mod.rs | 9 +-- .../bevy_render/src/view/window/screenshot.rs | 9 +-- crates/bevy_sprite/Cargo.toml | 1 + crates/bevy_sprite/src/mesh2d/material.rs | 2 +- crates/bevy_sprite/src/mesh2d/mesh.rs | 2 +- .../bevy_sprite/src/texture_atlas_builder.rs | 6 +- crates/bevy_sprite/src/texture_slice/mod.rs | 2 +- .../bevy_sprite/src/texture_slice/slicer.rs | 2 +- crates/bevy_text/Cargo.toml | 1 + crates/bevy_text/src/text.rs | 27 +++---- crates/bevy_time/Cargo.toml | 1 + crates/bevy_time/src/lib.rs | 3 +- crates/bevy_time/src/virt.rs | 2 +- crates/bevy_ui/Cargo.toml | 1 + crates/bevy_ui/src/layout/debug.rs | 2 +- crates/bevy_ui/src/layout/mod.rs | 2 +- crates/bevy_ui/src/render/render_pass.rs | 2 +- crates/bevy_ui/src/ui_node.rs | 5 +- crates/bevy_ui/src/widget/text.rs | 3 +- crates/bevy_utils/Cargo.toml | 14 +--- crates/bevy_utils/src/lib.rs | 13 ---- crates/bevy_utils/src/once.rs | 50 ------------- crates/bevy_winit/Cargo.toml | 2 +- crates/bevy_winit/src/cursor.rs | 4 +- crates/bevy_winit/src/state.rs | 2 +- crates/bevy_winit/src/system.rs | 2 +- crates/bevy_winit/src/winit_windows.rs | 5 +- examples/app/log_layers.rs | 9 ++- examples/app/log_layers_ecs.rs | 2 +- examples/ecs/system_piping.rs | 5 +- tools/example-showcase/disable-audio.patch | 2 +- 133 files changed, 377 insertions(+), 359 deletions(-) create mode 100644 crates/bevy_log/src/once.rs diff --git a/crates/bevy_animation/Cargo.toml b/crates/bevy_animation/Cargo.toml index b3312aa0ce..35346092e9 100644 --- a/crates/bevy_animation/Cargo.toml +++ b/crates/bevy_animation/Cargo.toml @@ -39,6 +39,7 @@ either = "1.13" thread_local = "1" uuid = { version = "1.7", features = ["v4"] } smallvec = "1" +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index 9baacf61c5..aeadc5233f 100644 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -44,13 +44,11 @@ use bevy_math::FloatOrd; use bevy_reflect::{prelude::ReflectDefault, Reflect, TypePath}; use bevy_time::Time; use bevy_transform::TransformSystem; -use bevy_utils::{ - tracing::{trace, warn}, - HashMap, NoOpHash, PreHashMap, PreHashMapExt, TypeIdMap, -}; +use bevy_utils::{HashMap, NoOpHash, PreHashMap, PreHashMapExt, TypeIdMap}; use petgraph::graph::NodeIndex; use serde::{Deserialize, Serialize}; use thread_local::ThreadLocal; +use tracing::{trace, warn}; use uuid::Uuid; /// The animation prelude. diff --git a/crates/bevy_asset/Cargo.toml b/crates/bevy_asset/Cargo.toml index de7094a636..e0c18253a8 100644 --- a/crates/bevy_asset/Cargo.toml +++ b/crates/bevy_asset/Cargo.toml @@ -47,6 +47,7 @@ serde = { version = "1", features = ["derive"] } thiserror = { version = "2", default-features = false } derive_more = { version = "1", default-features = false, features = ["from"] } uuid = { version = "1.0", features = ["v4"] } +tracing = { version = "0.1", default-features = false, features = ["std"] } [target.'cfg(target_os = "android")'.dependencies] bevy_window = { path = "../bevy_window", version = "0.15.0-dev" } diff --git a/crates/bevy_asset/src/asset_changed.rs b/crates/bevy_asset/src/asset_changed.rs index 9aafc157f7..b8f3fafc6b 100644 --- a/crates/bevy_asset/src/asset_changed.rs +++ b/crates/bevy_asset/src/asset_changed.rs @@ -13,10 +13,10 @@ use bevy_ecs::{ storage::{Table, TableRow}, world::unsafe_world_cell::UnsafeWorldCell, }; -use bevy_utils::tracing::error; use bevy_utils::HashMap; use core::marker::PhantomData; use disqualified::ShortName; +use tracing::error; /// A resource that stores the last tick an asset was changed. This is used by /// the [`AssetChanged`] filter to determine if an asset has changed since the last time diff --git a/crates/bevy_asset/src/io/android.rs b/crates/bevy_asset/src/io/android.rs index b8b78a9681..d8414a539f 100644 --- a/crates/bevy_asset/src/io/android.rs +++ b/crates/bevy_asset/src/io/android.rs @@ -1,7 +1,7 @@ use crate::io::{get_meta_path, AssetReader, AssetReaderError, PathStream, Reader, VecReader}; -use bevy_utils::tracing::error; use futures_lite::stream; use std::{ffi::CString, path::Path}; +use tracing::error; /// [`AssetReader`] implementation for Android devices, built on top of Android's [`AssetManager`]. /// diff --git a/crates/bevy_asset/src/io/embedded/embedded_watcher.rs b/crates/bevy_asset/src/io/embedded/embedded_watcher.rs index 2e62fb0813..d568aa6052 100644 --- a/crates/bevy_asset/src/io/embedded/embedded_watcher.rs +++ b/crates/bevy_asset/src/io/embedded/embedded_watcher.rs @@ -4,7 +4,7 @@ use crate::io::{ AssetSourceEvent, AssetWatcher, }; use alloc::sync::Arc; -use bevy_utils::{tracing::warn, HashMap}; +use bevy_utils::HashMap; use core::time::Duration; use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, RecommendedCache}; use parking_lot::RwLock; @@ -13,6 +13,7 @@ use std::{ io::{BufReader, Read}, path::{Path, PathBuf}, }; +use tracing::warn; /// A watcher for assets stored in the `embedded` asset source. Embedded assets are assets whose /// bytes have been embedded into the Rust binary using the [`embedded_asset`](crate::embedded_asset) macro. diff --git a/crates/bevy_asset/src/io/file/file_watcher.rs b/crates/bevy_asset/src/io/file/file_watcher.rs index e416b99971..80a36a8240 100644 --- a/crates/bevy_asset/src/io/file/file_watcher.rs +++ b/crates/bevy_asset/src/io/file/file_watcher.rs @@ -2,7 +2,6 @@ use crate::{ io::{AssetSourceEvent, AssetWatcher}, path::normalize_path, }; -use bevy_utils::tracing::error; use core::time::Duration; use crossbeam_channel::Sender; use notify_debouncer_full::{ @@ -15,6 +14,7 @@ use notify_debouncer_full::{ DebounceEventResult, Debouncer, RecommendedCache, }; use std::path::{Path, PathBuf}; +use tracing::error; /// An [`AssetWatcher`] that watches the filesystem for changes to asset files in a given root folder and emits [`AssetSourceEvent`] /// for each relevant change. This uses [`notify_debouncer_full`] to retrieve "debounced" filesystem events. diff --git a/crates/bevy_asset/src/io/file/mod.rs b/crates/bevy_asset/src/io/file/mod.rs index 83cc237c34..dc04349868 100644 --- a/crates/bevy_asset/src/io/file/mod.rs +++ b/crates/bevy_asset/src/io/file/mod.rs @@ -6,9 +6,9 @@ mod file_asset; #[cfg(not(feature = "multi_threaded"))] mod sync_file_asset; -use bevy_utils::tracing::{debug, error}; #[cfg(feature = "file_watcher")] pub use file_watcher::*; +use tracing::{debug, error}; use std::{ env, diff --git a/crates/bevy_asset/src/io/processor_gated.rs b/crates/bevy_asset/src/io/processor_gated.rs index 2179379070..1472e7ad13 100644 --- a/crates/bevy_asset/src/io/processor_gated.rs +++ b/crates/bevy_asset/src/io/processor_gated.rs @@ -5,10 +5,10 @@ use crate::{ }; use alloc::sync::Arc; use async_lock::RwLockReadGuardArc; -use bevy_utils::tracing::trace; use core::{pin::Pin, task::Poll}; use futures_io::AsyncRead; use std::path::Path; +use tracing::trace; use super::{AsyncSeekForward, ErasedAssetReader}; diff --git a/crates/bevy_asset/src/io/source.rs b/crates/bevy_asset/src/io/source.rs index da98deaa12..4b109a124f 100644 --- a/crates/bevy_asset/src/io/source.rs +++ b/crates/bevy_asset/src/io/source.rs @@ -5,12 +5,10 @@ use crate::{ use alloc::sync::Arc; use atomicow::CowArc; use bevy_ecs::system::Resource; -use bevy_utils::{ - tracing::{error, warn}, - HashMap, -}; +use bevy_utils::HashMap; use core::{fmt::Display, hash::Hash, time::Duration}; use thiserror::Error; +use tracing::{error, warn}; use super::{ErasedAssetReader, ErasedAssetWriter}; diff --git a/crates/bevy_asset/src/io/wasm.rs b/crates/bevy_asset/src/io/wasm.rs index 25a5d223cb..34e8d6a2cb 100644 --- a/crates/bevy_asset/src/io/wasm.rs +++ b/crates/bevy_asset/src/io/wasm.rs @@ -1,9 +1,9 @@ use crate::io::{ get_meta_path, AssetReader, AssetReaderError, EmptyPathStream, PathStream, Reader, VecReader, }; -use bevy_utils::tracing::error; use js_sys::{Uint8Array, JSON}; use std::path::{Path, PathBuf}; +use tracing::error; use wasm_bindgen::{prelude::wasm_bindgen, JsCast, JsValue}; use wasm_bindgen_futures::JsFuture; use web_sys::Response; diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index 7a3a06c389..bb34eed98c 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -215,8 +215,9 @@ use bevy_ecs::{ world::FromWorld, }; use bevy_reflect::{FromReflect, GetTypeRegistration, Reflect, TypePath}; -use bevy_utils::{tracing::error, HashSet}; +use bevy_utils::HashSet; use core::any::TypeId; +use tracing::error; #[cfg(all(feature = "file_watcher", not(feature = "multi_threaded")))] compile_error!( diff --git a/crates/bevy_asset/src/meta.rs b/crates/bevy_asset/src/meta.rs index bad3a4be72..e15de6dd0c 100644 --- a/crates/bevy_asset/src/meta.rs +++ b/crates/bevy_asset/src/meta.rs @@ -2,10 +2,10 @@ use crate::{ self as bevy_asset, loader::AssetLoader, processor::Process, Asset, AssetPath, DeserializeMetaError, VisitAssetDependencies, }; -use bevy_utils::tracing::error; use downcast_rs::{impl_downcast, Downcast}; use ron::ser::PrettyConfig; use serde::{Deserialize, Serialize}; +use tracing::error; pub const META_FORMAT_VERSION: &str = "1.0"; pub type MetaTransform = Box; diff --git a/crates/bevy_asset/src/processor/log.rs b/crates/bevy_asset/src/processor/log.rs index 2649b815d8..dbbab8a9ad 100644 --- a/crates/bevy_asset/src/processor/log.rs +++ b/crates/bevy_asset/src/processor/log.rs @@ -1,9 +1,10 @@ use crate::AssetPath; use async_fs::File; -use bevy_utils::{tracing::error, HashSet}; +use bevy_utils::HashSet; use futures_lite::{AsyncReadExt, AsyncWriteExt}; use std::path::PathBuf; use thiserror::Error; +use tracing::error; /// An in-memory representation of a single [`ProcessorTransactionLog`] entry. #[derive(Debug)] diff --git a/crates/bevy_asset/src/processor/mod.rs b/crates/bevy_asset/src/processor/mod.rs index 26bde8cd33..665ff7dd9e 100644 --- a/crates/bevy_asset/src/processor/mod.rs +++ b/crates/bevy_asset/src/processor/mod.rs @@ -61,17 +61,15 @@ use bevy_ecs::prelude::*; #[cfg(feature = "trace")] use bevy_tasks::ConditionalSendFuture; use bevy_tasks::IoTaskPool; -#[cfg(feature = "trace")] -use bevy_utils::tracing::{info_span, instrument::Instrument}; -use bevy_utils::{ - tracing::{debug, error, trace, warn}, - HashMap, HashSet, -}; +use bevy_utils::{HashMap, HashSet}; use futures_io::ErrorKind; use futures_lite::{AsyncReadExt, AsyncWriteExt, StreamExt}; use parking_lot::RwLock; use std::path::{Path, PathBuf}; use thiserror::Error; +use tracing::{debug, error, trace, warn}; +#[cfg(feature = "trace")] +use tracing::{info_span, instrument::Instrument}; /// A "background" asset processor that reads asset values from a source [`AssetSource`] (which corresponds to an [`AssetReader`](crate::io::AssetReader) / [`AssetWriter`](crate::io::AssetWriter) pair), /// processes them in some way, and writes them to a destination [`AssetSource`]. diff --git a/crates/bevy_asset/src/server/info.rs b/crates/bevy_asset/src/server/info.rs index 9b3edd5d8c..9e167ef354 100644 --- a/crates/bevy_asset/src/server/info.rs +++ b/crates/bevy_asset/src/server/info.rs @@ -7,11 +7,12 @@ use crate::{ use alloc::sync::{Arc, Weak}; use bevy_ecs::world::World; use bevy_tasks::Task; -use bevy_utils::{tracing::warn, Entry, HashMap, HashSet, TypeIdMap}; +use bevy_utils::{Entry, HashMap, HashSet, TypeIdMap}; use core::{any::TypeId, task::Waker}; use crossbeam_channel::Sender; use either::Either; use thiserror::Error; +use tracing::warn; #[derive(Debug)] pub(crate) struct AssetInfo { diff --git a/crates/bevy_asset/src/server/loaders.rs b/crates/bevy_asset/src/server/loaders.rs index 007dea47b0..e4be0841cf 100644 --- a/crates/bevy_asset/src/server/loaders.rs +++ b/crates/bevy_asset/src/server/loaders.rs @@ -7,11 +7,12 @@ use async_broadcast::RecvError; #[cfg(feature = "trace")] use bevy_tasks::ConditionalSendFuture; use bevy_tasks::IoTaskPool; -#[cfg(feature = "trace")] -use bevy_utils::tracing::{info_span, instrument::Instrument}; -use bevy_utils::{tracing::warn, HashMap, TypeIdMap}; +use bevy_utils::{HashMap, TypeIdMap}; use core::any::TypeId; use thiserror::Error; +use tracing::warn; +#[cfg(feature = "trace")] +use tracing::{info_span, instrument::Instrument}; #[derive(Default)] pub(crate) struct AssetLoaders { diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index 0270aefc66..af751c3a12 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -21,10 +21,7 @@ use alloc::sync::Arc; use atomicow::CowArc; use bevy_ecs::prelude::*; use bevy_tasks::IoTaskPool; -use bevy_utils::{ - tracing::{error, info}, - HashSet, -}; +use bevy_utils::HashSet; use core::{any::TypeId, future::Future, panic::AssertUnwindSafe, task::Poll}; use crossbeam_channel::{Receiver, Sender}; use either::Either; @@ -34,6 +31,7 @@ use loaders::*; use parking_lot::{RwLock, RwLockWriteGuard}; use std::path::{Path, PathBuf}; use thiserror::Error; +use tracing::{error, info}; /// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). This can be used to kick off new asset loads and /// retrieve their current load states. diff --git a/crates/bevy_audio/Cargo.toml b/crates/bevy_audio/Cargo.toml index 7df10a1bcb..757581154f 100644 --- a/crates/bevy_audio/Cargo.toml +++ b/crates/bevy_audio/Cargo.toml @@ -20,10 +20,10 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [ ] } bevy_transform = { path = "../bevy_transform", version = "0.15.0-dev" } bevy_derive = { path = "../bevy_derive", version = "0.15.0-dev" } -bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } # other rodio = { version = "0.20", default-features = false } +tracing = { version = "0.1", default-features = false, features = ["std"] } [target.'cfg(target_os = "android")'.dependencies] cpal = { version = "0.15", optional = true } diff --git a/crates/bevy_audio/src/audio_output.rs b/crates/bevy_audio/src/audio_output.rs index ee65eaf01f..90bdc38499 100644 --- a/crates/bevy_audio/src/audio_output.rs +++ b/crates/bevy_audio/src/audio_output.rs @@ -7,8 +7,8 @@ use bevy_ecs::{prelude::*, system::SystemParam}; use bevy_hierarchy::DespawnRecursiveExt; use bevy_math::Vec3; use bevy_transform::prelude::GlobalTransform; -use bevy_utils::tracing::warn; use rodio::{OutputStream, OutputStreamHandle, Sink, Source, SpatialSink}; +use tracing::warn; use crate::{AudioSink, AudioSinkPlayback}; diff --git a/crates/bevy_core_pipeline/Cargo.toml b/crates/bevy_core_pipeline/Cargo.toml index 3993b031e9..467cfe1e17 100644 --- a/crates/bevy_core_pipeline/Cargo.toml +++ b/crates/bevy_core_pipeline/Cargo.toml @@ -42,6 +42,7 @@ radsort = "0.1" nonmax = "0.5" smallvec = "1" thiserror = { version = "2", default-features = false } +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_core_pipeline/src/core_2d/main_opaque_pass_2d_node.rs b/crates/bevy_core_pipeline/src/core_2d/main_opaque_pass_2d_node.rs index 91093d0da5..d30ae71c64 100644 --- a/crates/bevy_core_pipeline/src/core_2d/main_opaque_pass_2d_node.rs +++ b/crates/bevy_core_pipeline/src/core_2d/main_opaque_pass_2d_node.rs @@ -9,9 +9,9 @@ use bevy_render::{ renderer::RenderContext, view::{ViewDepthTexture, ViewTarget}, }; -use bevy_utils::tracing::error; +use tracing::error; #[cfg(feature = "trace")] -use bevy_utils::tracing::info_span; +use tracing::info_span; use super::AlphaMask2d; diff --git a/crates/bevy_core_pipeline/src/core_2d/main_transparent_pass_2d_node.rs b/crates/bevy_core_pipeline/src/core_2d/main_transparent_pass_2d_node.rs index e365be9547..abd26dfce2 100644 --- a/crates/bevy_core_pipeline/src/core_2d/main_transparent_pass_2d_node.rs +++ b/crates/bevy_core_pipeline/src/core_2d/main_transparent_pass_2d_node.rs @@ -9,9 +9,9 @@ use bevy_render::{ renderer::RenderContext, view::{ViewDepthTexture, ViewTarget}, }; -use bevy_utils::tracing::error; +use tracing::error; #[cfg(feature = "trace")] -use bevy_utils::tracing::info_span; +use tracing::info_span; #[derive(Default)] pub struct MainTransparentPass2dNode {} diff --git a/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs index b51f363543..7fe338f421 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs @@ -12,9 +12,9 @@ use bevy_render::{ renderer::RenderContext, view::{ViewDepthTexture, ViewTarget, ViewUniformOffset}, }; -use bevy_utils::tracing::error; +use tracing::error; #[cfg(feature = "trace")] -use bevy_utils::tracing::info_span; +use tracing::info_span; use super::AlphaMask3d; diff --git a/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs index 225ce81da6..7255180323 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs @@ -9,10 +9,10 @@ use bevy_render::{ renderer::RenderContext, view::{ViewDepthTexture, ViewTarget}, }; -use bevy_utils::tracing::error; -#[cfg(feature = "trace")] -use bevy_utils::tracing::info_span; use core::ops::Range; +use tracing::error; +#[cfg(feature = "trace")] +use tracing::info_span; /// A [`bevy_render::render_graph::Node`] that runs the [`Transmissive3d`] /// [`ViewSortedRenderPhases`]. diff --git a/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs index 4f0d3d0722..719a7ae536 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs @@ -9,9 +9,9 @@ use bevy_render::{ renderer::RenderContext, view::{ViewDepthTexture, ViewTarget}, }; -use bevy_utils::tracing::error; +use tracing::error; #[cfg(feature = "trace")] -use bevy_utils::tracing::info_span; +use tracing::info_span; /// A [`bevy_render::render_graph::Node`] that runs the [`Transparent3d`] /// [`ViewSortedRenderPhases`]. diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index f70ad13914..7d2c11c0c2 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -101,8 +101,9 @@ use bevy_render::{ view::{ExtractedView, ViewDepthTexture, ViewTarget}, Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; -use bevy_utils::{tracing::warn, HashMap}; +use bevy_utils::HashMap; use nonmax::NonMaxU32; +use tracing::warn; use crate::{ core_3d::main_transmissive_pass_3d_node::MainTransmissivePass3dNode, diff --git a/crates/bevy_core_pipeline/src/deferred/node.rs b/crates/bevy_core_pipeline/src/deferred/node.rs index 5aa89a8e94..16704b647f 100644 --- a/crates/bevy_core_pipeline/src/deferred/node.rs +++ b/crates/bevy_core_pipeline/src/deferred/node.rs @@ -9,9 +9,9 @@ use bevy_render::{ renderer::RenderContext, view::ViewDepthTexture, }; -use bevy_utils::tracing::error; +use tracing::error; #[cfg(feature = "trace")] -use bevy_utils::tracing::info_span; +use tracing::info_span; use crate::prepass::ViewPrepassTextures; diff --git a/crates/bevy_core_pipeline/src/dof/mod.rs b/crates/bevy_core_pipeline/src/dof/mod.rs index 88e25e75c2..ca5eac082b 100644 --- a/crates/bevy_core_pipeline/src/dof/mod.rs +++ b/crates/bevy_core_pipeline/src/dof/mod.rs @@ -56,8 +56,9 @@ use bevy_render::{ }, Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; -use bevy_utils::{info_once, prelude::default, warn_once}; +use bevy_utils::{default, once}; use smallvec::SmallVec; +use tracing::{info, warn}; use crate::{ core_3d::{ @@ -381,7 +382,9 @@ impl ViewNode for DepthOfFieldNode { auxiliary_dof_texture, view_bind_group_layouts.dual_input.as_ref(), ) else { - warn_once!("Should have created the auxiliary depth of field texture by now"); + once!(warn!( + "Should have created the auxiliary depth of field texture by now" + )); continue; }; render_context.render_device().create_bind_group( @@ -423,7 +426,9 @@ impl ViewNode for DepthOfFieldNode { // `prepare_auxiliary_depth_of_field_textures``. if pipeline_render_info.is_dual_output { let Some(auxiliary_dof_texture) = auxiliary_dof_texture else { - warn_once!("Should have created the auxiliary depth of field texture by now"); + once!(warn!( + "Should have created the auxiliary depth of field texture by now" + )); continue; }; color_attachments.push(Some(RenderPassColorAttachment { @@ -815,9 +820,9 @@ fn extract_depth_of_field_settings( mut query: Extract>, ) { if !DEPTH_TEXTURE_SAMPLING_SUPPORTED { - info_once!( + once!(info!( "Disabling depth of field on this platform because depth textures aren't supported correctly" - ); + )); return; } diff --git a/crates/bevy_core_pipeline/src/oit/mod.rs b/crates/bevy_core_pipeline/src/oit/mod.rs index 14e8b8d4e3..7550f9aae8 100644 --- a/crates/bevy_core_pipeline/src/oit/mod.rs +++ b/crates/bevy_core_pipeline/src/oit/mod.rs @@ -16,15 +16,13 @@ use bevy_render::{ view::Msaa, Render, RenderApp, RenderSet, }; -use bevy_utils::{ - tracing::{trace, warn}, - HashSet, Instant, -}; +use bevy_utils::{HashSet, Instant}; use bevy_window::PrimaryWindow; use resolve::{ node::{OitResolveNode, OitResolvePass}, OitResolvePlugin, }; +use tracing::{trace, warn}; use crate::core_3d::{ graph::{Core3d, Node3d}, diff --git a/crates/bevy_core_pipeline/src/oit/resolve/mod.rs b/crates/bevy_core_pipeline/src/oit/resolve/mod.rs index 101f7b1ed9..ef8f87e1c8 100644 --- a/crates/bevy_core_pipeline/src/oit/resolve/mod.rs +++ b/crates/bevy_core_pipeline/src/oit/resolve/mod.rs @@ -22,7 +22,7 @@ use bevy_render::{ view::{ExtractedView, ViewTarget, ViewUniform, ViewUniforms}, Render, RenderApp, RenderSet, }; -use bevy_utils::tracing::warn; +use tracing::warn; use super::OitBuffers; diff --git a/crates/bevy_core_pipeline/src/prepass/node.rs b/crates/bevy_core_pipeline/src/prepass/node.rs index 17f5dfb2cf..c61663c198 100644 --- a/crates/bevy_core_pipeline/src/prepass/node.rs +++ b/crates/bevy_core_pipeline/src/prepass/node.rs @@ -8,9 +8,9 @@ use bevy_render::{ renderer::RenderContext, view::{ViewDepthTexture, ViewUniformOffset}, }; -use bevy_utils::tracing::error; +use tracing::error; #[cfg(feature = "trace")] -use bevy_utils::tracing::info_span; +use tracing::info_span; use crate::skybox::prepass::{RenderSkyboxPrepassPipeline, SkyboxPrepassBindGroup}; diff --git a/crates/bevy_core_pipeline/src/taa/mod.rs b/crates/bevy_core_pipeline/src/taa/mod.rs index 7698a15623..aadc26cbc6 100644 --- a/crates/bevy_core_pipeline/src/taa/mod.rs +++ b/crates/bevy_core_pipeline/src/taa/mod.rs @@ -37,7 +37,7 @@ use bevy_render::{ view::{ExtractedView, Msaa, ViewTarget}, ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, }; -use bevy_utils::tracing::warn; +use tracing::warn; const TAA_SHADER_HANDLE: Handle = Handle::weak_from_u128(656865235226276); diff --git a/crates/bevy_core_pipeline/src/tonemapping/mod.rs b/crates/bevy_core_pipeline/src/tonemapping/mod.rs index c6fb321725..bfc89cc645 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/mod.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/mod.rs @@ -18,9 +18,9 @@ use bevy_render::{ view::{ExtractedView, ViewTarget, ViewUniform}, Render, RenderApp, RenderSet, }; -#[cfg(not(feature = "tonemapping_luts"))] -use bevy_utils::tracing::error; use bitflags::bitflags; +#[cfg(not(feature = "tonemapping_luts"))] +use tracing::error; mod node; diff --git a/crates/bevy_dev_tools/Cargo.toml b/crates/bevy_dev_tools/Cargo.toml index 1d426853ce..7dfa630ff9 100644 --- a/crates/bevy_dev_tools/Cargo.toml +++ b/crates/bevy_dev_tools/Cargo.toml @@ -24,13 +24,13 @@ bevy_render = { path = "../bevy_render", version = "0.15.0-dev" } bevy_time = { path = "../bevy_time", version = "0.15.0-dev" } bevy_text = { path = "../bevy_text", version = "0.15.0-dev" } bevy_ui = { path = "../bevy_ui", version = "0.15.0-dev" } -bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } bevy_window = { path = "../bevy_window", version = "0.15.0-dev" } bevy_state = { path = "../bevy_state", version = "0.15.0-dev" } # other serde = { version = "1.0", features = ["derive"], optional = true } ron = { version = "0.8.0", optional = true } +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_dev_tools/src/ci_testing/systems.rs b/crates/bevy_dev_tools/src/ci_testing/systems.rs index 20c758a91c..70991fc2ac 100644 --- a/crates/bevy_dev_tools/src/ci_testing/systems.rs +++ b/crates/bevy_dev_tools/src/ci_testing/systems.rs @@ -2,7 +2,7 @@ use super::config::*; use bevy_app::AppExit; use bevy_ecs::prelude::*; use bevy_render::view::screenshot::{save_to_disk, Screenshot}; -use bevy_utils::tracing::{debug, info}; +use tracing::{debug, info}; pub(crate) fn send_events(world: &mut World, mut current_frame: Local) { let mut config = world.resource_mut::(); diff --git a/crates/bevy_dev_tools/src/fps_overlay.rs b/crates/bevy_dev_tools/src/fps_overlay.rs index f970fc8f43..23b21256cc 100644 --- a/crates/bevy_dev_tools/src/fps_overlay.rs +++ b/crates/bevy_dev_tools/src/fps_overlay.rs @@ -19,7 +19,6 @@ use bevy_ui::{ widget::{Text, TextUiWriter}, GlobalZIndex, Node, PositionType, }; -use bevy_utils::default; /// [`GlobalZIndex`] used to render the fps overlay. /// @@ -74,7 +73,7 @@ impl Default for FpsOverlayConfig { text_config: TextFont { font: Handle::::default(), font_size: 32.0, - ..default() + ..Default::default() }, text_color: Color::WHITE, enabled: true, @@ -91,7 +90,7 @@ fn setup(mut commands: Commands, overlay_config: Res) { Node { // We need to make sure the overlay doesn't affect the position of other UI nodes position_type: PositionType::Absolute, - ..default() + ..Default::default() }, // Render overlay on top of everything GlobalZIndex(FPS_OVERLAY_ZINDEX), diff --git a/crates/bevy_dev_tools/src/states.rs b/crates/bevy_dev_tools/src/states.rs index 21d5aedc03..8e43f80844 100644 --- a/crates/bevy_dev_tools/src/states.rs +++ b/crates/bevy_dev_tools/src/states.rs @@ -2,7 +2,7 @@ use bevy_ecs::event::EventReader; use bevy_state::state::{StateTransitionEvent, States}; -use bevy_utils::tracing::info; +use tracing::info; /// Logs state transitions into console. /// diff --git a/crates/bevy_diagnostic/Cargo.toml b/crates/bevy_diagnostic/Cargo.toml index 5d45853997..cf1852e05f 100644 --- a/crates/bevy_diagnostic/Cargo.toml +++ b/crates/bevy_diagnostic/Cargo.toml @@ -22,8 +22,10 @@ bevy_time = { path = "../bevy_time", version = "0.15.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } bevy_tasks = { path = "../bevy_tasks", version = "0.15.0-dev" } +# other const-fnv1a-hash = "1.1.0" serde = { version = "1.0", optional = true } +tracing = { version = "0.1", default-features = false, features = ["std"] } # macOS [target.'cfg(all(target_os="macos"))'.dependencies] diff --git a/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs index 6e53bf0a31..bf53fe520c 100644 --- a/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs @@ -2,8 +2,8 @@ use super::{Diagnostic, DiagnosticPath, DiagnosticsStore}; use bevy_app::prelude::*; use bevy_ecs::prelude::*; use bevy_time::{Real, Time, Timer, TimerMode}; -use bevy_utils::tracing::{debug, info}; use core::time::Duration; +use tracing::{debug, info}; /// An App Plugin that logs diagnostics to the console. /// diff --git a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs index 44e4d4698b..cd390506ce 100644 --- a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs @@ -66,8 +66,8 @@ pub mod internal { use bevy_app::{App, First, Startup, Update}; use bevy_ecs::system::Resource; use bevy_tasks::{available_parallelism, block_on, poll_once, AsyncComputeTaskPool, Task}; - use bevy_utils::tracing::info; use sysinfo::{CpuRefreshKind, MemoryRefreshKind, RefreshKind, System}; + use tracing::info; use crate::{Diagnostic, Diagnostics, DiagnosticsStore}; @@ -210,7 +210,7 @@ pub mod internal { } fn setup_system() { - bevy_utils::tracing::warn!("This platform and/or configuration is not supported!"); + tracing::warn!("This platform and/or configuration is not supported!"); } impl Default for super::SystemInfo { diff --git a/crates/bevy_ecs/Cargo.toml b/crates/bevy_ecs/Cargo.toml index 40b4fad7ec..ebf0df5234 100644 --- a/crates/bevy_ecs/Cargo.toml +++ b/crates/bevy_ecs/Cargo.toml @@ -32,7 +32,7 @@ reflect_functions = ["bevy_reflect", "bevy_reflect/functions"] ## Enables `tracing` integration, allowing spans and other metrics to be reported ## through that framework. -trace = ["std", "dep:tracing", "bevy_utils/tracing"] +trace = ["std", "dep:tracing"] ## Enables a more detailed set of traces which may be noisy if left on by default. detailed_trace = ["trace"] diff --git a/crates/bevy_ecs/src/query/state.rs b/crates/bevy_ecs/src/query/state.rs index 09c7f12e00..8eceb2ef9c 100644 --- a/crates/bevy_ecs/src/query/state.rs +++ b/crates/bevy_ecs/src/query/state.rs @@ -13,11 +13,11 @@ use crate::{ }; use alloc::vec::Vec; -#[cfg(feature = "trace")] -use bevy_utils::tracing::Span; use core::{fmt, mem::MaybeUninit, ptr}; use fixedbitset::FixedBitSet; use log::warn; +#[cfg(feature = "trace")] +use tracing::Span; use super::{ NopWorldQuery, QueryBuilder, QueryData, QueryEntityError, QueryFilter, QueryManyIter, diff --git a/crates/bevy_gilrs/Cargo.toml b/crates/bevy_gilrs/Cargo.toml index cd20696e77..92a46a0fc6 100644 --- a/crates/bevy_gilrs/Cargo.toml +++ b/crates/bevy_gilrs/Cargo.toml @@ -19,6 +19,7 @@ bevy_time = { path = "../bevy_time", version = "0.15.0-dev" } # other gilrs = "0.11.0" thiserror = { version = "2", default-features = false } +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs index f9e9bc8dfd..b8d83adbf3 100644 --- a/crates/bevy_gilrs/src/lib.rs +++ b/crates/bevy_gilrs/src/lib.rs @@ -18,10 +18,11 @@ use bevy_app::{App, Plugin, PostUpdate, PreStartup, PreUpdate}; use bevy_ecs::entity::EntityHashMap; use bevy_ecs::prelude::*; use bevy_input::InputSystem; -use bevy_utils::{synccell::SyncCell, tracing::error, HashMap}; +use bevy_utils::{synccell::SyncCell, HashMap}; use gilrs::GilrsBuilder; use gilrs_system::{gilrs_event_startup_system, gilrs_event_system}; use rumble::{play_gilrs_rumble, RunningRumbleEffects}; +use tracing::error; #[cfg_attr(not(target_arch = "wasm32"), derive(Resource))] pub(crate) struct Gilrs(pub SyncCell); diff --git a/crates/bevy_gilrs/src/rumble.rs b/crates/bevy_gilrs/src/rumble.rs index da1ce2e2bb..bc18aec18b 100644 --- a/crates/bevy_gilrs/src/rumble.rs +++ b/crates/bevy_gilrs/src/rumble.rs @@ -5,17 +5,14 @@ use bevy_ecs::prelude::{EventReader, Res, ResMut, Resource}; use bevy_ecs::system::NonSendMut; use bevy_input::gamepad::{GamepadRumbleIntensity, GamepadRumbleRequest}; use bevy_time::{Real, Time}; -use bevy_utils::{ - synccell::SyncCell, - tracing::{debug, warn}, - HashMap, -}; +use bevy_utils::{synccell::SyncCell, HashMap}; use core::time::Duration; use gilrs::{ ff::{self, BaseEffect, BaseEffectType, Repeat, Replay}, GamepadId, }; use thiserror::Error; +use tracing::{debug, warn}; /// A rumble effect that is currently in effect. struct RunningRumble { diff --git a/crates/bevy_gizmos/Cargo.toml b/crates/bevy_gizmos/Cargo.toml index e880e985ff..2d9f12a4e3 100644 --- a/crates/bevy_gizmos/Cargo.toml +++ b/crates/bevy_gizmos/Cargo.toml @@ -31,7 +31,9 @@ bevy_transform = { path = "../bevy_transform", version = "0.15.0-dev" } bevy_gizmos_macros = { path = "macros", version = "0.15.0-dev" } bevy_time = { path = "../bevy_time", version = "0.15.0-dev" } +# other bytemuck = "1.0" +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index 242f19bc6b..a7bca0769a 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -189,16 +189,16 @@ impl Plugin for GizmoPlugin { if app.is_plugin_added::() { app.add_plugins(pipeline_2d::LineGizmo2dPlugin); } else { - bevy_utils::tracing::warn!("bevy_sprite feature is enabled but bevy_sprite::SpritePlugin was not detected. Are you sure you loaded GizmoPlugin after SpritePlugin?"); + tracing::warn!("bevy_sprite feature is enabled but bevy_sprite::SpritePlugin was not detected. Are you sure you loaded GizmoPlugin after SpritePlugin?"); } #[cfg(feature = "bevy_pbr")] if app.is_plugin_added::() { app.add_plugins(pipeline_3d::LineGizmo3dPlugin); } else { - bevy_utils::tracing::warn!("bevy_pbr feature is enabled but bevy_pbr::PbrPlugin was not detected. Are you sure you loaded GizmoPlugin after PbrPlugin?"); + tracing::warn!("bevy_pbr feature is enabled but bevy_pbr::PbrPlugin was not detected. Are you sure you loaded GizmoPlugin after PbrPlugin?"); } } else { - bevy_utils::tracing::warn!("bevy_render feature is enabled but RenderApp was not detected. Are you sure you loaded GizmoPlugin after RenderPlugin?"); + tracing::warn!("bevy_render feature is enabled but RenderApp was not detected. Are you sure you loaded GizmoPlugin after RenderPlugin?"); } } @@ -419,8 +419,9 @@ fn extract_gizmo_data( handles: Extract>, config: Extract>, ) { - use bevy_utils::warn_once; + use bevy_utils::once; use config::GizmoLineStyle; + use tracing::warn; for (group_type_id, handle) in &handles.handles { let Some((config, _)) = config.get_config_dyn(group_type_id) else { @@ -447,10 +448,10 @@ fn extract_gizmo_data( } = config.line.style { if gap_scale <= 0.0 { - warn_once!("When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero."); + once!(warn!("When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero.")); } if line_scale <= 0.0 { - warn_once!("When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero."); + once!(warn!("When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero.")); } (gap_scale, line_scale) } else { diff --git a/crates/bevy_gizmos/src/pipeline_2d.rs b/crates/bevy_gizmos/src/pipeline_2d.rs index d2e17a680c..1e85602d62 100644 --- a/crates/bevy_gizmos/src/pipeline_2d.rs +++ b/crates/bevy_gizmos/src/pipeline_2d.rs @@ -27,7 +27,7 @@ use bevy_render::{ Render, RenderApp, RenderSet, }; use bevy_sprite::{Mesh2dPipeline, Mesh2dPipelineKey, SetMesh2dViewBindGroup}; -use bevy_utils::tracing::error; +use tracing::error; pub struct LineGizmo2dPlugin; diff --git a/crates/bevy_gizmos/src/pipeline_3d.rs b/crates/bevy_gizmos/src/pipeline_3d.rs index 49d00b3343..a36e5c55a3 100644 --- a/crates/bevy_gizmos/src/pipeline_3d.rs +++ b/crates/bevy_gizmos/src/pipeline_3d.rs @@ -30,7 +30,7 @@ use bevy_render::{ view::{ExtractedView, Msaa, RenderLayers, ViewTarget}, Render, RenderApp, RenderSet, }; -use bevy_utils::tracing::error; +use tracing::error; pub struct LineGizmo3dPlugin; impl Plugin for LineGizmo3dPlugin { diff --git a/crates/bevy_gizmos/src/retained.rs b/crates/bevy_gizmos/src/retained.rs index 9cb6791aca..435f417552 100644 --- a/crates/bevy_gizmos/src/retained.rs +++ b/crates/bevy_gizmos/src/retained.rs @@ -106,7 +106,8 @@ pub(crate) fn extract_linegizmos( ) { use bevy_math::Affine3; use bevy_render::sync_world::{MainEntity, TemporaryRenderEntity}; - use bevy_utils::warn_once; + use bevy_utils::once; + use tracing::warn; use crate::config::GizmoLineStyle; @@ -124,10 +125,10 @@ pub(crate) fn extract_linegizmos( } = gizmo.line_config.style { if gap_scale <= 0.0 { - warn_once!("when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero"); + once!(warn!("when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero")); } if line_scale <= 0.0 { - warn_once!("when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero"); + once!(warn!("when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero")); } (gap_scale, line_scale) } else { diff --git a/crates/bevy_gltf/Cargo.toml b/crates/bevy_gltf/Cargo.toml index 9bc1ca3e7d..1d52ca097a 100644 --- a/crates/bevy_gltf/Cargo.toml +++ b/crates/bevy_gltf/Cargo.toml @@ -59,6 +59,7 @@ percent-encoding = "2.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1" smallvec = "1.11" +tracing = { version = "0.1", default-features = false, features = ["std"] } [dev-dependencies] bevy_log = { path = "../bevy_log", version = "0.15.0-dev" } diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 116ecb23c3..6eb3198c29 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -41,10 +41,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}, - HashMap, HashSet, -}; +use bevy_utils::{HashMap, HashSet}; use gltf::{ accessor::Iter, image::Source, @@ -60,6 +57,7 @@ use std::{ path::{Path, PathBuf}, }; use thiserror::Error; +use tracing::{error, info_span, warn}; #[cfg(feature = "bevy_animation")] use { bevy_animation::{prelude::*, AnimationTarget, AnimationTargetId}, @@ -704,17 +702,15 @@ async fn load_gltf<'a, 'b, 'c>( if mesh.attribute(Mesh::ATTRIBUTE_NORMAL).is_none() && matches!(mesh.primitive_topology(), PrimitiveTopology::TriangleList) { - bevy_utils::tracing::debug!( - "Automatically calculating missing vertex normals for geometry." - ); + tracing::debug!("Automatically calculating missing vertex normals for geometry."); let vertex_count_before = mesh.count_vertices(); mesh.duplicate_vertices(); mesh.compute_flat_normals(); let vertex_count_after = mesh.count_vertices(); if 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); + 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_utils::tracing::debug!( + tracing::debug!( "Missing vertex normals in indexed geometry, computing them as flat." ); } @@ -728,7 +724,7 @@ async fn load_gltf<'a, 'b, 'c>( } else if mesh.attribute(Mesh::ATTRIBUTE_NORMAL).is_some() && material_needs_tangents(&primitive.material()) { - bevy_utils::tracing::debug!( + 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 ); diff --git a/crates/bevy_image/Cargo.toml b/crates/bevy_image/Cargo.toml index df033d64d6..7ca9166b52 100644 --- a/crates/bevy_image/Cargo.toml +++ b/crates/bevy_image/Cargo.toml @@ -62,6 +62,7 @@ flate2 = { version = "1.0.22", optional = true } ruzstd = { version = "0.7.0", optional = true } # For transcoding of UASTC/ETC1S universal formats, and for .basis file support basis-universal = { version = "0.3.0", optional = true } +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_image/src/dds.rs b/crates/bevy_image/src/dds.rs index f36ec25894..ffb3ce2c7c 100644 --- a/crates/bevy_image/src/dds.rs +++ b/crates/bevy_image/src/dds.rs @@ -1,11 +1,11 @@ //! [DirectDraw Surface](https://en.wikipedia.org/wiki/DirectDraw_Surface) functionality. -#[cfg(debug_assertions)] -use bevy_utils::warn_once; use ddsfile::{Caps2, D3DFormat, Dds, DxgiFormat}; use std::io::Cursor; use wgpu::TextureViewDescriptor; use wgpu_types::{Extent3d, TextureDimension, TextureFormat, TextureViewDimension}; +#[cfg(debug_assertions)] +use {bevy_utils::once, tracing::warn}; use super::{CompressedImageFormats, Image, TextureError}; @@ -53,10 +53,10 @@ pub fn dds_buffer_to_image( let mip_map_level = match dds.get_num_mipmap_levels() { 0 => { #[cfg(debug_assertions)] - warn_once!( + once!(warn!( "Mipmap levels for texture {} are 0, bumping them to 1", name - ); + )); 1 } t => t, diff --git a/crates/bevy_image/src/image.rs b/crates/bevy_image/src/image.rs index d9f02379f4..cbe678b96b 100644 --- a/crates/bevy_image/src/image.rs +++ b/crates/bevy_image/src/image.rs @@ -72,7 +72,7 @@ macro_rules! feature_gate { ($feature: tt, $value: ident) => {{ #[cfg(not(feature = $feature))] { - bevy_utils::tracing::warn!("feature \"{}\" is not enabled", $feature); + tracing::warn!("feature \"{}\" is not enabled", $feature); return None; } #[cfg(feature = $feature)] diff --git a/crates/bevy_input_focus/Cargo.toml b/crates/bevy_input_focus/Cargo.toml index ed86ecdec0..d9f4bc6864 100644 --- a/crates/bevy_input_focus/Cargo.toml +++ b/crates/bevy_input_focus/Cargo.toml @@ -10,14 +10,16 @@ keywords = ["bevy"] rust-version = "1.83.0" [dependencies] +# bevy bevy_app = { path = "../bevy_app", version = "0.15.0-dev", default-features = false } bevy_ecs = { path = "../bevy_ecs", version = "0.15.0-dev", default-features = false } bevy_input = { path = "../bevy_input", version = "0.15.0-dev", default-features = false } bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.15.0-dev", default-features = false } -bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev", default-features = false } bevy_window = { path = "../bevy_window", version = "0.15.0-dev", default-features = false } +# other thiserror = { version = "2", default-features = false } +tracing = { version = "0.1", default-features = false, features = ["std"] } [dev-dependencies] smol_str = "0.2" diff --git a/crates/bevy_input_focus/src/tab_navigation.rs b/crates/bevy_input_focus/src/tab_navigation.rs index d47744a357..6af9dede58 100644 --- a/crates/bevy_input_focus/src/tab_navigation.rs +++ b/crates/bevy_input_focus/src/tab_navigation.rs @@ -36,9 +36,9 @@ use bevy_input::{ keyboard::{KeyCode, KeyboardInput}, ButtonInput, ButtonState, }; -use bevy_utils::tracing::warn; use bevy_window::PrimaryWindow; use thiserror::Error; +use tracing::warn; use crate::{FocusedInput, InputFocus, InputFocusVisible}; diff --git a/crates/bevy_log/Cargo.toml b/crates/bevy_log/Cargo.toml index 173d13e6ba..7663e58d33 100644 --- a/crates/bevy_log/Cargo.toml +++ b/crates/bevy_log/Cargo.toml @@ -13,10 +13,12 @@ trace = ["tracing-error"] trace_tracy_memory = ["dep:tracy-client"] [dependencies] +# bevy bevy_app = { path = "../bevy_app", version = "0.15.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.15.0-dev" } +# other tracing-subscriber = { version = "0.3.1", features = [ "registry", "env-filter", @@ -24,6 +26,7 @@ tracing-subscriber = { version = "0.3.1", features = [ tracing-chrome = { version = "0.7.0", optional = true } tracing-log = "0.2.0" tracing-error = { version = "0.2.0", optional = true } +tracing = { version = "0.1", default-features = false, features = ["std"] } # Tracy dependency compatibility table: # https://github.com/nagisa/rust_tracy_client diff --git a/crates/bevy_log/src/android_tracing.rs b/crates/bevy_log/src/android_tracing.rs index 3b6649feaf..ba0b3b7a27 100644 --- a/crates/bevy_log/src/android_tracing.rs +++ b/crates/bevy_log/src/android_tracing.rs @@ -1,10 +1,10 @@ use alloc::ffi::CString; -use bevy_utils::tracing::{ +use core::fmt::{Debug, Write}; +use tracing::{ field::Field, span::{Attributes, Record}, Event, Id, Level, Subscriber, }; -use core::fmt::{Debug, Write}; use tracing_subscriber::{field::Visit, layer::Context, registry::LookupSpan, Layer}; #[derive(Default)] diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index 29ecc83109..8328744e5b 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -22,6 +22,7 @@ use core::error::Error; #[cfg(target_os = "android")] mod android_tracing; +mod once; #[cfg(feature = "trace_tracy_memory")] #[global_allocator] @@ -33,21 +34,21 @@ static GLOBAL: tracy_client::ProfiledAllocator = /// This includes the most common types in this crate, re-exported for your convenience. pub mod prelude { #[doc(hidden)] - pub use bevy_utils::tracing::{ + pub use tracing::{ debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span, }; #[doc(hidden)] - pub use bevy_utils::{debug_once, error_once, info_once, once, trace_once, warn_once}; + pub use crate::{debug_once, error_once, info_once, trace_once, warn_once}; + + #[doc(hidden)] + pub use bevy_utils::once; } -pub use bevy_utils::{ - debug_once, error_once, info_once, once, trace_once, - tracing::{ - debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span, - Level, - }, - warn_once, +pub use bevy_utils::once; +pub use tracing::{ + self, debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, + warn_span, Level, }; pub use tracing_subscriber; @@ -89,7 +90,7 @@ pub(crate) struct FlushGuard(SyncCell); /// ```no_run /// # use bevy_app::{App, NoopPluginGroup as DefaultPlugins, PluginGroup}; /// # use bevy_log::LogPlugin; -/// # use bevy_utils::tracing::Level; +/// # use tracing::Level; /// fn main() { /// App::new() /// .add_plugins(DefaultPlugins.set(LogPlugin { @@ -232,7 +233,7 @@ pub struct LogPlugin { /// Because [`BoxedLayer`] takes a `dyn Layer`, `Vec` is also an acceptable return value. /// /// Access to [`App`] is also provided to allow for communication between the - /// [`Subscriber`](bevy_utils::tracing::Subscriber) and the [`App`]. + /// [`Subscriber`](tracing::Subscriber) and the [`App`]. /// /// Please see the `examples/log_layers.rs` for a complete example. pub custom_layer: fn(app: &mut App) -> Option, @@ -364,7 +365,7 @@ impl Plugin for LogPlugin { let logger_already_set = LogTracer::init().is_err(); let subscriber_already_set = - bevy_utils::tracing::subscriber::set_global_default(finished_subscriber).is_err(); + tracing::subscriber::set_global_default(finished_subscriber).is_err(); match (logger_already_set, subscriber_already_set) { (true, true) => error!( diff --git a/crates/bevy_log/src/once.rs b/crates/bevy_log/src/once.rs new file mode 100644 index 0000000000..ad53b62c6c --- /dev/null +++ b/crates/bevy_log/src/once.rs @@ -0,0 +1,49 @@ +/// Call [`trace!`](crate::trace) once per call site. +/// +/// Useful for logging within systems which are called every frame. +#[macro_export] +macro_rules! trace_once { + ($($arg:tt)+) => ({ + $crate::once!($crate::trace!($($arg)+)) + }); +} + +/// Call [`debug!`](crate::debug) once per call site. +/// +/// Useful for logging within systems which are called every frame. +#[macro_export] +macro_rules! debug_once { + ($($arg:tt)+) => ({ + $crate::once!($crate::debug!($($arg)+)) + }); +} + +/// Call [`info!`](crate::info) once per call site. +/// +/// Useful for logging within systems which are called every frame. +#[macro_export] +macro_rules! info_once { + ($($arg:tt)+) => ({ + $crate::once!($crate::info!($($arg)+)) + }); +} + +/// Call [`warn!`](crate::warn) once per call site. +/// +/// Useful for logging within systems which are called every frame. +#[macro_export] +macro_rules! warn_once { + ($($arg:tt)+) => ({ + $crate::once!($crate::warn!($($arg)+)) + }); +} + +/// Call [`error!`](crate::error) once per call site. +/// +/// Useful for logging within systems which are called every frame. +#[macro_export] +macro_rules! error_once { + ($($arg:tt)+) => ({ + $crate::once!($crate::error!($($arg)+)) + }); +} diff --git a/crates/bevy_mesh/Cargo.toml b/crates/bevy_mesh/Cargo.toml index e5871c3e3c..3cf167c983 100644 --- a/crates/bevy_mesh/Cargo.toml +++ b/crates/bevy_mesh/Cargo.toml @@ -9,6 +9,7 @@ license = "MIT OR Apache-2.0" keywords = ["bevy"] [dependencies] +# bevy bevy_asset = { path = "../bevy_asset", version = "0.15.0-dev" } bevy_image = { path = "../bevy_image", version = "0.15.0-dev" } bevy_math = { path = "../bevy_math", version = "0.15.0-dev" } @@ -21,13 +22,14 @@ bevy_mikktspace = { path = "../bevy_mikktspace", version = "0.15.0-dev" } bevy_derive = { path = "../bevy_derive", version = "0.15.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } -# misc +# other bitflags = { version = "2.3", features = ["serde"] } bytemuck = { version = "1.5" } wgpu-types = { version = "23", default-features = false } serde = { version = "1", features = ["derive"] } hexasphere = "15.0" thiserror = { version = "2", default-features = false } +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_mesh/src/mesh.rs b/crates/bevy_mesh/src/mesh.rs index f643cc6674..6c933163f6 100644 --- a/crates/bevy_mesh/src/mesh.rs +++ b/crates/bevy_mesh/src/mesh.rs @@ -13,8 +13,8 @@ use bevy_asset::{Asset, Handle, RenderAssetUsages}; use bevy_image::Image; use bevy_math::{primitives::Triangle3d, *}; use bevy_reflect::Reflect; -use bevy_utils::tracing::warn; use bytemuck::cast_slice; +use tracing::warn; use wgpu_types::{VertexAttribute, VertexFormat, VertexStepMode}; pub const INDEX_BUFFER_ASSET_INDEX: u64 = 0; diff --git a/crates/bevy_pbr/Cargo.toml b/crates/bevy_pbr/Cargo.toml index afaa1d1985..b1bb96519e 100644 --- a/crates/bevy_pbr/Cargo.toml +++ b/crates/bevy_pbr/Cargo.toml @@ -48,7 +48,6 @@ bevy_transform = { path = "../bevy_transform", version = "0.15.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } bevy_window = { path = "../bevy_window", version = "0.15.0-dev" } - # other bitflags = "2.3" fixedbitset = "0.5" @@ -70,6 +69,7 @@ radsort = "0.1" smallvec = "1.6" nonmax = "0.5" static_assertions = "1" +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_pbr/src/cluster/assign.rs b/crates/bevy_pbr/src/cluster/assign.rs index 44b0eb2aed..19d8fdb059 100644 --- a/crates/bevy_pbr/src/cluster/assign.rs +++ b/crates/bevy_pbr/src/cluster/assign.rs @@ -17,7 +17,8 @@ use bevy_render::{ view::{RenderLayers, ViewVisibility}, }; use bevy_transform::components::GlobalTransform; -use bevy_utils::{prelude::default, tracing::warn}; +use bevy_utils::prelude::default; +use tracing::warn; use crate::{ prelude::EnvironmentMapLight, ClusterConfig, ClusterFarZMode, Clusters, ExtractedPointLight, diff --git a/crates/bevy_pbr/src/cluster/mod.rs b/crates/bevy_pbr/src/cluster/mod.rs index 97aa10ec60..eb7834871b 100644 --- a/crates/bevy_pbr/src/cluster/mod.rs +++ b/crates/bevy_pbr/src/cluster/mod.rs @@ -23,7 +23,8 @@ use bevy_render::{ sync_world::RenderEntity, Extract, }; -use bevy_utils::{tracing::warn, HashSet}; +use bevy_utils::HashSet; +use tracing::warn; pub(crate) use crate::cluster::assign::assign_objects_to_clusters; use crate::MeshPipeline; diff --git a/crates/bevy_pbr/src/light_probe/mod.rs b/crates/bevy_pbr/src/light_probe/mod.rs index 39c33f9cbf..4961983ecd 100644 --- a/crates/bevy_pbr/src/light_probe/mod.rs +++ b/crates/bevy_pbr/src/light_probe/mod.rs @@ -28,7 +28,8 @@ use bevy_render::{ Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::{components::Transform, prelude::GlobalTransform}; -use bevy_utils::{tracing::error, HashMap}; +use bevy_utils::HashMap; +use tracing::error; use core::{hash::Hash, ops::Deref}; diff --git a/crates/bevy_pbr/src/lightmap/mod.rs b/crates/bevy_pbr/src/lightmap/mod.rs index fc6f973cb1..31447017c5 100644 --- a/crates/bevy_pbr/src/lightmap/mod.rs +++ b/crates/bevy_pbr/src/lightmap/mod.rs @@ -57,9 +57,10 @@ use bevy_render::{ Extract, ExtractSchedule, RenderApp, }; use bevy_render::{renderer::RenderDevice, sync_world::MainEntityHashMap}; -use bevy_utils::{default, tracing::error, HashSet}; +use bevy_utils::{default, HashSet}; use fixedbitset::FixedBitSet; use nonmax::{NonMaxU16, NonMaxU32}; +use tracing::error; use crate::{binding_arrays_are_usable, ExtractMeshesSet}; diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index e2ccdb2a32..33772133cc 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -42,8 +42,9 @@ use bevy_render::{ }; use bevy_render::{mesh::allocator::MeshAllocator, sync_world::MainEntityHashMap}; use bevy_render::{texture::FallbackImage, view::RenderVisibleEntities}; -use bevy_utils::{hashbrown::hash_map::Entry, tracing::error}; +use bevy_utils::hashbrown::hash_map::Entry; use core::{hash::Hash, marker::PhantomData}; +use tracing::error; /// Materials are used alongside [`MaterialPlugin`], [`Mesh3d`], and [`MeshMaterial3d`] /// to spawn entities that are rendered with a specific [`Material`] type. They serve as an easy to use high level diff --git a/crates/bevy_pbr/src/material_bind_groups.rs b/crates/bevy_pbr/src/material_bind_groups.rs index 3baa25eb9a..a7c06dfcf2 100644 --- a/crates/bevy_pbr/src/material_bind_groups.rs +++ b/crates/bevy_pbr/src/material_bind_groups.rs @@ -21,8 +21,9 @@ use bevy_render::{ renderer::RenderDevice, texture::FallbackImage, }; -use bevy_utils::{default, tracing::error, HashMap}; +use bevy_utils::{default, HashMap}; use core::{any, iter, marker::PhantomData, num::NonZero}; +use tracing::error; /// An object that creates and stores bind groups for a single material type. /// diff --git a/crates/bevy_pbr/src/meshlet/mod.rs b/crates/bevy_pbr/src/meshlet/mod.rs index 5486fd72e0..5db0644f97 100644 --- a/crates/bevy_pbr/src/meshlet/mod.rs +++ b/crates/bevy_pbr/src/meshlet/mod.rs @@ -83,8 +83,8 @@ use bevy_render::{ ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::components::Transform; -use bevy_utils::tracing::error; use derive_more::From; +use tracing::error; const MESHLET_BINDINGS_SHADER_HANDLE: Handle = Handle::weak_from_u128(1325134235233421); const MESHLET_MESH_MATERIAL_SHADER_HANDLE: Handle = diff --git a/crates/bevy_pbr/src/prepass/mod.rs b/crates/bevy_pbr/src/prepass/mod.rs index 211bbe9926..7a430b2132 100644 --- a/crates/bevy_pbr/src/prepass/mod.rs +++ b/crates/bevy_pbr/src/prepass/mod.rs @@ -36,7 +36,7 @@ use bevy_render::{ Extract, }; use bevy_transform::prelude::GlobalTransform; -use bevy_utils::tracing::error; +use tracing::error; #[cfg(feature = "meshlet")] use crate::meshlet::{ diff --git a/crates/bevy_pbr/src/render/gpu_preprocess.rs b/crates/bevy_pbr/src/render/gpu_preprocess.rs index 144539d524..3c7954a8c4 100644 --- a/crates/bevy_pbr/src/render/gpu_preprocess.rs +++ b/crates/bevy_pbr/src/render/gpu_preprocess.rs @@ -36,9 +36,9 @@ use bevy_render::{ view::{NoIndirectDrawing, ViewUniform, ViewUniformOffset, ViewUniforms}, Render, RenderApp, RenderSet, }; -use bevy_utils::tracing::warn; use bitflags::bitflags; use smallvec::{smallvec, SmallVec}; +use tracing::warn; use crate::{ graph::NodePbr, MeshCullingData, MeshCullingDataBuffer, MeshInputUniform, MeshUniform, diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index cd2c37f345..1316b9c6d5 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -35,14 +35,11 @@ use bevy_render::{ sync_world::{MainEntity, RenderEntity}, }; use bevy_transform::{components::GlobalTransform, prelude::Transform}; -#[cfg(feature = "trace")] -use bevy_utils::tracing::info_span; -use bevy_utils::{ - default, - tracing::{error, warn}, - HashMap, -}; +use bevy_utils::{default, HashMap}; use core::{hash::Hash, ops::Range}; +#[cfg(feature = "trace")] +use tracing::info_span; +use tracing::{error, warn}; #[derive(Component)] pub struct ExtractedPointLight { diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index 84a433f555..17c4188b5f 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -43,14 +43,10 @@ use bevy_render::{ Extract, }; use bevy_transform::components::GlobalTransform; -use bevy_utils::{ - default, - hashbrown::hash_map::Entry, - tracing::{error, warn}, - HashMap, Parallel, -}; +use bevy_utils::{default, hashbrown::hash_map::Entry, HashMap, Parallel}; use material_bind_groups::MaterialBindingId; use render::skin::{self, SkinIndex}; +use tracing::{error, warn}; use crate::{ render::{ diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.rs b/crates/bevy_pbr/src/render/mesh_view_bindings.rs index e27b3d7b7f..5c8823f2d3 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.rs @@ -21,7 +21,7 @@ use bevy_render::{ globals::{GlobalsBuffer, GlobalsUniform}, render_asset::RenderAssets, render_resource::{binding_types::*, *}, - renderer::RenderDevice, + renderer::{RenderAdapter, RenderDevice}, texture::{FallbackImage, FallbackImageMsaa, FallbackImageZero, GpuImage}, view::{ Msaa, RenderVisibilityRanges, ViewUniform, ViewUniforms, @@ -29,16 +29,8 @@ use bevy_render::{ }, }; use core::{array, num::NonZero}; - -#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))] -use bevy_render::render_resource::binding_types::texture_cube; -use bevy_render::renderer::RenderAdapter; -#[cfg(debug_assertions)] -use bevy_utils::warn_once; use environment_map::EnvironmentMapLight; -#[cfg(debug_assertions)] -use crate::MESH_PIPELINE_VIEW_LAYOUT_SAFE_MAX_TEXTURES; use crate::{ environment_map::{self, RenderViewEnvironmentMapBindGroupEntries}, irradiance_volume::{ @@ -52,6 +44,12 @@ use crate::{ ViewClusterBindings, ViewShadowBindings, CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, }; +#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))] +use bevy_render::render_resource::binding_types::texture_cube; + +#[cfg(debug_assertions)] +use {crate::MESH_PIPELINE_VIEW_LAYOUT_SAFE_MAX_TEXTURES, bevy_utils::once, tracing::warn}; + #[derive(Clone)] pub struct MeshPipelineViewLayout { pub bind_group_layout: BindGroupLayout, @@ -445,7 +443,7 @@ impl MeshPipelineViewLayouts { #[cfg(debug_assertions)] if layout.texture_count > MESH_PIPELINE_VIEW_LAYOUT_SAFE_MAX_TEXTURES { // Issue our own warning here because Naga's error message is a bit cryptic in this situation - warn_once!("Too many textures in mesh pipeline view layout, this might cause us to hit `wgpu::Limits::max_sampled_textures_per_shader_stage` in some environments."); + once!(warn!("Too many textures in mesh pipeline view layout, this might cause us to hit `wgpu::Limits::max_sampled_textures_per_shader_stage` in some environments.")); } &layout.bind_group_layout diff --git a/crates/bevy_pbr/src/ssao/mod.rs b/crates/bevy_pbr/src/ssao/mod.rs index 5784c41b2a..d2271b9b38 100644 --- a/crates/bevy_pbr/src/ssao/mod.rs +++ b/crates/bevy_pbr/src/ssao/mod.rs @@ -34,11 +34,9 @@ use bevy_render::{ view::{Msaa, ViewUniform, ViewUniformOffset, ViewUniforms}, Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; -use bevy_utils::{ - prelude::default, - tracing::{error, warn}, -}; +use bevy_utils::prelude::default; use core::mem; +use tracing::{error, warn}; const PREPROCESS_DEPTH_SHADER_HANDLE: Handle = Handle::weak_from_u128(102258915420479); const SSAO_SHADER_HANDLE: Handle = Handle::weak_from_u128(253938746510568); diff --git a/crates/bevy_pbr/src/ssr/mod.rs b/crates/bevy_pbr/src/ssr/mod.rs index 996c120041..aa4e1037d5 100644 --- a/crates/bevy_pbr/src/ssr/mod.rs +++ b/crates/bevy_pbr/src/ssr/mod.rs @@ -38,7 +38,8 @@ use bevy_render::{ view::{ExtractedView, Msaa, ViewTarget, ViewUniformOffset}, Render, RenderApp, RenderSet, }; -use bevy_utils::{info_once, prelude::default}; +use bevy_utils::{once, prelude::default}; +use tracing::info; use crate::{ binding_arrays_are_usable, graph::NodePbr, prelude::EnvironmentMapLight, @@ -502,10 +503,10 @@ impl ExtractComponent for ScreenSpaceReflections { fn extract_component(settings: QueryItem<'_, Self::QueryData>) -> Option { if !DEPTH_TEXTURE_SAMPLING_SUPPORTED { - info_once!( + once!(info!( "Disabling screen-space reflections on this platform because depth textures \ aren't supported correctly" - ); + )); return None; } diff --git a/crates/bevy_picking/Cargo.toml b/crates/bevy_picking/Cargo.toml index 3deba7d21b..94608bf215 100644 --- a/crates/bevy_picking/Cargo.toml +++ b/crates/bevy_picking/Cargo.toml @@ -12,6 +12,7 @@ license = "MIT OR Apache-2.0" bevy_mesh_picking_backend = ["dep:bevy_mesh", "dep:crossbeam-channel"] [dependencies] +# bevy bevy_app = { path = "../bevy_app", version = "0.15.0-dev" } bevy_asset = { path = "../bevy_asset", version = "0.15.0-dev" } bevy_derive = { path = "../bevy_derive", version = "0.15.0-dev" } @@ -27,8 +28,10 @@ bevy_transform = { path = "../bevy_transform", version = "0.15.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } bevy_window = { path = "../bevy_window", version = "0.15.0-dev" } +# other crossbeam-channel = { version = "0.5", optional = true } uuid = { version = "1.1", features = ["v4"] } +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_picking/src/events.rs b/crates/bevy_picking/src/events.rs index c9792ccb8c..c105b71e23 100644 --- a/crates/bevy_picking/src/events.rs +++ b/crates/bevy_picking/src/events.rs @@ -44,8 +44,9 @@ use bevy_hierarchy::Parent; use bevy_math::Vec2; use bevy_reflect::prelude::*; use bevy_render::camera::NormalizedRenderTarget; -use bevy_utils::{tracing::debug, HashMap, Instant}; +use bevy_utils::{HashMap, Instant}; use bevy_window::Window; +use tracing::debug; use crate::{ backend::{prelude::PointerLocation, HitData}, diff --git a/crates/bevy_picking/src/input.rs b/crates/bevy_picking/src/input.rs index 321ed6b5e6..94e195e4b3 100644 --- a/crates/bevy_picking/src/input.rs +++ b/crates/bevy_picking/src/input.rs @@ -22,8 +22,9 @@ use bevy_input::{ use bevy_math::Vec2; use bevy_reflect::prelude::*; use bevy_render::camera::RenderTarget; -use bevy_utils::{tracing::debug, HashMap, HashSet}; +use bevy_utils::{HashMap, HashSet}; use bevy_window::{PrimaryWindow, WindowEvent, WindowRef}; +use tracing::debug; use crate::pointer::{ Location, PointerAction, PointerButton, PointerId, PointerInput, PointerLocation, diff --git a/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs b/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs index 2ba76f7960..ef6f187416 100644 --- a/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs +++ b/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs @@ -18,7 +18,7 @@ use bevy_ecs::{prelude::*, system::lifetimeless::Read, system::SystemParam}; use bevy_math::FloatOrd; use bevy_render::{prelude::*, primitives::Aabb}; use bevy_transform::components::GlobalTransform; -use bevy_utils::tracing::*; +use tracing::*; /// How a ray cast should handle [`Visibility`]. #[derive(Clone, Copy, Reflect)] diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 6e1407f326..5a160ccd65 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -92,6 +92,7 @@ nonmax = "0.5" smallvec = { version = "1.11", features = ["const_new"] } offset-allocator = "0.2" variadics_please = "1.1" +tracing = { version = "0.1", default-features = false, features = ["std"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] # Omit the `glsl` feature in non-WebAssembly by default. diff --git a/crates/bevy_render/src/batching/gpu_preprocessing.rs b/crates/bevy_render/src/batching/gpu_preprocessing.rs index 26353da461..6a7f994e97 100644 --- a/crates/bevy_render/src/batching/gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/gpu_preprocessing.rs @@ -9,9 +9,10 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use bevy_encase_derive::ShaderType; -use bevy_utils::{default, tracing::error}; +use bevy_utils::default; use bytemuck::{Pod, Zeroable}; use nonmax::NonMaxU32; +use tracing::error; use wgpu::{BindingResource, BufferUsages, DownlevelFlags, Features}; use crate::{ diff --git a/crates/bevy_render/src/batching/no_gpu_preprocessing.rs b/crates/bevy_render/src/batching/no_gpu_preprocessing.rs index 25b4bd8d79..1f39c387dc 100644 --- a/crates/bevy_render/src/batching/no_gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/no_gpu_preprocessing.rs @@ -2,8 +2,8 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::system::{Res, ResMut, Resource, StaticSystemParam}; -use bevy_utils::tracing::error; use smallvec::{smallvec, SmallVec}; +use tracing::error; use wgpu::BindingResource; use crate::{ diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index f7bb13340f..5164f3d59b 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -32,13 +32,14 @@ use bevy_math::{ops, vec2, Dir3, FloatOrd, Mat4, Ray3d, Rect, URect, UVec2, UVec use bevy_reflect::prelude::*; use bevy_render_macros::ExtractComponent; use bevy_transform::components::{GlobalTransform, Transform}; -use bevy_utils::{tracing::warn, HashMap, HashSet}; +use bevy_utils::{HashMap, HashSet}; use bevy_window::{ NormalizedWindowRef, PrimaryWindow, Window, WindowCreated, WindowRef, WindowResized, WindowScaleFactorChanged, }; use core::ops::Range; use derive_more::derive::From; +use tracing::warn; use wgpu::{BlendState, TextureFormat, TextureUsages}; /// Render viewport configuration for the [`Camera`] component. diff --git a/crates/bevy_render/src/camera/camera_driver_node.rs b/crates/bevy_render/src/camera/camera_driver_node.rs index 99a988b9f3..b5698a0f82 100644 --- a/crates/bevy_render/src/camera/camera_driver_node.rs +++ b/crates/bevy_render/src/camera/camera_driver_node.rs @@ -71,7 +71,7 @@ impl Node for CameraDriverNode { }; #[cfg(feature = "trace")] - let _span = bevy_utils::tracing::info_span!("no_camera_clear_pass").entered(); + let _span = tracing::info_span!("no_camera_clear_pass").entered(); let pass_descriptor = RenderPassDescriptor { label: Some("no_camera_clear_pass"), color_attachments: &[Some(RenderPassColorAttachment { diff --git a/crates/bevy_render/src/diagnostic/internal.rs b/crates/bevy_render/src/diagnostic/internal.rs index 872323f80f..ba15a95dde 100644 --- a/crates/bevy_render/src/diagnostic/internal.rs +++ b/crates/bevy_render/src/diagnostic/internal.rs @@ -7,7 +7,7 @@ use std::thread::{self, ThreadId}; use bevy_diagnostic::{Diagnostic, DiagnosticMeasurement, DiagnosticPath, DiagnosticsStore}; use bevy_ecs::system::{Res, ResMut, Resource}; -use bevy_utils::{tracing, Instant}; +use bevy_utils::Instant; use std::sync::Mutex; use wgpu::{ Buffer, BufferDescriptor, BufferUsages, CommandEncoder, ComputePass, Features, MapMode, diff --git a/crates/bevy_render/src/extract_resource.rs b/crates/bevy_render/src/extract_resource.rs index 2d36e694be..62c25aef17 100644 --- a/crates/bevy_render/src/extract_resource.rs +++ b/crates/bevy_render/src/extract_resource.rs @@ -3,6 +3,8 @@ use core::marker::PhantomData; use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; pub use bevy_render_macros::ExtractResource; +use bevy_utils::once; +use tracing::{error, warn}; use crate::{Extract, ExtractSchedule, RenderApp}; @@ -34,10 +36,10 @@ impl Plugin for ExtractResourcePlugin { if let Some(render_app) = app.get_sub_app_mut(RenderApp) { render_app.add_systems(ExtractSchedule, extract_resource::); } else { - bevy_utils::error_once!( + once!(error!( "Render app did not exist when trying to add `extract_resource` for <{}>.", core::any::type_name::() - ); + )); } } } @@ -56,11 +58,11 @@ pub fn extract_resource( } else { #[cfg(debug_assertions)] if !main_resource.is_added() { - bevy_utils::warn_once!( + once!(warn!( "Removing resource {} from render world not expected, adding using `Commands`. This may decrease performance", core::any::type_name::() - ); + )); } commands.insert_resource(R::extract_resource(main_resource)); } diff --git a/crates/bevy_render/src/gpu_readback.rs b/crates/bevy_render/src/gpu_readback.rs index bf75759e28..75742de909 100644 --- a/crates/bevy_render/src/gpu_readback.rs +++ b/crates/bevy_render/src/gpu_readback.rs @@ -23,10 +23,11 @@ use bevy_ecs::{ use bevy_image::{Image, TextureFormatPixelInfo}; use bevy_reflect::Reflect; use bevy_render_macros::ExtractComponent; -use bevy_utils::{tracing::warn, HashMap}; +use bevy_utils::HashMap; use encase::internal::ReadFrom; use encase::private::Reader; use encase::ShaderType; +use tracing::warn; use wgpu::CommandEncoder; /// A plugin that enables reading back gpu buffers and textures to the cpu. diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 88483342d2..54e6d9164a 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -98,9 +98,9 @@ use alloc::sync::Arc; use bevy_app::{App, AppLabel, Plugin, SubApp}; use bevy_asset::{load_internal_asset, AssetApp, AssetServer, Handle}; use bevy_ecs::{prelude::*, schedule::ScheduleLabel}; -use bevy_utils::tracing::debug; use core::ops::{Deref, DerefMut}; use std::sync::Mutex; +use tracing::debug; /// Contains the default Bevy rendering backend based on wgpu. /// @@ -486,7 +486,7 @@ unsafe fn initialize_render_app(app: &mut App) { render_app.set_extract(|main_world, render_world| { { #[cfg(feature = "trace")] - let _stage_span = bevy_utils::tracing::info_span!("entity_sync").entered(); + let _stage_span = tracing::info_span!("entity_sync").entered(); entity_sync_system(main_world, render_world); } diff --git a/crates/bevy_render/src/mesh/allocator.rs b/crates/bevy_render/src/mesh/allocator.rs index a4928cec60..5233907257 100644 --- a/crates/bevy_render/src/mesh/allocator.rs +++ b/crates/bevy_render/src/mesh/allocator.rs @@ -15,8 +15,9 @@ use bevy_ecs::{ system::{Res, ResMut, Resource}, world::{FromWorld, World}, }; -use bevy_utils::{default, tracing::error, HashMap, HashSet}; +use bevy_utils::{default, HashMap, HashSet}; use offset_allocator::{Allocation, Allocator}; +use tracing::error; use wgpu::{ BufferDescriptor, BufferSize, BufferUsages, CommandEncoderDescriptor, DownlevelFlags, COPY_BUFFER_ALIGNMENT, diff --git a/crates/bevy_render/src/pipelined_rendering.rs b/crates/bevy_render/src/pipelined_rendering.rs index 41279e7d25..39caaedac7 100644 --- a/crates/bevy_render/src/pipelined_rendering.rs +++ b/crates/bevy_render/src/pipelined_rendering.rs @@ -148,7 +148,7 @@ impl Plugin for PipelinedRenderingPlugin { std::thread::spawn(move || { #[cfg(feature = "trace")] - let _span = bevy_utils::tracing::info_span!("render thread").entered(); + let _span = tracing::info_span!("render thread").entered(); let compute_task_pool = ComputeTaskPool::get(); loop { @@ -164,8 +164,7 @@ impl Plugin for PipelinedRenderingPlugin { { #[cfg(feature = "trace")] - let _sub_app_span = - bevy_utils::tracing::info_span!("sub app", name = ?RenderApp).entered(); + let _sub_app_span = tracing::info_span!("sub app", name = ?RenderApp).entered(); render_app.update(); } @@ -174,7 +173,7 @@ impl Plugin for PipelinedRenderingPlugin { } } - bevy_utils::tracing::debug!("exiting pipelined rendering thread"); + tracing::debug!("exiting pipelined rendering thread"); }); } } diff --git a/crates/bevy_render/src/render_asset.rs b/crates/bevy_render/src/render_asset.rs index 2757dceb9f..0c2d4cd837 100644 --- a/crates/bevy_render/src/render_asset.rs +++ b/crates/bevy_render/src/render_asset.rs @@ -11,12 +11,10 @@ use bevy_ecs::{ world::{FromWorld, Mut}, }; use bevy_render_macros::ExtractResource; -use bevy_utils::{ - tracing::{debug, error}, - HashMap, HashSet, -}; +use bevy_utils::{HashMap, HashSet}; use core::marker::PhantomData; use thiserror::Error; +use tracing::{debug, error}; #[derive(Debug, Error)] pub enum PrepareAssetError { diff --git a/crates/bevy_render/src/render_graph/app.rs b/crates/bevy_render/src/render_graph/app.rs index 80ffcdb2a1..338ae75d7a 100644 --- a/crates/bevy_render/src/render_graph/app.rs +++ b/crates/bevy_render/src/render_graph/app.rs @@ -1,6 +1,6 @@ use bevy_app::{App, SubApp}; use bevy_ecs::world::FromWorld; -use bevy_utils::tracing::warn; +use tracing::warn; use super::{IntoRenderNodeArray, Node, RenderGraph, RenderLabel, RenderSubGraph}; diff --git a/crates/bevy_render/src/render_phase/draw_state.rs b/crates/bevy_render/src/render_phase/draw_state.rs index 4ba3e41087..a7b8acdc00 100644 --- a/crates/bevy_render/src/render_phase/draw_state.rs +++ b/crates/bevy_render/src/render_phase/draw_state.rs @@ -8,10 +8,13 @@ use crate::{ renderer::RenderDevice, }; use bevy_color::LinearRgba; -use bevy_utils::{default, detailed_trace}; +use bevy_utils::default; use core::ops::Range; use wgpu::{IndexFormat, QuerySet, RenderPass}; +#[cfg(feature = "detailed_trace")] +use tracing::trace; + /// Tracks the state of a [`TrackedRenderPass`]. /// /// This is used to skip redundant operations on the [`TrackedRenderPass`] (e.g. setting an already @@ -164,7 +167,8 @@ impl<'a> TrackedRenderPass<'a> { /// /// Subsequent draw calls will exhibit the behavior defined by the `pipeline`. pub fn set_render_pipeline(&mut self, pipeline: &'a RenderPipeline) { - detailed_trace!("set pipeline: {:?}", pipeline); + #[cfg(feature = "detailed_trace")] + trace!("set pipeline: {:?}", pipeline); if self.state.is_pipeline_set(pipeline.id()) { return; } @@ -189,7 +193,8 @@ impl<'a> TrackedRenderPass<'a> { .state .is_bind_group_set(index, bind_group.id(), dynamic_uniform_indices) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "set bind_group {} (already set): {:?} ({:?})", index, bind_group, @@ -197,7 +202,8 @@ impl<'a> TrackedRenderPass<'a> { ); return; } - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "set bind_group {}: {:?} ({:?})", index, bind_group, @@ -222,7 +228,8 @@ impl<'a> TrackedRenderPass<'a> { /// [`draw_indexed`]: TrackedRenderPass::draw_indexed pub fn set_vertex_buffer(&mut self, slot_index: usize, buffer_slice: BufferSlice<'a>) { if self.state.is_vertex_buffer_set(slot_index, &buffer_slice) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "set vertex buffer {} (already set): {:?} (offset = {}, size = {})", slot_index, buffer_slice.id(), @@ -231,7 +238,8 @@ impl<'a> TrackedRenderPass<'a> { ); return; } - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "set vertex buffer {}: {:?} (offset = {}, size = {})", slot_index, buffer_slice.id(), @@ -258,14 +266,16 @@ impl<'a> TrackedRenderPass<'a> { .state .is_index_buffer_set(buffer_slice.id(), offset, index_format) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "set index buffer (already set): {:?} ({})", buffer_slice.id(), offset ); return; } - detailed_trace!("set index buffer: {:?} ({})", buffer_slice.id(), offset); + #[cfg(feature = "detailed_trace")] + trace!("set index buffer: {:?} ({})", buffer_slice.id(), offset); self.pass.set_index_buffer(*buffer_slice, index_format); self.state .set_index_buffer(buffer_slice.id(), offset, index_format); @@ -275,7 +285,8 @@ impl<'a> TrackedRenderPass<'a> { /// /// The active vertex buffer(s) can be set with [`TrackedRenderPass::set_vertex_buffer`]. pub fn draw(&mut self, vertices: Range, instances: Range) { - detailed_trace!("draw: {:?} {:?}", vertices, instances); + #[cfg(feature = "detailed_trace")] + trace!("draw: {:?} {:?}", vertices, instances); self.pass.draw(vertices, instances); } @@ -284,7 +295,8 @@ impl<'a> TrackedRenderPass<'a> { /// The active index buffer can be set with [`TrackedRenderPass::set_index_buffer`], while the /// active vertex buffer(s) can be set with [`TrackedRenderPass::set_vertex_buffer`]. pub fn draw_indexed(&mut self, indices: Range, base_vertex: i32, instances: Range) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "draw indexed: {:?} {} {:?}", indices, base_vertex, @@ -311,7 +323,8 @@ impl<'a> TrackedRenderPass<'a> { /// } /// ``` pub fn draw_indirect(&mut self, indirect_buffer: &'a Buffer, indirect_offset: u64) { - detailed_trace!("draw indirect: {:?} {}", indirect_buffer, indirect_offset); + #[cfg(feature = "detailed_trace")] + trace!("draw indirect: {:?} {}", indirect_buffer, indirect_offset); self.pass.draw_indirect(indirect_buffer, indirect_offset); } @@ -335,7 +348,8 @@ impl<'a> TrackedRenderPass<'a> { /// } /// ``` pub fn draw_indexed_indirect(&mut self, indirect_buffer: &'a Buffer, indirect_offset: u64) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "draw indexed indirect: {:?} {}", indirect_buffer, indirect_offset @@ -367,7 +381,8 @@ impl<'a> TrackedRenderPass<'a> { indirect_offset: u64, count: u32, ) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "multi draw indirect: {:?} {}, {}x", indirect_buffer, indirect_offset, @@ -407,7 +422,8 @@ impl<'a> TrackedRenderPass<'a> { count_offset: u64, max_count: u32, ) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "multi draw indirect count: {:?} {}, ({:?} {})x, max {}x", indirect_buffer, indirect_offset, @@ -449,7 +465,8 @@ impl<'a> TrackedRenderPass<'a> { indirect_offset: u64, count: u32, ) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "multi draw indexed indirect: {:?} {}, {}x", indirect_buffer, indirect_offset, @@ -491,7 +508,8 @@ impl<'a> TrackedRenderPass<'a> { count_offset: u64, max_count: u32, ) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "multi draw indexed indirect count: {:?} {}, ({:?} {})x, max {}x", indirect_buffer, indirect_offset, @@ -512,7 +530,8 @@ impl<'a> TrackedRenderPass<'a> { /// /// Subsequent stencil tests will test against this value. pub fn set_stencil_reference(&mut self, reference: u32) { - detailed_trace!("set stencil reference: {}", reference); + #[cfg(feature = "detailed_trace")] + trace!("set stencil reference: {}", reference); self.pass.set_stencil_reference(reference); } @@ -520,7 +539,8 @@ impl<'a> TrackedRenderPass<'a> { /// /// Subsequent draw calls will discard any fragments that fall outside this region. pub fn set_scissor_rect(&mut self, x: u32, y: u32, width: u32, height: u32) { - detailed_trace!("set_scissor_rect: {} {} {} {}", x, y, width, height); + #[cfg(feature = "detailed_trace")] + trace!("set_scissor_rect: {} {} {} {}", x, y, width, height); self.pass.set_scissor_rect(x, y, width, height); } @@ -528,7 +548,8 @@ impl<'a> TrackedRenderPass<'a> { /// /// `Features::PUSH_CONSTANTS` must be enabled on the device in order to call these functions. pub fn set_push_constants(&mut self, stages: ShaderStages, offset: u32, data: &[u8]) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "set push constants: {:?} offset: {} data.len: {}", stages, offset, @@ -549,7 +570,8 @@ impl<'a> TrackedRenderPass<'a> { min_depth: f32, max_depth: f32, ) { - detailed_trace!( + #[cfg(feature = "detailed_trace")] + trace!( "set viewport: {} {} {} {} {} {}", x, y, @@ -580,7 +602,8 @@ impl<'a> TrackedRenderPass<'a> { /// /// This is a GPU debugging feature. This has no effect on the rendering itself. pub fn insert_debug_marker(&mut self, label: &str) { - detailed_trace!("insert debug marker: {}", label); + #[cfg(feature = "detailed_trace")] + trace!("insert debug marker: {}", label); self.pass.insert_debug_marker(label); } @@ -605,7 +628,8 @@ impl<'a> TrackedRenderPass<'a> { /// [`push_debug_group`]: TrackedRenderPass::push_debug_group /// [`pop_debug_group`]: TrackedRenderPass::pop_debug_group pub fn push_debug_group(&mut self, label: &str) { - detailed_trace!("push_debug_group marker: {}", label); + #[cfg(feature = "detailed_trace")] + trace!("push_debug_group marker: {}", label); self.pass.push_debug_group(label); } @@ -622,7 +646,8 @@ impl<'a> TrackedRenderPass<'a> { /// [`push_debug_group`]: TrackedRenderPass::push_debug_group /// [`pop_debug_group`]: TrackedRenderPass::pop_debug_group pub fn pop_debug_group(&mut self) { - detailed_trace!("pop_debug_group"); + #[cfg(feature = "detailed_trace")] + trace!("pop_debug_group"); self.pass.pop_debug_group(); } @@ -630,7 +655,8 @@ impl<'a> TrackedRenderPass<'a> { /// /// Subsequent blending tests will test against this value. pub fn set_blend_constant(&mut self, color: LinearRgba) { - detailed_trace!("set blend constant: {:?}", color); + #[cfg(feature = "detailed_trace")] + trace!("set blend constant: {:?}", color); self.pass.set_blend_constant(wgpu::Color::from(color)); } } diff --git a/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs b/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs index 3a811a5dbe..be03306c1a 100644 --- a/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs +++ b/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs @@ -222,7 +222,7 @@ impl IntoBindGroupLayoutEntryBuilder for BindingType { impl IntoBindGroupLayoutEntryBuilder for BindGroupLayoutEntry { fn into_bind_group_layout_entry_builder(self) -> BindGroupLayoutEntryBuilder { if self.binding != u32::MAX { - bevy_utils::tracing::warn!("The BindGroupLayoutEntries api ignores the binding index when converting a raw wgpu::BindGroupLayoutEntry. You can ignore this warning by setting it to u32::MAX."); + tracing::warn!("The BindGroupLayoutEntries api ignores the binding index when converting a raw wgpu::BindGroupLayoutEntry. You can ignore this warning by setting it to u32::MAX."); } BindGroupLayoutEntryBuilder { ty: self.ty, diff --git a/crates/bevy_render/src/render_resource/pipeline_cache.rs b/crates/bevy_render/src/render_resource/pipeline_cache.rs index 220f5bd326..af3909c509 100644 --- a/crates/bevy_render/src/render_resource/pipeline_cache.rs +++ b/crates/bevy_render/src/render_resource/pipeline_cache.rs @@ -11,16 +11,12 @@ use bevy_ecs::{ system::{Res, ResMut, Resource}, }; use bevy_tasks::Task; -use bevy_utils::{ - default, - hashbrown::hash_map::EntryRef, - tracing::{debug, error}, - HashMap, HashSet, -}; +use bevy_utils::{default, hashbrown::hash_map::EntryRef, HashMap, HashSet}; use core::{future::Future, hash::Hash, mem, ops::Deref}; use naga::valid::Capabilities; use std::sync::{Mutex, PoisonError}; use thiserror::Error; +use tracing::{debug, error}; #[cfg(feature = "shader_format_spirv")] use wgpu::util::make_spirv; use wgpu::{ diff --git a/crates/bevy_render/src/render_resource/pipeline_specializer.rs b/crates/bevy_render/src/render_resource/pipeline_specializer.rs index 3ee7a78ed7..7801381acb 100644 --- a/crates/bevy_render/src/render_resource/pipeline_specializer.rs +++ b/crates/bevy_render/src/render_resource/pipeline_specializer.rs @@ -9,11 +9,11 @@ use bevy_ecs::system::Resource; use bevy_utils::{ default, hashbrown::hash_map::{RawEntryMut, VacantEntry}, - tracing::error, Entry, FixedHasher, HashMap, }; use core::{fmt::Debug, hash::Hash}; use thiserror::Error; +use tracing::error; pub trait SpecializedRenderPipeline { type Key: Clone + Hash + PartialEq + Eq; diff --git a/crates/bevy_render/src/renderer/graph_runner.rs b/crates/bevy_render/src/renderer/graph_runner.rs index 6c96a9b324..6433a39da1 100644 --- a/crates/bevy_render/src/renderer/graph_runner.rs +++ b/crates/bevy_render/src/renderer/graph_runner.rs @@ -1,7 +1,7 @@ use bevy_ecs::{prelude::Entity, world::World}; -#[cfg(feature = "trace")] -use bevy_utils::tracing::info_span; use bevy_utils::HashMap; +#[cfg(feature = "trace")] +use tracing::info_span; use alloc::{borrow::Cow, collections::VecDeque}; use smallvec::{smallvec, SmallVec}; diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 7f1282194c..1cd17e8a02 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -4,9 +4,9 @@ mod render_device; use bevy_derive::{Deref, DerefMut}; #[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))] use bevy_tasks::ComputeTaskPool; -use bevy_utils::tracing::{error, info, info_span, warn}; pub use graph_runner::*; pub use render_device::*; +use tracing::{error, info, info_span, warn}; use crate::{ diagnostic::{internal::DiagnosticsRecorder, RecordDiagnostics}, @@ -99,8 +99,8 @@ pub fn render_system(world: &mut World, state: &mut SystemState { - bevy_utils::tracing::trace!( + tracing::trace!( "Couldn't get swap chain texture. This is probably a quirk \ of your Linux GPU driver, so it can be safely ignored." ); diff --git a/crates/bevy_render/src/view/window/screenshot.rs b/crates/bevy_render/src/view/window/screenshot.rs index 1b7db5b421..9fddb42760 100644 --- a/crates/bevy_render/src/view/window/screenshot.rs +++ b/crates/bevy_render/src/view/window/screenshot.rs @@ -26,11 +26,7 @@ use bevy_hierarchy::DespawnRecursiveExt; use bevy_image::{Image, TextureFormatPixelInfo}; use bevy_reflect::Reflect; use bevy_tasks::AsyncComputeTaskPool; -use bevy_utils::{ - default, - tracing::{error, info, warn}, - HashSet, -}; +use bevy_utils::{default, HashSet}; use bevy_window::{PrimaryWindow, WindowRef}; use core::ops::Deref; use std::{ @@ -40,6 +36,7 @@ use std::{ Mutex, }, }; +use tracing::{error, info, warn}; use wgpu::{CommandEncoder, Extent3d, TextureFormat}; #[derive(Event, Deref, DerefMut, Reflect, Debug)] @@ -628,7 +625,7 @@ fn render_screenshot( pub(crate) fn collect_screenshots(world: &mut World) { #[cfg(feature = "trace")] - let _span = bevy_utils::tracing::info_span!("collect_screenshots").entered(); + let _span = tracing::info_span!("collect_screenshots").entered(); let sender = world.resource::().deref().clone(); let prepared = world.resource::(); diff --git a/crates/bevy_sprite/Cargo.toml b/crates/bevy_sprite/Cargo.toml index 8800f6cb6e..090a68585b 100644 --- a/crates/bevy_sprite/Cargo.toml +++ b/crates/bevy_sprite/Cargo.toml @@ -44,6 +44,7 @@ bitflags = "2.3" radsort = "0.1" nonmax = "0.5" serde = { version = "1", features = ["derive"], optional = true } +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index a53b45cc26..2e648e513a 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -36,9 +36,9 @@ use bevy_render::{ Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_render::{render_resource::BindingResources, sync_world::MainEntityHashMap}; -use bevy_utils::tracing::error; use core::{hash::Hash, marker::PhantomData}; use derive_more::derive::From; +use tracing::error; /// Materials are used alongside [`Material2dPlugin`], [`Mesh2d`], and [`MeshMaterial2d`] /// to spawn entities that are rendered with a specific [`Material2d`] type. They serve as an easy to use high level diff --git a/crates/bevy_sprite/src/mesh2d/mesh.rs b/crates/bevy_sprite/src/mesh2d/mesh.rs index 191615db81..92abdeb68a 100644 --- a/crates/bevy_sprite/src/mesh2d/mesh.rs +++ b/crates/bevy_sprite/src/mesh2d/mesh.rs @@ -44,8 +44,8 @@ use bevy_render::{ Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::components::GlobalTransform; -use bevy_utils::tracing::error; use nonmax::NonMaxU32; +use tracing::error; #[derive(Default)] pub struct Mesh2dRenderPlugin; diff --git a/crates/bevy_sprite/src/texture_atlas_builder.rs b/crates/bevy_sprite/src/texture_atlas_builder.rs index 50619e18f9..bfc577db3e 100644 --- a/crates/bevy_sprite/src/texture_atlas_builder.rs +++ b/crates/bevy_sprite/src/texture_atlas_builder.rs @@ -5,15 +5,13 @@ use bevy_render::{ render_asset::RenderAssetUsages, render_resource::{Extent3d, TextureDimension, TextureFormat}, }; -use bevy_utils::{ - tracing::{debug, error, warn}, - HashMap, -}; +use bevy_utils::HashMap; use rectangle_pack::{ contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation, RectToInsert, TargetBin, }; use thiserror::Error; +use tracing::{debug, error, warn}; use crate::{TextureAtlasLayout, TextureAtlasSources}; diff --git a/crates/bevy_sprite/src/texture_slice/mod.rs b/crates/bevy_sprite/src/texture_slice/mod.rs index 2dea51adc6..88939df91f 100644 --- a/crates/bevy_sprite/src/texture_slice/mod.rs +++ b/crates/bevy_sprite/src/texture_slice/mod.rs @@ -86,7 +86,7 @@ impl TextureSlice { remaining_columns -= size_y; } if slices.len() > 1_000 { - bevy_utils::tracing::warn!("One of your tiled textures has generated {} slices. You might want to use higher stretch values to avoid a great performance cost", slices.len()); + tracing::warn!("One of your tiled textures has generated {} slices. You might want to use higher stretch values to avoid a great performance cost", slices.len()); } slices } diff --git a/crates/bevy_sprite/src/texture_slice/slicer.rs b/crates/bevy_sprite/src/texture_slice/slicer.rs index 310be42979..7250533550 100644 --- a/crates/bevy_sprite/src/texture_slice/slicer.rs +++ b/crates/bevy_sprite/src/texture_slice/slicer.rs @@ -217,7 +217,7 @@ impl TextureSlicer { if self.border.left + self.border.right >= rect.size().x || self.border.top + self.border.bottom >= rect.size().y { - bevy_utils::tracing::error!( + tracing::error!( "TextureSlicer::border has out of bounds values. No slicing will be applied" ); return vec![TextureSlice { diff --git a/crates/bevy_text/Cargo.toml b/crates/bevy_text/Cargo.toml index 80f89a6e5d..f322a4bddc 100644 --- a/crates/bevy_text/Cargo.toml +++ b/crates/bevy_text/Cargo.toml @@ -37,6 +37,7 @@ serde = { version = "1", features = ["derive"] } smallvec = "1.13" unicode-bidi = "0.3.13" sys-locale = "0.3.0" +tracing = { version = "0.1", default-features = false, features = ["std"] } [dev-dependencies] approx = "0.5.1" diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index 9ac844c099..bfefe283cf 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -10,10 +10,11 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{prelude::*, reflect::ReflectComponent}; use bevy_hierarchy::{Children, Parent}; use bevy_reflect::prelude::*; -use bevy_utils::warn_once; +use bevy_utils::once; use cosmic_text::{Buffer, Metrics}; use serde::{Deserialize, Serialize}; use smallvec::SmallVec; +use tracing::warn; /// Wrapper for [`cosmic_text::Buffer`] #[derive(Deref, DerefMut, Debug, Clone)] @@ -443,8 +444,8 @@ pub fn detect_text_needs_rerender( // - Root children changed (can include additions and removals). for root in changed_roots.iter() { let Ok((_, Some(mut computed), _)) = computed.get_mut(root) else { - warn_once!("found entity {} with a root text component ({}) but no ComputedTextBlock; this warning only \ - prints once", root, core::any::type_name::()); + once!(warn!("found entity {} with a root text component ({}) but no ComputedTextBlock; this warning only \ + prints once", root, core::any::type_name::())); continue; }; computed.needs_rerender = true; @@ -456,18 +457,18 @@ pub fn detect_text_needs_rerender( // - Span children changed (can include additions and removals). for (entity, maybe_span_parent, has_text_block) in changed_spans.iter() { if has_text_block { - warn_once!("found entity {} with a TextSpan that has a TextLayout, which should only be on root \ + once!(warn!("found entity {} with a TextSpan that has a TextLayout, which should only be on root \ text entities (that have {}); this warning only prints once", - entity, core::any::type_name::()); + entity, core::any::type_name::())); } let Some(span_parent) = maybe_span_parent else { - warn_once!( + once!(warn!( "found entity {} with a TextSpan that has no parent; it should have an ancestor \ with a root text component ({}); this warning only prints once", entity, core::any::type_name::() - ); + )); continue; }; let mut parent: Entity = **span_parent; @@ -477,9 +478,9 @@ pub fn detect_text_needs_rerender( // is outweighed by the expense of tracking visited spans. loop { let Ok((maybe_parent, maybe_computed, has_span)) = computed.get_mut(parent) else { - warn_once!("found entity {} with a TextSpan that is part of a broken hierarchy with a Parent \ + once!(warn!("found entity {} with a TextSpan that is part of a broken hierarchy with a Parent \ component that points at non-existent entity {}; this warning only prints once", - entity, parent); + entity, parent)); break; }; if let Some(mut computed) = maybe_computed { @@ -487,18 +488,18 @@ pub fn detect_text_needs_rerender( break; } if !has_span { - warn_once!("found entity {} with a TextSpan that has an ancestor ({}) that does not have a text \ + once!(warn!("found entity {} with a TextSpan that has an ancestor ({}) that does not have a text \ span component or a ComputedTextBlock component; this warning only prints once", - entity, parent); + entity, parent)); break; } let Some(next_parent) = maybe_parent else { - warn_once!( + once!(warn!( "found entity {} with a TextSpan that has no ancestor with the root text \ component ({}); this warning only prints once", entity, core::any::type_name::() - ); + )); break; }; parent = **next_parent; diff --git a/crates/bevy_time/Cargo.toml b/crates/bevy_time/Cargo.toml index e12b04423c..881b167753 100644 --- a/crates/bevy_time/Cargo.toml +++ b/crates/bevy_time/Cargo.toml @@ -26,6 +26,7 @@ bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } # other crossbeam-channel = "0.5.0" serde = { version = "1", features = ["derive"], optional = true } +tracing = { version = "0.1", default-features = false, features = ["std"] } [lints] workspace = true diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index 1e75c5484e..c72e139824 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -35,10 +35,11 @@ use bevy_ecs::{ event::{event_update_system, signal_event_update_system, EventRegistry, ShouldUpdateEvents}, prelude::*, }; -use bevy_utils::{tracing::warn, Instant}; +use bevy_utils::Instant; use core::time::Duration; pub use crossbeam_channel::TrySendError; use crossbeam_channel::{Receiver, Sender}; +use tracing::warn; /// Adds time functionality to Apps. #[derive(Default)] diff --git a/crates/bevy_time/src/virt.rs b/crates/bevy_time/src/virt.rs index 65dfb4b98c..702ebe196c 100644 --- a/crates/bevy_time/src/virt.rs +++ b/crates/bevy_time/src/virt.rs @@ -1,7 +1,7 @@ #[cfg(feature = "bevy_reflect")] use bevy_reflect::Reflect; -use bevy_utils::tracing::debug; use core::time::Duration; +use tracing::debug; use crate::{real::Real, time::Time}; diff --git a/crates/bevy_ui/Cargo.toml b/crates/bevy_ui/Cargo.toml index e8548a405d..55f592426a 100644 --- a/crates/bevy_ui/Cargo.toml +++ b/crates/bevy_ui/Cargo.toml @@ -41,6 +41,7 @@ derive_more = { version = "1", default-features = false, features = ["from"] } nonmax = "0.5" smallvec = "1.11" accesskit = "0.17" +tracing = { version = "0.1", default-features = false, features = ["std"] } [features] default = [] diff --git a/crates/bevy_ui/src/layout/debug.rs b/crates/bevy_ui/src/layout/debug.rs index 8a951cd97d..5cf5b2a328 100644 --- a/crates/bevy_ui/src/layout/debug.rs +++ b/crates/bevy_ui/src/layout/debug.rs @@ -27,7 +27,7 @@ pub fn print_ui_layout_tree(ui_surface: &UiSurface) { &mut out, ); } - bevy_utils::tracing::info!("Layout tree for camera entity: {entity}\n{out}"); + tracing::info!("Layout tree for camera entity: {entity}\n{out}"); } } diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 4c24ca322e..1646023d11 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -17,9 +17,9 @@ use bevy_math::{UVec2, Vec2}; use bevy_render::camera::{Camera, NormalizedRenderTarget}; use bevy_sprite::BorderRect; use bevy_transform::components::Transform; -use bevy_utils::tracing::warn; use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged}; use thiserror::Error; +use tracing::warn; use ui_surface::UiSurface; use bevy_text::ComputedTextBlock; diff --git a/crates/bevy_ui/src/render/render_pass.rs b/crates/bevy_ui/src/render/render_pass.rs index 1e3a9d81ba..97ae826b3e 100644 --- a/crates/bevy_ui/src/render/render_pass.rs +++ b/crates/bevy_ui/src/render/render_pass.rs @@ -16,7 +16,7 @@ use bevy_render::{ renderer::*, view::*, }; -use bevy_utils::tracing::error; +use tracing::error; pub struct UiPassNode { ui_view_query: QueryState<(&'static ViewTarget, &'static ExtractedCamera), With>, diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 7f14532fdd..47a4e2cf7a 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -10,12 +10,13 @@ use bevy_render::{ }; use bevy_sprite::BorderRect; use bevy_transform::components::Transform; -use bevy_utils::warn_once; +use bevy_utils::once; use bevy_window::{PrimaryWindow, WindowRef}; use core::num::NonZero; use derive_more::derive::From; use smallvec::SmallVec; use thiserror::Error; +use tracing::warn; /// Provides the computed size and layout properties of the node. /// @@ -2670,7 +2671,7 @@ impl<'w, 's> DefaultUiCamera<'w, 's> { self.default_cameras.get_single().ok().or_else(|| { // If there isn't a single camera and the query isn't empty, there is two or more cameras queried. if !self.default_cameras.is_empty() { - warn_once!("Two or more Entities with IsDefaultUiCamera found when only one Camera with this marker is allowed."); + once!(warn!("Two or more Entities with IsDefaultUiCamera found when only one Camera with this marker is allowed.")); } self.cameras .iter() diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index 7db65cd58c..6b0ee8c3cb 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -24,8 +24,9 @@ use bevy_text::{ TextBounds, TextColor, TextError, TextFont, TextLayout, TextLayoutInfo, TextMeasureInfo, TextPipeline, TextReader, TextRoot, TextSpanAccess, TextWriter, YAxisOrientation, }; -use bevy_utils::{tracing::error, Entry}; +use bevy_utils::Entry; use taffy::style::AvailableSpace; +use tracing::error; /// UI text system flags. /// diff --git a/crates/bevy_utils/Cargo.toml b/crates/bevy_utils/Cargo.toml index 2719b4372f..d681e5506d 100644 --- a/crates/bevy_utils/Cargo.toml +++ b/crates/bevy_utils/Cargo.toml @@ -9,28 +9,19 @@ license = "MIT OR Apache-2.0" keywords = ["bevy"] [features] -default = ["std", "serde", "tracing"] +default = ["std", "serde"] # Functionality ## Adds serialization support through `serde`. serde = ["hashbrown/serde"] -# Debugging Features - -## Enables `tracing` integration, allowing spans and other metrics to be reported -## through that framework. -tracing = ["dep:tracing"] - -## Enables more detailed reporting via `tracing`. -detailed_trace = ["tracing"] - # Platform Compatibility ## Allows access to the `std` crate. Enabling this feature will prevent compilation ## on `no_std` targets, but provides access to certain additional features on ## supported platforms. -std = ["alloc", "tracing?/std", "foldhash/std", "dep:thread_local"] +std = ["alloc", "foldhash/std", "dep:thread_local"] ## Allows access to the `alloc` crate. alloc = ["hashbrown"] @@ -45,7 +36,6 @@ portable-atomic = ["dep:portable-atomic"] [dependencies] foldhash = { version = "0.1.3", default-features = false } -tracing = { version = "0.1", default-features = false, optional = true } hashbrown = { version = "0.15.1", features = [ "equivalent", "raw-entry", diff --git a/crates/bevy_utils/src/lib.rs b/crates/bevy_utils/src/lib.rs index 7e094e2178..73d12f3197 100644 --- a/crates/bevy_utils/src/lib.rs +++ b/crates/bevy_utils/src/lib.rs @@ -63,8 +63,6 @@ pub use hashbrown; pub use parallel_queue::*; #[cfg(any(feature = "std", target_arch = "wasm32"))] pub use time::*; -#[cfg(feature = "tracing")] -pub use tracing; #[cfg(feature = "alloc")] use core::any::TypeId; @@ -377,17 +375,6 @@ impl Drop for OnDrop { } } -/// Like [`tracing::trace`], but conditional on cargo feature `detailed_trace`. -#[cfg(feature = "tracing")] -#[macro_export] -macro_rules! detailed_trace { - ($($tts:tt)*) => { - if cfg!(feature = "detailed_trace") { - $crate::tracing::trace!($($tts)*); - } - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/bevy_utils/src/once.rs b/crates/bevy_utils/src/once.rs index 23ca669257..cb5cd086e9 100644 --- a/crates/bevy_utils/src/once.rs +++ b/crates/bevy_utils/src/once.rs @@ -37,53 +37,3 @@ macro_rules! once { } }}; } - -/// Call [`trace!`](crate::tracing::trace) once per call site. -/// -/// Useful for logging within systems which are called every frame. -#[macro_export] -macro_rules! trace_once { - ($($arg:tt)+) => ({ - $crate::once!($crate::tracing::trace!($($arg)+)) - }); -} - -/// Call [`debug!`](crate::tracing::debug) once per call site. -/// -/// Useful for logging within systems which are called every frame. -#[macro_export] -macro_rules! debug_once { - ($($arg:tt)+) => ({ - $crate::once!($crate::tracing::debug!($($arg)+)) - }); -} - -/// Call [`info!`](crate::tracing::info) once per call site. -/// -/// Useful for logging within systems which are called every frame. -#[macro_export] -macro_rules! info_once { - ($($arg:tt)+) => ({ - $crate::once!($crate::tracing::info!($($arg)+)) - }); -} - -/// Call [`warn!`](crate::tracing::warn) once per call site. -/// -/// Useful for logging within systems which are called every frame. -#[macro_export] -macro_rules! warn_once { - ($($arg:tt)+) => ({ - $crate::once!($crate::tracing::warn!($($arg)+)) - }); -} - -/// Call [`error!`](crate::tracing::error) once per call site. -/// -/// Useful for logging within systems which are called every frame. -#[macro_export] -macro_rules! error_once { - ($($arg:tt)+) => ({ - $crate::once!($crate::tracing::error!($($arg)+)) - }); -} diff --git a/crates/bevy_winit/Cargo.toml b/crates/bevy_winit/Cargo.toml index 02ff9f56a7..d6a7007136 100644 --- a/crates/bevy_winit/Cargo.toml +++ b/crates/bevy_winit/Cargo.toml @@ -20,7 +20,6 @@ android-game-activity = ["winit/android-game-activity"] custom_cursor = ["bevy_image", "bevy_asset", "bytemuck", "wgpu-types"] - [dependencies] # bevy bevy_a11y = { path = "../bevy_a11y", version = "0.15.0-dev" } @@ -54,6 +53,7 @@ serde = { version = "1.0", features = ["derive"], optional = true } bytemuck = { version = "1.5", optional = true } wgpu-types = { version = "23", optional = true } accesskit = "0.17" +tracing = { version = "0.1", default-features = false, features = ["std"] } [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = { version = "0.2" } diff --git a/crates/bevy_winit/src/cursor.rs b/crates/bevy_winit/src/cursor.rs index 6a121dae22..c2a8139ef8 100644 --- a/crates/bevy_winit/src/cursor.rs +++ b/crates/bevy_winit/src/cursor.rs @@ -27,11 +27,11 @@ use bevy_ecs::{ #[cfg(feature = "custom_cursor")] use bevy_image::Image; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; -#[cfg(feature = "custom_cursor")] -use bevy_utils::tracing::warn; use bevy_utils::HashSet; use bevy_window::{SystemCursorIcon, Window}; #[cfg(feature = "custom_cursor")] +use tracing::warn; +#[cfg(feature = "custom_cursor")] use wgpu_types::TextureFormat; pub(crate) struct CursorPlugin; diff --git a/crates/bevy_winit/src/state.rs b/crates/bevy_winit/src/state.rs index 4a8927db07..f4666bab67 100644 --- a/crates/bevy_winit/src/state.rs +++ b/crates/bevy_winit/src/state.rs @@ -187,7 +187,7 @@ impl ApplicationHandler for WinitAppRunnerState { } #[cfg(feature = "trace")] - let _span = bevy_utils::tracing::info_span!("winit event_handler").entered(); + let _span = tracing::info_span!("winit event_handler").entered(); if self.app.plugins_state() != PluginsState::Cleaned { if self.app.plugins_state() != PluginsState::Ready { diff --git a/crates/bevy_winit/src/system.rs b/crates/bevy_winit/src/system.rs index 5a7a32d556..80ec6292a8 100644 --- a/crates/bevy_winit/src/system.rs +++ b/crates/bevy_winit/src/system.rs @@ -7,11 +7,11 @@ use bevy_ecs::{ system::{Local, NonSendMut, Query, SystemParamItem}, }; use bevy_input::keyboard::KeyboardFocusLost; -use bevy_utils::tracing::{error, info, warn}; use bevy_window::{ ClosingWindow, Monitor, PrimaryMonitor, RawHandleWrapper, VideoMode, Window, WindowClosed, WindowClosing, WindowCreated, WindowFocused, WindowMode, WindowResized, WindowWrapper, }; +use tracing::{error, info, warn}; use winit::{ dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize}, diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index 01c8a83301..45e7850807 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -2,11 +2,12 @@ use bevy_a11y::AccessibilityRequested; use bevy_ecs::entity::Entity; use bevy_ecs::entity::EntityHashMap; -use bevy_utils::{tracing::warn, HashMap}; +use bevy_utils::HashMap; use bevy_window::{ CursorGrabMode, MonitorSelection, Window, WindowMode, WindowPosition, WindowResolution, WindowWrapper, }; +use tracing::warn; use winit::{ dpi::{LogicalSize, PhysicalPosition}, @@ -375,7 +376,7 @@ pub(crate) fn attempt_grab( CursorGrabMode::None => "ungrab", }; - bevy_utils::tracing::error!("Unable to {} cursor: {}", err_desc, err); + tracing::error!("Unable to {} cursor: {}", err_desc, err); Err(err) } else { Ok(()) diff --git a/examples/app/log_layers.rs b/examples/app/log_layers.rs index 36fdb6c4e5..558d5b2ba5 100644 --- a/examples/app/log_layers.rs +++ b/examples/app/log_layers.rs @@ -1,9 +1,12 @@ //! This example illustrates how to add custom log layers in bevy. use bevy::{ - log::{tracing_subscriber::Layer, BoxedLayer}, + log::{ + tracing::{self, Subscriber}, + tracing_subscriber::Layer, + BoxedLayer, + }, prelude::*, - utils::tracing::Subscriber, }; struct CustomLayer; @@ -11,7 +14,7 @@ struct CustomLayer; impl Layer for CustomLayer { fn on_event( &self, - event: &bevy::utils::tracing::Event<'_>, + event: &tracing::Event<'_>, _ctx: bevy::log::tracing_subscriber::layer::Context<'_, S>, ) { println!("Got event!"); diff --git a/examples/app/log_layers_ecs.rs b/examples/app/log_layers_ecs.rs index 0ea064200a..30cba02b8d 100644 --- a/examples/app/log_layers_ecs.rs +++ b/examples/app/log_layers_ecs.rs @@ -15,11 +15,11 @@ use std::sync::mpsc; use bevy::{ log::{ + tracing::{self, Subscriber}, tracing_subscriber::{self, Layer}, BoxedLayer, Level, }, prelude::*, - utils::tracing::{self, Subscriber}, }; fn main() { diff --git a/examples/ecs/system_piping.rs b/examples/ecs/system_piping.rs index 9fa981a4bc..dec148cdfc 100644 --- a/examples/ecs/system_piping.rs +++ b/examples/ecs/system_piping.rs @@ -4,10 +4,7 @@ use bevy::prelude::*; use std::num::ParseIntError; -use bevy::{ - log::LogPlugin, - utils::tracing::{debug, error, info, Level}, -}; +use bevy::log::{debug, error, info, Level, LogPlugin}; fn main() { App::new() diff --git a/tools/example-showcase/disable-audio.patch b/tools/example-showcase/disable-audio.patch index b5aa015dd7..fa495d9f9c 100644 --- a/tools/example-showcase/disable-audio.patch +++ b/tools/example-showcase/disable-audio.patch @@ -5,9 +5,9 @@ index 3e8082e23..624769443 100644 @@ -7,7 +7,7 @@ use bevy_ecs::{prelude::*, system::SystemParam}; use bevy_math::Vec3; use bevy_transform::prelude::GlobalTransform; - use bevy_utils::tracing::warn; -use rodio::{OutputStream, OutputStreamHandle, Sink, Source, SpatialSink}; +use rodio::{OutputStreamHandle, Sink, Source, SpatialSink}; + use tracing::warn; use crate::{AudioSink, AudioSinkPlayback};