Skip to content

Commit e9b8c71

Browse files
lee-orrmockersf
andauthored
move once from bevy_log to bevy_utils, to allow for it's use in bevy_ecs (#11419)
# 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: #11417 (comment) --------- Co-authored-by: François <[email protected]>
1 parent 6fbd585 commit e9b8c71

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

crates/bevy_log/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
//! For more fine-tuned control over logging behavior, set up the [`LogPlugin`] or
1212
//! `DefaultPlugins` during app initialization.
1313
14-
mod once;
15-
1614
#[cfg(feature = "trace")]
1715
use std::panic;
1816

@@ -31,12 +29,17 @@ pub mod prelude {
3129
debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span,
3230
};
3331

34-
pub use crate::{debug_once, error_once, info_once, trace_once, warn_once};
32+
#[doc(hidden)]
33+
pub use bevy_utils::{debug_once, error_once, info_once, once, trace_once, warn_once};
3534
}
3635

37-
pub use bevy_utils::tracing::{
38-
debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span,
39-
Level,
36+
pub use bevy_utils::{
37+
debug_once, error_once, info_once, once, trace_once,
38+
tracing::{
39+
debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, warn_span,
40+
Level,
41+
},
42+
warn_once,
4043
};
4144
pub use tracing_subscriber;
4245

crates/bevy_utils/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mod cow_arc;
2323
mod default;
2424
mod float_ord;
2525
pub mod intern;
26+
mod once;
2627

2728
pub use crate::uuid::Uuid;
2829
pub use ahash::{AHasher, RandomState};

crates/bevy_log/src/once.rs renamed to crates/bevy_utils/src/once.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,52 @@ macro_rules! once {
1111
}};
1212
}
1313

14-
/// Call [`trace!`](crate::trace) once per call site.
14+
/// Call [`trace!`](crate::tracing::trace) once per call site.
1515
///
1616
/// Useful for logging within systems which are called every frame.
1717
#[macro_export]
1818
macro_rules! trace_once {
1919
($($arg:tt)+) => ({
20-
$crate::once!($crate::trace!($($arg)+))
20+
$crate::once!($crate::tracing::trace!($($arg)+))
2121
});
2222
}
2323

24-
/// Call [`debug!`](crate::debug) once per call site.
24+
/// Call [`debug!`](crate::tracing::debug) once per call site.
2525
///
2626
/// Useful for logging within systems which are called every frame.
2727
#[macro_export]
2828
macro_rules! debug_once {
2929
($($arg:tt)+) => ({
30-
$crate::once!($crate::debug!($($arg)+))
30+
$crate::once!($crate::tracing::debug!($($arg)+))
3131
});
3232
}
3333

34-
/// Call [`info!`](crate::info) once per call site.
34+
/// Call [`info!`](crate::tracing::info) once per call site.
3535
///
3636
/// Useful for logging within systems which are called every frame.
3737
#[macro_export]
3838
macro_rules! info_once {
3939
($($arg:tt)+) => ({
40-
$crate::once!($crate::info!($($arg)+))
40+
$crate::once!($crate::tracing::info!($($arg)+))
4141
});
4242
}
4343

44-
/// Call [`warn!`](crate::warn) once per call site.
44+
/// Call [`warn!`](crate::tracing::warn) once per call site.
4545
///
4646
/// Useful for logging within systems which are called every frame.
4747
#[macro_export]
4848
macro_rules! warn_once {
4949
($($arg:tt)+) => ({
50-
$crate::once!($crate::warn!($($arg)+))
50+
$crate::once!($crate::tracing::warn!($($arg)+))
5151
});
5252
}
5353

54-
/// Call [`error!`](crate::error) once per call site.
54+
/// Call [`error!`](crate::tracing::error) once per call site.
5555
///
5656
/// Useful for logging within systems which are called every frame.
5757
#[macro_export]
5858
macro_rules! error_once {
5959
($($arg:tt)+) => ({
60-
$crate::once!($crate::error!($($arg)+))
60+
$crate::once!($crate::tracing::error!($($arg)+))
6161
});
6262
}

0 commit comments

Comments
 (0)