diff options
| author | bors <bors@rust-lang.org> | 2013-03-13 10:40:07 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-13 10:40:07 -0700 |
| commit | 695e9fd13cd71c87e9afc0903b3fb6856452d345 (patch) | |
| tree | 5c97280a8ddc0e2a797912c4b3007461841d1a74 /src/libsyntax | |
| parent | 0ad3a110be9070b87ecd7e1c71d20a02660d8959 (diff) | |
| parent | 9c7e16e48d15b3380cc680f6194fe3516867d2db (diff) | |
| download | rust-695e9fd13cd71c87e9afc0903b3fb6856452d345.tar.gz rust-695e9fd13cd71c87e9afc0903b3fb6856452d345.zip | |
auto merge of #5293 : brson/rust/logging, r=brson
r? @graydon This removes `log` from the language. Because we can't quite implement it as a syntax extension (probably need globals at the least) it simply renames the keyword to `__log` and hides it behind macros. After this the only way to log is with `debug!`, `info!`, etc. I figure that if there is demand for `log!` we can add it back later. I am not sure that we ever agreed on this course of action, though I *think* there is consensus that `log` shouldn't be a statement.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/ext/fmt.rs | 21 | ||||
| -rw-r--r-- | src/libsyntax/parse/comments.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/print/pp.rs | 2 |
6 files changed, 23 insertions, 24 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e61e8a1a594..831d1140a53 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -411,34 +411,34 @@ pub fn core_macros() -> ~str { macro_rules! error ( ($arg:expr) => ( - log(::core::error, fmt!( \"%?\", $arg )) + __log(1u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(::core::error, fmt!( $($arg),+ )) + __log(1u32, fmt!( $($arg),+ )) ) ) macro_rules! warn ( ($arg:expr) => ( - log(::core::warn, fmt!( \"%?\", $arg )) + __log(2u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(::core::warn, fmt!( $($arg),+ )) + __log(2u32, fmt!( $($arg),+ )) ) ) macro_rules! info ( ($arg:expr) => ( - log(::core::info, fmt!( \"%?\", $arg )) + __log(3u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(::core::info, fmt!( $($arg),+ )) + __log(3u32, fmt!( $($arg),+ )) ) ) macro_rules! debug ( ($arg:expr) => ( - log(::core::debug, fmt!( \"%?\", $arg )) + __log(4u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(::core::debug, fmt!( $($arg),+ )) + __log(4u32, fmt!( $($arg),+ )) ) ) diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index af558e6b330..ee0de9e48db 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -37,8 +37,7 @@ pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) expr_to_str(cx, args[0], ~"first argument to fmt! must be a string literal."); let fmtspan = args[0].span; - debug!("Format string:"); - log(debug, fmt); + debug!("Format string: %s", fmt); fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: &str) -> ! { cx.span_fatal(sp, msg); } @@ -223,7 +222,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } fn log_conv(c: Conv) { match c.param { - Some(p) => { log(debug, ~"param: " + p.to_str()); } + Some(p) => { debug!("param: %s", p.to_str()); } _ => debug!("param: none") } for c.flags.each |f| { @@ -236,18 +235,18 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } } match c.width { - CountIs(i) => log( - debug, ~"width: count is " + i.to_str()), - CountIsParam(i) => log( - debug, ~"width: count is param " + i.to_str()), + CountIs(i) => + debug!("width: count is %s", i.to_str()), + CountIsParam(i) => + debug!("width: count is param %s", i.to_str()), CountIsNextParam => debug!("width: count is next param"), CountImplied => debug!("width: count is implied") } match c.precision { - CountIs(i) => log( - debug, ~"prec: count is " + i.to_str()), - CountIsParam(i) => log( - debug, ~"prec: count is param " + i.to_str()), + CountIs(i) => + debug!("prec: count is %s", i.to_str()), + CountIsParam(i) => + debug!("prec: count is param %s", i.to_str()), CountIsNextParam => debug!("prec: count is next param"), CountImplied => debug!("prec: count is implied") } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 494ef3a81a0..360cdebc670 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -183,7 +183,7 @@ fn read_line_comments(rdr: @mut StringReader, code_to_the_left: bool, let mut lines: ~[~str] = ~[]; while rdr.curr == '/' && nextch(rdr) == '/' { let line = read_one_line_comment(rdr); - log(debug, line); + debug!("%s", line); if is_doc_comment(line) { // doc-comments are not put in comments break; } @@ -221,7 +221,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str], s1 = str::slice(s, col, len); } else { s1 = ~""; } } else { s1 = /*bad*/ copy s; } - log(debug, ~"pushing line: " + s1); + debug!("pushing line: %s", s1); lines.push(s1); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 51e36d9ec02..0c38b2f5ab5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1184,7 +1184,7 @@ pub impl Parser { } } hi = self.span.hi; - } else if self.eat_keyword(&~"log") { + } else if self.eat_keyword(&~"__log") { self.expect(&token::LPAREN); let lvl = self.parse_expr(); self.expect(&token::COMMA); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 81aacbf173d..c41b3aec09b 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -495,7 +495,7 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> { ~"else", ~"enum", ~"extern", ~"false", ~"fn", ~"for", ~"if", ~"impl", - ~"let", ~"log", ~"loop", + ~"let", ~"__log", ~"loop", ~"match", ~"mod", ~"mut", ~"once", ~"priv", ~"pub", ~"pure", diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 8557ef22fc6..7f46e452299 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -472,7 +472,7 @@ pub impl Printer { fn print(&mut self, x: token, L: int) { debug!("print %s %d (remaining line space=%d)", tok_str(x), L, self.space); - log(debug, buf_str(copy self.token, + debug!("%s", buf_str(copy self.token, copy self.size, self.left, self.right, |
