From e9b8c71da07ea03ac131d016a349911979eb6e80 Mon Sep 17 00:00:00 2001 From: Lee-Orr Date: Fri, 19 Jan 2024 01:07:41 -0500 Subject: [PATCH] move once from bevy_log to bevy_utils, to allow for it's use in bevy_ecs (#11419) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective When working within `bevy_ecs`, we can't use the `log_once` macros due to their placement in `bevy_log` - which depends on `bevy_ecs`. All this create does is migrate those macros to the `bevy_utils` crate, while still re-exporting them in `bevy_log`. created to resolve this: https://github.com/bevyengine/bevy/pull/11417#discussion_r1458100211 --------- Co-authored-by: François --- crates/bevy_log/src/lib.rs | 15 +++++++++------ crates/bevy_utils/src/lib.rs | 1 + crates/{bevy_log => bevy_utils}/src/once.rs | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 16 deletions(-) rename crates/{bevy_log => bevy_utils}/src/once.rs (64%) diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index ad07c9ec91..b60c154dc6 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -11,8 +11,6 @@ //! For more fine-tuned control over logging behavior, set up the [`LogPlugin`] or //! `DefaultPlugins` during app initialization. -mod once; - #[cfg(feature = "trace")] use std::panic; @@ -31,12 +29,17 @@ pub mod prelude { debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span, }; - pub use crate::{debug_once, error_once, info_once, trace_once, warn_once}; + #[doc(hidden)] + pub use bevy_utils::{debug_once, error_once, info_once, once, trace_once, warn_once}; } -pub use bevy_utils::tracing::{ - debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span, - Level, +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 tracing_subscriber; diff --git a/crates/bevy_utils/src/lib.rs b/crates/bevy_utils/src/lib.rs index aeef0b8918..37a8380e4d 100644 --- a/crates/bevy_utils/src/lib.rs +++ b/crates/bevy_utils/src/lib.rs @@ -23,6 +23,7 @@ mod cow_arc; mod default; mod float_ord; pub mod intern; +mod once; pub use crate::uuid::Uuid; pub use ahash::{AHasher, RandomState}; diff --git a/crates/bevy_log/src/once.rs b/crates/bevy_utils/src/once.rs similarity index 64% rename from crates/bevy_log/src/once.rs rename to crates/bevy_utils/src/once.rs index 9cac9f22e1..ce25120a5a 100644 --- a/crates/bevy_log/src/once.rs +++ b/crates/bevy_utils/src/once.rs @@ -11,52 +11,52 @@ macro_rules! once { }}; } -/// Call [`trace!`](crate::trace) once per call site. +/// 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::trace!($($arg)+)) + $crate::once!($crate::tracing::trace!($($arg)+)) }); } -/// Call [`debug!`](crate::debug) once per call site. +/// 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::debug!($($arg)+)) + $crate::once!($crate::tracing::debug!($($arg)+)) }); } -/// Call [`info!`](crate::info) once per call site. +/// 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::info!($($arg)+)) + $crate::once!($crate::tracing::info!($($arg)+)) }); } -/// Call [`warn!`](crate::warn) once per call site. +/// 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::warn!($($arg)+)) + $crate::once!($crate::tracing::warn!($($arg)+)) }); } -/// Call [`error!`](crate::error) once per call site. +/// 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::error!($($arg)+)) + $crate::once!($crate::tracing::error!($($arg)+)) }); }