Skip to content

Make the new logging macros a first-class citizen #10006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 14 additions & 14 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -700,15 +700,15 @@ mod math {
type complex = (f64, f64);
fn sin(f: f64) -> f64 {
...
# fail2!();
# fail!();
}
fn cos(f: f64) -> f64 {
...
# fail2!();
# fail!();
}
fn tan(f: f64) -> f64 {
...
# fail2!();
# fail!();
}
}
~~~~
Expand Down Expand Up @@ -1059,8 +1059,8 @@ output slot type would normally be. For example:

~~~~
fn my_err(s: &str) -> ! {
info2!("{}", s);
fail2!();
info!("{}", s);
fail!();
}
~~~~

Expand All @@ -1078,7 +1078,7 @@ were declared without the `!` annotation, the following code would not
typecheck:

~~~~
# fn my_err(s: &str) -> ! { fail2!() }
# fn my_err(s: &str) -> ! { fail!() }

fn f(i: int) -> int {
if i == 42 {
Expand Down Expand Up @@ -2826,9 +2826,9 @@ enum List<X> { Nil, Cons(X, @List<X>) }
let x: List<int> = Cons(10, @Cons(11, @Nil));

match x {
Cons(_, @Nil) => fail2!("singleton list"),
Cons(_, @Nil) => fail!("singleton list"),
Cons(*) => return,
Nil => fail2!("empty list")
Nil => fail!("empty list")
}
~~~~

Expand Down Expand Up @@ -2864,7 +2864,7 @@ match x {
return;
}
_ => {
fail2!();
fail!();
}
}
~~~~
Expand Down Expand Up @@ -2918,7 +2918,7 @@ guard may refer to the variables bound within the pattern they follow.
let message = match maybe_digit {
Some(x) if x < 10 => process_digit(x),
Some(x) => process_other(x),
None => fail2!()
None => fail!()
};
~~~~

Expand Down Expand Up @@ -3669,10 +3669,10 @@ that demonstrates all four of them:

~~~~
fn main() {
error2!("This is an error log")
warn2!("This is a warn log")
info2!("this is an info log")
debug2!("This is a debug log")
error!("This is an error log")
warn!("This is a warn log")
info!("this is an info log")
debug!("This is a debug log")
}
~~~~

Expand Down
6 changes: 3 additions & 3 deletions doc/tutorial-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ match x {
// complicated stuff goes here
return result + val;
},
_ => fail2!("Didn't get good_2")
_ => fail!("Didn't get good_2")
}
}
_ => return 0 // default value
Expand Down Expand Up @@ -268,7 +268,7 @@ macro_rules! biased_match (
biased_match!((x) ~ (good_1(g1, val)) else { return 0 };
binds g1, val )
biased_match!((g1.body) ~ (good_2(result) )
else { fail2!("Didn't get good_2") };
else { fail!("Didn't get good_2") };
binds result )
// complicated stuff goes here
return result + val;
Expand Down Expand Up @@ -369,7 +369,7 @@ macro_rules! biased_match (
# fn f(x: t1) -> uint {
biased_match!(
(x) ~ (good_1(g1, val)) else { return 0 };
(g1.body) ~ (good_2(result) ) else { fail2!("Didn't get good_2") };
(g1.body) ~ (good_2(result) ) else { fail!("Didn't get good_2") };
binds val, result )
// complicated stuff goes here
return result + val;
Expand Down
8 changes: 4 additions & 4 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ unit, `()`, as the empty tuple if you like).
~~~~
let mytup: (int, int, f64) = (10, 20, 30.0);
match mytup {
(a, b, c) => info2!("{}", a + b + (c as int))
(a, b, c) => info!("{}", a + b + (c as int))
}
~~~~

Expand All @@ -779,7 +779,7 @@ For example:
struct MyTup(int, int, f64);
let mytup: MyTup = MyTup(10, 20, 30.0);
match mytup {
MyTup(a, b, c) => info2!("{}", a + b + (c as int))
MyTup(a, b, c) => info!("{}", a + b + (c as int))
}
~~~~

Expand Down Expand Up @@ -1576,7 +1576,7 @@ arguments.
use std::task::spawn;

do spawn() || {
debug2!("I'm a task, whatever");
debug!("I'm a task, whatever");
}
~~~~

Expand All @@ -1588,7 +1588,7 @@ may be omitted from `do` expressions.
use std::task::spawn;

do spawn {
debug2!("Kablam!");
debug!("Kablam!");
}
~~~~

Expand Down
14 changes: 7 additions & 7 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ pub fn parse_config(args: ~[~str]) -> config {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println(getopts::groups::usage(message, groups));
println("");
fail2!()
fail!()
}

let matches =
&match getopts::groups::getopts(args_, groups) {
Ok(m) => m,
Err(f) => fail2!("{}", f.to_err_msg())
Err(f) => fail!("{}", f.to_err_msg())
};

if matches.opt_present("h") || matches.opt_present("help") {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println(getopts::groups::usage(message, groups));
println("");
fail2!()
fail!()
}

fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
Expand Down Expand Up @@ -203,7 +203,7 @@ pub fn str_mode(s: ~str) -> mode {
~"pretty" => mode_pretty,
~"debug-info" => mode_debug_info,
~"codegen" => mode_codegen,
_ => fail2!("invalid mode")
_ => fail!("invalid mode")
}
}

