summaryrefslogtreecommitdiff
path: root/rola-utils/functions/src/log_macros.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-06-18 20:56:05 +0800
committer魏曹先生 <1992414357@qq.com>2026-06-18 20:56:05 +0800
commit68daa10abfe3015beca966825d32cf67c9f5d5d7 (patch)
treec28f0470240e7cdc3748cee57ef74353514c47b7 /rola-utils/functions/src/log_macros.rs
parent669898193bebeadc975881bee496fe0239df76a0 (diff)
feat(bucket): implement bucket initialization and logging infrastructure
Add bucket init logic with directory structure creation and log macros for tracing
Diffstat (limited to 'rola-utils/functions/src/log_macros.rs')
-rw-r--r--rola-utils/functions/src/log_macros.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/rola-utils/functions/src/log_macros.rs b/rola-utils/functions/src/log_macros.rs
new file mode 100644
index 0000000..4ee4e68
--- /dev/null
+++ b/rola-utils/functions/src/log_macros.rs
@@ -0,0 +1,53 @@
+//! Custom logging macros, with the same names as `log` crate's `trace!`, `debug!`, `info!`, `warn!`, `error!`,
+//! but different behavior: automatically prepend `file!()` information to the message.
+//!
+//! # Usage
+//! ```ignore
+//! trace!("value = {}", x);
+//! debug!("something happened");
+//! info!("user {} logged in", username);
+//! warn!("disk space low: {} GB", free);
+//! error!("failed to open file: {}", path);
+//! ```
+//!
+//! Expands to:
+//! ```ignore
+//! ::log::trace!("[{}]: {}", file!(), format!("value = {}", x));
+//! ::log::debug!("[{}]: {}", file!(), format!("something happened"));
+//! ...
+//! ```
+
+#[macro_export]
+macro_rules! trace {
+ ($($arg:tt)*) => {
+ ::log::trace!("[{}]: {}", file!(), format!($($arg)*));
+ };
+}
+
+#[macro_export]
+macro_rules! debug {
+ ($($arg:tt)*) => {
+ ::log::debug!("[{}]: {}", file!(), format!($($arg)*));
+ };
+}
+
+#[macro_export]
+macro_rules! info {
+ ($($arg:tt)*) => {
+ ::log::info!("[{}]: {}", file!(), format!($($arg)*));
+ };
+}
+
+#[macro_export]
+macro_rules! warn {
+ ($($arg:tt)*) => {
+ ::log::warn!("[{}]: {}", file!(), format!($($arg)*));
+ };
+}
+
+#[macro_export]
+macro_rules! error {
+ ($($arg:tt)*) => {
+ ::log::error!("[{}]: {}", file!(), format!($($arg)*));
+ };
+}