about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-08 12:27:39 -0800
committerbors <bors@rust-lang.org>2013-03-08 12:27:39 -0800
commiteaed16cea6c83c49bfb3d4a663f9b715f86d1f37 (patch)
treeb36b1e90ed9915362fc260554ab3b44da15eb4bb /src/libsyntax
parentac3dc66ec14100c04de232b2aba366301a05a837 (diff)
parentdd4d45062d8a9715250e2b912d8fcf4817e3995e (diff)
downloadrust-eaed16cea6c83c49bfb3d4a663f9b715f86d1f37.tar.gz
rust-eaed16cea6c83c49bfb3d4a663f9b715f86d1f37.zip
auto merge of #5278 : brson/rust/logplusplus, r=brson
r?

`log` can  polymorphically log anything, but debug!, etc. requires a format string. With this patch you can equivalently write `debug!(foo)` or `debug!("%?", foo)`.

I'm doing this because I was trying to remove `log` (replacing it with nothing, at least temporarily), but there are a number of logging statements that just want to print an arbitrary value and don't care about the format string.

I'm not entirely convinced this is a good change, since it overloads the implementation of these macros and makes their usage slightly more nuanced.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/expand.rs40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index f76f10f3de1..e61e8a1a594 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -409,14 +409,38 @@ pub fn core_macros() -> ~str {
 ~"pub mod macros {
     macro_rules! ignore (($($x:tt)*) => (()))
 
-    macro_rules! error ( ($( $arg:expr ),+) => (
-        log(::core::error, fmt!( $($arg),+ )) ))
-    macro_rules! warn ( ($( $arg:expr ),+) => (
-        log(::core::warn, fmt!( $($arg),+ )) ))
-    macro_rules! info ( ($( $arg:expr ),+) => (
-        log(::core::info, fmt!( $($arg),+ )) ))
-    macro_rules! debug ( ($( $arg:expr ),+) => (
-        log(::core::debug, fmt!( $($arg),+ )) ))
+    macro_rules! error (
+        ($arg:expr) => (
+            log(::core::error, fmt!( \"%?\", $arg ))
+        );
+        ($( $arg:expr ),+) => (
+            log(::core::error, fmt!( $($arg),+ ))
+        )
+    )
+    macro_rules! warn (
+        ($arg:expr) => (
+            log(::core::warn, fmt!( \"%?\", $arg ))
+        );
+        ($( $arg:expr ),+) => (
+            log(::core::warn, fmt!( $($arg),+ ))
+        )
+    )
+    macro_rules! info (
+        ($arg:expr) => (
+            log(::core::info, fmt!( \"%?\", $arg ))
+        );
+        ($( $arg:expr ),+) => (
+            log(::core::info, fmt!( $($arg),+ ))
+        )
+    )
+    macro_rules! debug (
+        ($arg:expr) => (
+            log(::core::debug, fmt!( \"%?\", $arg ))
+        );
+        ($( $arg:expr ),+) => (
+            log(::core::debug, fmt!( $($arg),+ ))
+        )
+    )
 
     macro_rules! fail(
         ($msg: expr) => (