From 6511d471bafd446026462ce0dba8ef5e2ebf462f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 19 Apr 2011 12:02:06 +0200 Subject: replace error logging with log_err in stdlib and rustc --- src/comp/driver/rustc.rs | 33 ++++++++++++++++----------------- src/comp/driver/session.rs | 36 ++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 35 deletions(-) (limited to 'src/comp/driver') diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index db069279..085a1f58 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -18,6 +18,7 @@ import std.option.some; import std.option.none; import std._str; import std._vec; +import std.io; fn default_environment(session.session sess, str argv0, @@ -88,26 +89,24 @@ impure fn pretty_print_input(session.session sess, } fn warn_wrong_compiler() { - log "This is the rust 'self-hosted' compiler."; - log "The one written in rust."; - log "It is currently incomplete."; - log "You may want rustboot instead, the compiler next door."; + io.stdout().write_str("This is the rust 'self-hosted' compiler. +The one written in rust. +It is currently incomplete. +You may want rustboot instead, the compiler next door.\n"); } fn usage(session.session sess, str argv0) { - log #fmt("usage: %s [options] ", argv0); - log "options:"; - log ""; - log " -o write output to "; - log " -nowarn suppress wrong-compiler warning"; - log " -glue generate glue.bc file"; - log " -shared compile a shared-library crate"; - log " -pp pretty-print the input instead of compiling"; - log " -ls list the symbols defined by a crate file"; - log " -L add a directory to the library search path"; - log " -h display this message"; - log ""; - log ""; + io.stdout().write_str(#fmt("usage: %s [options] \n", argv0) + " +options: + + -o write output to + -nowarn suppress wrong-compiler warning + -glue generate glue.bc file + -shared compile a shared-library crate + -pp pretty-print the input instead of compiling + -ls list the symbols defined by a crate file + -L add a directory to the library search path + -h display this message\n\n"); } fn get_os() -> session.os { diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs index 9cbbc94c..8e0f22b2 100644 --- a/src/comp/driver/session.rs +++ b/src/comp/driver/session.rs @@ -42,16 +42,16 @@ state obj session(ast.crate_num cnum, cfg targ, fn span_err(span sp, str msg) { auto lo = codemap.lookup_pos(cm, sp.lo); auto hi = codemap.lookup_pos(cm, sp.hi); - log #fmt("%s:%u:%u:%u:%u: error: %s", - lo.filename, - lo.line, lo.col, - hi.line, hi.col, - msg); + log_err #fmt("%s:%u:%u:%u:%u: error: %s", + lo.filename, + lo.line, lo.col, + hi.line, hi.col, + msg); fail; } fn err(str msg) { - log #fmt("error: %s", msg); + log_err #fmt("error: %s", msg); fail; } @@ -65,31 +65,31 @@ state obj session(ast.crate_num cnum, cfg targ, fn span_warn(span sp, str msg) { auto lo = codemap.lookup_pos(cm, sp.lo); auto hi = codemap.lookup_pos(cm, sp.hi); - log #fmt("%s:%u:%u:%u:%u: warning: %s", - lo.filename, - lo.line, lo.col, - hi.line, hi.col, - msg); + log_err #fmt("%s:%u:%u:%u:%u: warning: %s", + lo.filename, + lo.line, lo.col, + hi.line, hi.col, + msg); } fn bug(str msg) { - log #fmt("error: internal compiler error %s", msg); + log_err #fmt("error: internal compiler error %s", msg); fail; } fn span_unimpl(span sp, str msg) { auto lo = codemap.lookup_pos(cm, sp.lo); auto hi = codemap.lookup_pos(cm, sp.hi); - log #fmt("%s:%u:%u:%u:%u: error: unimplemented %s", - lo.filename, - lo.line, lo.col, - hi.line, hi.col, - msg); + log_err #fmt("%s:%u:%u:%u:%u: error: unimplemented %s", + lo.filename, + lo.line, lo.col, + hi.line, hi.col, + msg); fail; } fn unimpl(str msg) { - log #fmt("error: unimplemented %s", msg); + log_err #fmt("error: unimplemented %s", msg); fail; } -- cgit v1.2.3