| 2099 | |
| 2100 | bool ds4_log_is_tty(FILE *fp) { |
| 2101 | int fd = fileno(fp); |
| 2102 | return fd >= 0 && isatty(fd) != 0; |
| 2103 | } |
| 2104 | |
| 2105 | static void ds4_vlog(FILE *fp, ds4_log_type type, const char *fmt, va_list ap) { |
| 2106 | const bool colorize = type != DS4_LOG_DEFAULT && ds4_log_is_tty(fp); |
| 2107 | if (colorize) fputs(ds4_log_color_code(type), fp); |
| 2108 | vfprintf(fp, fmt, ap); |
| 2109 | if (colorize) fputs("\x1b[0m", fp); |
| 2110 | } |
| 2111 | |
| 2112 | void ds4_log(FILE *fp, ds4_log_type type, const char *fmt, ...) { |
nothing calls this directly
no outgoing calls
no test coverage detected