summaryrefslogtreecommitdiff
path: root/src/log.rs
diff options
context:
space:
mode:
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)
+ };
+}