diagnostic: only print color if output is for the screen

This commit is contained in:
Damian Gryski 2012-07-26 23:50:20 +02:00 committed by Tim Chevalier
parent cdd052f6ea
commit ffb067640b

View File

@ -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]);