diff options
author | 2015-08-23 13:16:37 -0400 | |
---|---|---|
committer | 2015-08-23 13:17:53 -0400 | |
commit | e2322414666488945ffcbcab06f9cca95ff731d3 (patch) | |
tree | 93325db3fc39393f1d876b88e80b90ed5695e472 /sway | |
parent | Handle wlc log events (diff) | |
download | sway-e2322414666488945ffcbcab06f9cca95ff731d3.tar.gz sway-e2322414666488945ffcbcab06f9cca95ff731d3.tar.zst sway-e2322414666488945ffcbcab06f9cca95ff731d3.zip |
Do not log with colors unless stdout is a tty
Diffstat (limited to 'sway')
-rw-r--r-- | sway/log.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -53,7 +53,7 @@ void sway_log(log_importance_t verbosity, const char* format, ...) { | |||
53 | c = sizeof(verbosity_colors) / sizeof(char *) - 1; | 53 | c = sizeof(verbosity_colors) / sizeof(char *) - 1; |
54 | } | 54 | } |
55 | 55 | ||
56 | if (colored) { | 56 | if (colored && isatty(STDERR_FILENO)) { |
57 | fprintf(stderr, "%s", verbosity_colors[c]); | 57 | fprintf(stderr, "%s", verbosity_colors[c]); |
58 | } | 58 | } |
59 | 59 | ||
@@ -62,7 +62,7 @@ void sway_log(log_importance_t verbosity, const char* format, ...) { | |||
62 | vfprintf(stderr, format, args); | 62 | vfprintf(stderr, format, args); |
63 | va_end(args); | 63 | va_end(args); |
64 | 64 | ||
65 | if (colored) { | 65 | if (colored && isatty(STDERR_FILENO)) { |
66 | fprintf(stderr, "\x1B[0m"); | 66 | fprintf(stderr, "\x1B[0m"); |
67 | } | 67 | } |
68 | fprintf(stderr, "\n"); | 68 | fprintf(stderr, "\n"); |
@@ -76,7 +76,7 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) { | |||
76 | c = sizeof(verbosity_colors) / sizeof(char *) - 1; | 76 | c = sizeof(verbosity_colors) / sizeof(char *) - 1; |
77 | } | 77 | } |
78 | 78 | ||
79 | if (colored) { | 79 | if (colored && isatty(STDERR_FILENO)) { |
80 | fprintf(stderr, "%s", verbosity_colors[c]); | 80 | fprintf(stderr, "%s", verbosity_colors[c]); |
81 | } | 81 | } |
82 | 82 | ||
@@ -90,7 +90,7 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) { | |||
90 | strerror_r(errno, error, sizeof(error)); | 90 | strerror_r(errno, error, sizeof(error)); |
91 | fprintf(stderr, "%s", error); | 91 | fprintf(stderr, "%s", error); |
92 | 92 | ||
93 | if (colored) { | 93 | if (colored && isatty(STDERR_FILENO)) { |
94 | fprintf(stderr, "\x1B[0m"); | 94 | fprintf(stderr, "\x1B[0m"); |
95 | } | 95 | } |
96 | fprintf(stderr, "\n"); | 96 | fprintf(stderr, "\n"); |