}
}
- if (is_atty (this.stream.fileno ())) {
+ if (Log.writer_supports_color (this.stream.fileno ())) {
if (error_color != null) {
this.error_color_start = "\x1b[0" + error_color + "m";
this.error_color_end = ANSI_COLOR_END;
return true;
}
- [CCode (has_target = false)]
- private delegate int AttyFunc (int fd);
-
- private bool is_atty (int fd) {
- Module module = Module.open (null, ModuleFlags.LAZY);
- if (module == null) {
- return false;
- }
-
- void* _func;
- module.symbol ("isatty", out _func);
- if (_func == null) {
- module.symbol ("_isatty", out _func);
- if (_func == null) {
- return false;
- }
- }
-
- AttyFunc? func = (AttyFunc) _func;
- return func (fd) > 0;
- }
-
[PrintfFormat]
private inline void msg (string type, string type_color_start, string type_color_end, string file, long line, long startpos, long endpos,
string errline, string msg_format, va_list args)
}
}
- if (colored_output == Report.Colored.ALWAYS || (colored_output == Report.Colored.AUTO && is_atty (stderr.fileno ()))) {
+ if (colored_output == Report.Colored.ALWAYS || (colored_output == Report.Colored.AUTO && Log.writer_supports_color (stderr.fileno ()))) {
if (error_color != null) {
this.error_color_start = "\x1b[0" + error_color + "m";
this.error_color_end = ANSI_COLOR_END;
public static void error (SourceReference? source, string msg_format, ...) {
CodeContext.get ().report.err (source, msg_format.vprintf (va_list ()));
}
-
-
- [CCode (has_target = false)]
- private delegate int AttyFunc (int fd);
-
- private bool is_atty (int fd) {
- Module module = Module.open (null, ModuleFlags.LAZY);
- if (module == null) {
- return false;
- }
-
- void* _func;
- module.symbol ("isatty", out _func);
- if (_func == null) {
- module.symbol ("_isatty", out _func);
- if (_func == null) {
- return false;
- }
- }
-
- AttyFunc? func = (AttyFunc) _func;
- return func (fd) > 0;
- }
}