diagnostic: only print color if output is for the screen
This commit is contained in:
parent
cdd052f6ea
commit
ffb067640b
1 changed files with 4 additions and 2 deletions
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue