diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2023-06-12 05:01:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-12 01:01:07 -0400 |
commit | 531e26ea45e537a29dffe9438bc5085750574571 (patch) | |
tree | ac47a05d6b6422e79937dd6189f6a348e929a431 /src/utils | |
parent | cfdfd2bd3f6877ebe4fcfc9d359caeebbabf8911 (diff) |
other: post-0.9.2 cleanup (#1203)
* other: some cleanup
* other: add conditional logging macros
* more cleanup
* use compile-time feature for some text in clap
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/logging.rs | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/utils/logging.rs b/src/utils/logging.rs index ed1578d2..312c909f 100644 --- a/src/utils/logging.rs +++ b/src/utils/logging.rs @@ -1,4 +1,4 @@ -#[cfg(feature = "fern")] +#[cfg(feature = "logging")] pub fn init_logger( min_level: log::LevelFilter, debug_file_name: &std::ffi::OsStr, ) -> Result<(), fern::InitError> { @@ -28,3 +28,63 @@ pub fn init_logger( Ok(()) } + +#[macro_export] +macro_rules! c_debug { + ($($x:tt)*) => { + #[cfg(feature = "logging")] + { + log::debug!($($x)*) + } + }; +} + +#[macro_export] +macro_rules! c_error { + ($($x:tt)*) => { + #[cfg(feature = "logging")] + { + log::error!($($x)*) + } + }; +} + +#[macro_export] +macro_rules! c_info { + ($($x:tt)*) => { + #[cfg(feature = "logging")] + { + log::info!($($x)*) + } + }; +} + +#[macro_export] +macro_rules! c_log { + ($($x:tt)*) => { + #[cfg(feature = "logging")] + { + log::log!($($x)*) + } + }; +} + +#[macro_export] +macro_rules! c_trace { + ($($x:tt)*) => { + #[cfg(feature = "logging")] + { + log::trace!($($x)*) + } + }; +} + +#[macro_export] +macro_rules! c_warn { + ($($x:tt)*) => { + #[cfg(feature = "logging")] + { + log::warn!($($x)*) + } + }; +} |