From 029e1c630a597a0ba67ea2906c7f297294e55981 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 8 Jun 2024 01:13:20 +0000 Subject: [PATCH] split core log into directory Signed-off-by: Jason Volk --- src/core/log/mod.rs | 33 ++++++++++++++++++++++++++++++ src/core/{log.rs => log/reload.rs} | 26 +---------------------- 2 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 src/core/log/mod.rs rename src/core/{log.rs => log/reload.rs} (79%) diff --git a/src/core/log/mod.rs b/src/core/log/mod.rs new file mode 100644 index 00000000..aac25ec2 --- /dev/null +++ b/src/core/log/mod.rs @@ -0,0 +1,33 @@ +mod reload; + +pub use reload::ReloadHandle; +pub use reload::LogLevelReloadHandles; + +// Wraps for logging macros. Use these macros rather than extern tracing:: or log:: crates in +// project code. ::log and ::tracing can still be used if necessary but discouraged. Remember +// debug_ log macros are also exported to the crate namespace like these. + +#[macro_export] +macro_rules! error { + ( $($x:tt)+ ) => { tracing::error!( $($x)+ ); } +} + +#[macro_export] +macro_rules! warn { + ( $($x:tt)+ ) => { tracing::warn!( $($x)+ ); } +} + +#[macro_export] +macro_rules! info { + ( $($x:tt)+ ) => { tracing::info!( $($x)+ ); } +} + +#[macro_export] +macro_rules! debug { + ( $($x:tt)+ ) => { tracing::debug!( $($x)+ ); } +} + +#[macro_export] +macro_rules! trace { + ( $($x:tt)+ ) => { tracing::trace!( $($x)+ ); } +} diff --git a/src/core/log.rs b/src/core/log/reload.rs similarity index 79% rename from src/core/log.rs rename to src/core/log/reload.rs index eae25eb0..7646254e 100644 --- a/src/core/log.rs +++ b/src/core/log/reload.rs @@ -49,31 +49,7 @@ impl LogLevelReloadHandles { for handle in &self.inner.handles { handle.reload(new_value.clone())?; } + Ok(()) } } - -#[macro_export] -macro_rules! error { - ( $($x:tt)+ ) => { tracing::error!( $($x)+ ); } -} - -#[macro_export] -macro_rules! warn { - ( $($x:tt)+ ) => { tracing::warn!( $($x)+ ); } -} - -#[macro_export] -macro_rules! info { - ( $($x:tt)+ ) => { tracing::info!( $($x)+ ); } -} - -#[macro_export] -macro_rules! debug { - ( $($x:tt)+ ) => { tracing::debug!( $($x)+ ); } -} - -#[macro_export] -macro_rules! trace { - ( $($x:tt)+ ) => { tracing::trace!( $($x)+ ); } -}