Expand All @@ -226,7 +226,7 @@ pub fn run_tests(config: &config) {
// For context, see #8904
rt::test::prepare_for_lots_of_tests();
let res = test::run_tests_console(&opts, tests);
if !res { fail2!("Some tests failed"); }
if !res { fail!("Some tests failed"); }
}

pub fn test_opts(config: &config) -> test::TestOpts {
Expand All @@ -244,13 +244,13 @@ pub fn test_opts(config: &config) -> test::TestOpts {
}

pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
debug2!("making tests from {}",
debug!("making tests from {}",
config.src_base.display());
let mut tests = ~[];
let dirs = os::list_dir_path(&config.src_base);
for file in dirs.iter() {
let file = file.clone();
debug2!("inspecting file {}", file.display());
debug!("inspecting file {}", file.display());
if is_test(config, &file) {
let t = do make_test(config, &file) {
match config.mode {
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[ExpectedError] {
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
let msg = line.slice(idx, len).to_owned();

debug2!("line={} kind={} msg={}", line_num - adjust_line, kind, msg);
debug!("line={} kind={} msg={}", line_num - adjust_line, kind, msg);

return ~[ExpectedError{line: line_num - adjust_line, kind: kind,
msg: msg}];
Expand Down
4 changes: 2 additions & 2 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
let end = strs.pop();
(strs.pop(), end)
}
n => fail2!("Expected 1 or 2 strings, not {}", n)
n => fail!("Expected 1 or 2 strings, not {}", n)
}
}
}
Expand Down Expand Up @@ -183,7 +183,7 @@ fn parse_name_value_directive(line: &str,
Some(colon) => {
let value = line.slice(colon + keycolon.len(),
line.len()).to_owned();
debug2!("{}: {}", directive, value);
debug!("{}: {}", directive, value);
Some(value)
}
None => None
Expand Down
20 changes: 10 additions & 10 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {
io::stdout().write_str("\n\n");
}
let testfile = Path::new(testfile);
debug2!("running {}", testfile.display());
debug!("running {}", testfile.display());
let props = load_props(&testfile);
debug2!("loaded props");
debug!("loaded props");
match config.mode {
mode_compile_fail => run_cfail_test(&config, &props, &testfile),
mode_run_fail => run_rfail_test(&config, &props, &testfile),
Expand Down Expand Up @@ -241,7 +241,7 @@ actual:\n\
\n",
expected, actual);
io::stdout().write_str(msg);
fail2!();
fail!();
}
}

Expand Down Expand Up @@ -289,7 +289,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
let script_str = [~"set charset UTF-8",
cmds,
~"quit\n"].connect("\n");
debug2!("script_str = {}", script_str);
debug!("script_str = {}", script_str);
dump_output_file(config, testfile, script_str, "debugger.script");

// run debugger script with gdb
Expand Down Expand Up @@ -348,10 +348,10 @@ fn check_error_patterns(props: &TestProps,
let mut done = false;
for line in ProcRes.stderr.line_iter() {
if line.contains(*next_err_pat) {
debug2!("found error pattern {}", *next_err_pat);
debug!("found error pattern {}", *next_err_pat);
next_err_idx += 1u;
if next_err_idx == props.error_patterns.len() {
debug2!("found all error patterns");
debug!("found all error patterns");
done = true;
break;
}
Expand Down Expand Up @@ -423,7 +423,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
let mut was_expected = false;
for (i, ee) in expected_errors.iter().enumerate() {
if !found_flags[i] {
debug2!("prefix={} ee.kind={} ee.msg={} line={}",
debug!("prefix={} ee.kind={} ee.msg={} line={}",
prefixes[i], ee.kind, ee.msg, line);
if (prefix_matches(line, prefixes[i]) &&
line.contains(ee.kind) &&
Expand Down Expand Up @@ -626,7 +626,7 @@ fn compose_and_run_compiler(
fn ensure_dir(path: &Path) {
if os::path_is_dir(path) { return; }
if !os::make_dir(path, 0x1c0i32) {
fail2!("can't make dir {}", path.display());
fail!("can't make dir {}", path.display());
}
}

Expand Down Expand Up @@ -784,7 +784,7 @@ fn maybe_dump_to_stdout(config: &config, out: &str, err: &str) {

fn error(err: ~str) { io::stdout().write_line(format!("\nerror: {}", err)); }

fn fatal(err: ~str) -> ! { error(err); fail2!(); }
fn fatal(err: ~str) -> ! { error(err); fail!(); }

fn fatal_ProcRes(err: ~str, ProcRes: &ProcRes) -> ! {
let msg =
Expand All @@ -802,7 +802,7 @@ stderr:\n\
\n",
err, ProcRes.cmdline, ProcRes.stdout, ProcRes.stderr);
io::stdout().write_str(msg);
fail2!();
fail!();
}

fn _arm_exec_compiled_test(config: &config, props: &TestProps,
Expand Down
4 changes: 2 additions & 2 deletions src/compiletest/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn get_os(triple: &str) -> &'static str {
return os
}
}
fail2!("Cannot determine OS from triple");
fail!("Cannot determine OS from triple");
}

pub fn make_new_path(path: &str) -> ~str {
Expand Down Expand Up @@ -63,6 +63,6 @@ pub fn path_div() -> ~str { ~":" }
pub fn path_div() -> ~str { ~";" }

pub fn logv(config: &config, s: ~str) {
debug2!("{}", s);
debug!("{}", s);
if config.verbose { io::println(s); }
}
10 changes: 5 additions & 5 deletions src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<T:Send> MutexArc<T> {
let inner = x.unwrap();
let MutexArcInner { failed: failed, data: data, _ } = inner;
if failed {
fail2!("Can't unwrap poisoned MutexArc - another task failed inside!");
fail!("Can't unwrap poisoned MutexArc - another task failed inside!");
}
data
}
Expand Down Expand Up @@ -300,9 +300,9 @@ impl<T:Freeze + Send> MutexArc<T> {
fn check_poison(is_mutex: bool, failed: bool) {
if failed {
if is_mutex {
fail2!("Poisoned MutexArc - another task failed inside!");
fail!("Poisoned MutexArc - another task failed inside!");
} else {
fail2!("Poisoned rw_arc - another task failed inside!");
fail!("Poisoned rw_arc - another task failed inside!");
}
}
}
Expand Down Expand Up @@ -505,7 +505,7 @@ impl<T:Freeze + Send> RWArc<T> {
let inner = x.unwrap();
let RWArcInner { failed: failed, data: data, _ } = inner;
if failed {
fail2!("Can't unwrap poisoned RWArc - another task failed inside!")
fail!("Can't unwrap poisoned RWArc - another task failed inside!")
}
data
}
Expand Down Expand Up @@ -619,7 +619,7 @@ mod tests {
assert_eq!(arc_v.get()[2], 3);
assert_eq!(arc_v.get()[4], 5);

info2!("{:?}", arc_v);
info!("{:?}", arc_v);
}

#[test]
Expand Down
Loading