about summary refs log tree commit diff
path: root/src/libsyntax/ext/expand.rs
diff options
context:
space:
mode:
authorPhilipp Brüschweiler <blei42@gmail.com>2013-12-02 21:47:57 +0100
committerPhilipp Brüschweiler <blei42@gmail.com>2013-12-02 21:47:57 +0100
commita75f72d45a1c1399adab0e123acdb76582a360ae (patch)
tree5f99ea6941e8bebb6b7950f4b0adec6edc392faf /src/libsyntax/ext/expand.rs
parent61443dc1f5089df637edba83587b9f3020063266 (diff)
downloadrust-a75f72d45a1c1399adab0e123acdb76582a360ae.tar.gz
rust-a75f72d45a1c1399adab0e123acdb76582a360ae.zip
Add a macro to check if logging at a given label is enabled
This is useful when the information that is needed to do useful logging
is expensive to produce.
Diffstat (limited to 'src/libsyntax/ext/expand.rs')
-rw-r--r--src/libsyntax/ext/expand.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index acf0326aefd..1d040c10984 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -754,6 +754,13 @@ pub fn std_macros() -> @str {
         if cfg!(not(ndebug)) { log!(4u32, $($arg)*) }
     ))
 
+    macro_rules! log_enabled(
+        ($lvl:expr) => ( {
+            let lvl = $lvl;
+            lvl <= __log_level() && (lvl != 4 || cfg!(not(ndebug)))
+        } )
+    )
+
     macro_rules! fail(
         () => (
             fail!("explicit failure")