summaryrefslogtreecommitdiff
path: root/src/log.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-06-26 21:03:36 +0100
committertcmal <me@aria.rip>2024-06-26 21:51:48 +0100
commit6785d154460921cc3b774376a676a226402d8270 (patch)
tree865544599227908a77e0f6ef1b00e03ca382f567 /src/log.rs
parentf7f0df71657df790259f5358617901cf4142faf9 (diff)
add logging macros for debug mode only printing
Diffstat (limited to 'src/log.rs')
-rw-r--r--src/log.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/log.rs b/src/log.rs
new file mode 100644
index 0000000..5be30d3
--- /dev/null
+++ b/src/log.rs
@@ -0,0 +1,24 @@
+//! Helper macros for logging
+
+/// Log to standard error, only compiled when in debug mode.
+#[macro_export]
+macro_rules! debug {
+ ($($e:expr),*) => {
+ #[cfg(debug_assertions)]
+ {
+ eprintln!($($e),*);
+ }
+ };
+}
+
+/// Log a request / cookie when `debug_assertions` are on
+#[macro_export]
+macro_rules! debug_req {
+ ($req:ident) => {
+ crate::debug!("seq ?: {:?}", $req)
+ };
+ ($req:ident, $cookie:ident) => {
+ use xcb::Cookie;
+ crate::debug!("seq {}: {:?}", $cookie.sequence(), $req)
+ };
+}