Skip to content

Commit d65eabd

Browse files
tedhorstbrson
authored andcommitted
log to stderr instead of stdout
includes rustc diagnostics runtest updated to check stderr for errors
1 parent f10d0e1 commit d65eabd

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

src/comp/driver/diagnostic.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,16 @@ fn diagnosticcolor(lvl: level) -> u8 {
159159

160160
fn print_diagnostic(topic: str, lvl: level, msg: str) {
161161
if str::is_not_empty(topic) {
162-
io::stdout().write_str(#fmt["%s ", topic]);
162+
io::stderr().write_str(#fmt["%s ", topic]);
163163
}
164164
if term::color_supported() {
165-
term::fg(io::stdout(), diagnosticcolor(lvl));
165+
term::fg(io::stderr(), diagnosticcolor(lvl));
166166
}
167-
io::stdout().write_str(#fmt["%s:", diagnosticstr(lvl)]);
167+
io::stderr().write_str(#fmt["%s:", diagnosticstr(lvl)]);
168168
if term::color_supported() {
169-
term::reset(io::stdout());
169+
term::reset(io::stderr());
170170
}
171-
io::stdout().write_str(#fmt[" %s\n", msg]);
171+
io::stderr().write_str(#fmt[" %s\n", msg]);
172172
}
173173

174174
fn emit(cmsp: option<(codemap::codemap, span)>,
@@ -201,10 +201,10 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
201201
}
202202
// Print the offending lines
203203
for line: uint in display_lines {
204-
io::stdout().write_str(#fmt["%s:%u ", fm.name, line + 1u]);
204+
io::stderr().write_str(#fmt["%s:%u ", fm.name, line + 1u]);
205205
let s = codemap::get_line(fm, line as int);
206206
if !str::ends_with(s, "\n") { s += "\n"; }
207-
io::stdout().write_str(s);
207+
io::stderr().write_str(s);
208208
}
209209
if elided {
210210
let last_line = display_lines[vec::len(display_lines) - 1u];
@@ -213,7 +213,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
213213
let out = "";
214214
while indent > 0u { out += " "; indent -= 1u; }
215215
out += "...\n";
216-
io::stdout().write_str(out);
216+
io::stderr().write_str(out);
217217
}
218218

219219

@@ -238,6 +238,6 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
238238
let width = hi.col - lo.col - 1u;
239239
while width > 0u { str::push_char(s, '~'); width -= 1u; }
240240
}
241-
io::stdout().write_str(s + "\n");
241+
io::stderr().write_str(s + "\n");
242242
}
243243
}

src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn check_error_patterns(props: test_props,
199199

200200
let next_err_idx = 0u;
201201
let next_err_pat = props.error_patterns[next_err_idx];
202-
for line: str in str::split(procres.stdout, '\n' as u8) {
202+
for line: str in str::split(procres.stderr, '\n' as u8) {
203203
if str::find(line, next_err_pat) > 0 {
204204
#debug("found error pattern %s", next_err_pat);
205205
next_err_idx += 1u;
@@ -246,7 +246,7 @@ fn check_expected_errors(expected_errors: [errors::expected_error],
246246
// filename:line1:col1: line2:col2: *warning:* msg
247247
// where line1:col1: is the starting point, line2:col2:
248248
// is the ending point, and * represents ANSI color codes.
249-
for line: str in str::split(procres.stdout, '\n' as u8) {
249+
for line: str in str::split(procres.stderr, '\n' as u8) {
250250
let was_expected = false;
251251
vec::iteri(expected_errors) {|i, ee|
252252
if !found_flags[i] {

src/rt/rust_srv.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ rust_srv::realloc(void *p, size_t bytes) {
2525

2626
void
2727
rust_srv::log(char const *msg) {
28-
printf("rust: %s\n", msg);
29-
// FIXME: flushing each time is expensive, but at the moment
30-
// necessary to get output through before a rust_task::fail
31-
// call. This should be changed.
32-
fflush(stdout);
28+
fprintf(stderr, "rust: %s\n", msg);
3329
}
3430

3531
void

0 commit comments

Comments
 (0)