aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-23 13:16:37 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-23 13:17:53 -0400
commite2322414666488945ffcbcab06f9cca95ff731d3 (patch)
tree93325db3fc39393f1d876b88e80b90ed5695e472 /sway
parentHandle wlc log events (diff)
downloadsway-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.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sway/log.c b/sway/log.c
index 4a047eef..a7d73d5c 100644
--- a/sway/log.c
+++ b/sway/log.c
@@ -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");