From d7d2aae0537984faafb1f9b9aedded3e48bb5941 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 4 Feb 2020 18:29:04 +0100 Subject: log: log to stderr, not stdout --- log.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/log.c b/log.c index 61605944..6d6b9668 100644 --- a/log.c +++ b/log.c @@ -16,7 +16,7 @@ static bool colorize = false; static void __attribute__((constructor)) init(void) { - colorize = isatty(STDOUT_FILENO); + colorize = isatty(STDERR_FILENO); } void @@ -59,24 +59,24 @@ _log(enum log_class log_class, const char *module, const char *file, int lineno, char clr[16]; snprintf(clr, sizeof(clr), "\e[%dm", class_clr); - printf("%s%s%s: ", colorize ? clr : "", class, colorize ? "\e[0m" : ""); + fprintf(stderr, "%s%s%s: ", colorize ? clr : "", class, colorize ? "\e[0m" : ""); if (colorize) - printf("\e[2m"); + fprintf(stderr, "\e[2m"); #if defined(_DEBUG) - printf("%s:%d: ", file, lineno); + fprintf(stderr, "%s:%d: ", file, lineno); #else - printf("%s: ", module); + fprintf(stderr, "%s: ", module); #endif if (colorize) - printf("\e[0m"); + fprintf(stderr, "\e[0m"); - vprintf(fmt, va); + vfprintf(stderr, fmt, va); if (sys_errno != 0) - printf(": %s", strerror(sys_errno)); + fprintf(stderr, ": %s", strerror(sys_errno)); - printf("\n"); + fprintf(stderr, "\n"); } static void -- cgit v1.3