Skip to content

Commit 36d5074

Browse files
tedhorstbrson
authored andcommitted
log to stderr instead of stdout
includes rustc diagnostics runtest updated to check stderr for errors
1 parent 17110fb commit 36d5074

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)>,
@@ -202,10 +202,10 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
202202
}
203203
// Print the offending lines
204204
for line: uint in display_lines {
205-
io::stdout().write_str(#fmt["%s:%u ", fm.name, line + 1u]);
205+
io::stderr().write_str(#fmt["%s:%u ", fm.name, line + 1u]);
206206
let s = codemap::get_line(fm, line as int);
207207
if !str::ends_with(s, "\n") { s += "\n"; }
208-
io::stdout().write_str(s);
208+
io::stderr().write_str(s);
209209
}
210210
if elided {
211211
let last_line = display_lines[vec::len(display_lines) - 1u];
@@ -214,7 +214,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
214214
let out = "";
215215
while indent > 0u { out += " "; indent -= 1u; }
216216
out += "...\n";
217-
io::stdout().write_str(out);
217+
io::stderr().write_str(out);
218218
}
219219

220220

@@ -239,7 +239,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
239239
let width = hi.col - lo.col - 1u;
240240
while width > 0u { str::push_char(s, '~'); width -= 1u; }
241241
}
242-
io::stdout().write_str(s + "\n");
242+
io::stderr().write_str(s + "\n");
243243
}
244244
}
245245

src/compiletest/runtest.rs

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

199199
let next_err_idx = 0u;
200200
let next_err_pat = props.error_patterns[next_err_idx];
201-
for line: str in str::split_byte(procres.stdout, '\n' as u8) {
201+
for line: str in str::split_byte(procres.stderr, '\n' as u8) {
202202
if str::find(line, next_err_pat) > 0 {
203203
#debug("found error pattern %s", next_err_pat);
204204
next_err_idx += 1u;
@@ -245,7 +245,7 @@ fn check_expected_errors(expected_errors: [errors::expected_error],
245245
// filename:line1:col1: line2:col2: *warning:* msg
246246
// where line1:col1: is the starting point, line2:col2:
247247
// is the ending point, and * represents ANSI color codes.
248-
for line: str in str::split_byte(procres.stdout, '\n' as u8) {
248+
for line: str in str::split_byte(procres.stderr, '\n' as u8) {
249249
let was_expected = false;
250250
vec::iteri(expected_errors) {|i, ee|
251251
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)