Skip to content

Commit

Permalink
diagnostic: only print color if output is for the screen
Browse files Browse the repository at this point in the history
  • Loading branch information
dgryski authored and catamorphism committed Jul 27, 2012
1 parent cdd052f commit ffb0676
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/libsyntax/diagnostic.rs
Expand Up @@ -163,14 +163,16 @@ fn diagnosticcolor(lvl: level) -> u8 {
}

fn print_diagnostic(topic: ~str, lvl: level, msg: ~str) {
let use_color = term::color_supported() &&
io::stderr().get_type() == io::screen;
if str::is_not_empty(topic) {
io::stderr().write_str(#fmt["%s ", topic]);
}
if term::color_supported() {
if use_color {
term::fg(io::stderr(), diagnosticcolor(lvl));
}
io::stderr().write_str(#fmt["%s:", diagnosticstr(lvl)]);
if term::color_supported() {
if use_color {
term::reset(io::stderr());
}
io::stderr().write_str(#fmt[" %s\n", msg]);
Expand Down

0 comments on commit ffb0676

Please sign in to comment.