diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-08-27 23:12:05 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-09-05 01:48:20 -0700 |
| commit | 8a966183fe5129ea2a55a9898ac1bd0f16f3573d (patch) | |
| tree | 8e222f4e505499610a935accf49b73e5ee8e2a89 /src/libsyntax/ext | |
| parent | 3c3ae1d0e26c9ae0906dc57daa14bb9e4627e3c8 (diff) | |
| download | rust-8a966183fe5129ea2a55a9898ac1bd0f16f3573d.tar.gz rust-8a966183fe5129ea2a55a9898ac1bd0f16f3573d.zip | |
Remove the __log function for __log_level
Also redefine all of the standard logging macros to use more rust code instead of custom LLVM translation code. This makes them a bit easier to understand, but also more flexibile for future types of logging. Additionally, this commit removes the LogType language item in preparation for changing how logging is performed.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 88 |
1 files changed, 35 insertions, 53 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 7e48fe4d419..00248425ee6 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -740,59 +740,41 @@ pub fn std_macros() -> @str { macro_rules! ignore (($($x:tt)*) => (())) - macro_rules! error ( - ($arg:expr) => ( - __log(1u32, fmt!( \"%?\", $arg )) - ); - ($( $arg:expr ),+) => ( - __log(1u32, fmt!( $($arg),+ )) - ) - ) - - macro_rules! warn ( - ($arg:expr) => ( - __log(2u32, fmt!( \"%?\", $arg )) - ); - ($( $arg:expr ),+) => ( - __log(2u32, fmt!( $($arg),+ )) - ) - ) - - macro_rules! info ( - ($arg:expr) => ( - __log(3u32, fmt!( \"%?\", $arg )) - ); - ($( $arg:expr ),+) => ( - __log(3u32, fmt!( $($arg),+ )) - ) - ) - - macro_rules! debug ( - ($arg:expr) => ( - if cfg!(debug) { __log(4u32, fmt!( \"%?\", $arg )) } - ); - ($( $arg:expr ),+) => ( - if cfg!(debug) { __log(4u32, fmt!( $($arg),+ )) } - ) - ) - - macro_rules! error2 ( - ($($arg:tt)*) => ( __log(1u32, format!($($arg)*))) - ) - - macro_rules! warn2 ( - ($($arg:tt)*) => ( __log(2u32, format!($($arg)*))) - ) - - macro_rules! info2 ( - ($($arg:tt)*) => ( __log(3u32, format!($($arg)*))) + macro_rules! log( + ($lvl:expr, $arg:expr) => ({ + let lvl = $lvl; + if lvl <= __log_level() { + ::std::logging::log(lvl, fmt!(\"%?\", $arg)) + } + }); + ($lvl:expr, $($arg:expr),+) => ({ + let lvl = $lvl; + if lvl <= __log_level() { + ::std::logging::log(lvl, fmt!($($arg),+)) + } + }) ) - - macro_rules! debug2 ( - ($($arg:tt)*) => ( - if cfg!(debug) { __log(4u32, format!($($arg)*)) } - ) + macro_rules! error( ($($arg:tt)+) => (log!(1u32, $($arg)+)) ) + macro_rules! warn ( ($($arg:tt)+) => (log!(2u32, $($arg)+)) ) + macro_rules! info ( ($($arg:tt)+) => (log!(3u32, $($arg)+)) ) + macro_rules! debug( ($($arg:tt)+) => ( + if cfg!(debug) { log!(4u32, $($arg)+) } + )) + + macro_rules! log2( + ($lvl:expr, $($arg:tt)+) => ({ + let lvl = $lvl; + if lvl <= __log_level() { + ::std::logging::log(lvl, format!($($arg)+)) + } + }) ) + macro_rules! error2( ($($arg:tt)+) => (log2!(1u32, $($arg)+)) ) + macro_rules! warn2 ( ($($arg:tt)+) => (log2!(2u32, $($arg)+)) ) + macro_rules! info2 ( ($($arg:tt)+) => (log2!(3u32, $($arg)+)) ) + macro_rules! debug2( ($($arg:tt)+) => ( + if cfg!(debug) { log2!(4u32, $($arg)+) } + )) macro_rules! fail( () => ( @@ -989,13 +971,13 @@ pub fn std_macros() -> @str { // allocation but should rather delegate to an invocation of // write! instead of format! macro_rules! print ( - ($($arg:tt)+) => ( ::std::io::print(format!($($arg)+))) + ($($arg:tt)+) => (::std::io::print(format!($($arg)+))) ) // FIXME(#6846) once stdio is redesigned, this shouldn't perform an // allocation but should rather delegate to an io::Writer macro_rules! println ( - ($($arg:tt)+) => ({ print!($($arg)+); ::std::io::println(\"\"); }) + ($($arg:tt)+) => (::std::io::println(format!($($arg)+))) ) // NOTE: use this after a snapshot lands to abstract the details |
