aboutsummaryrefslogtreecommitdiff
path: root/sway/log.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-08-23 13:16:37 -0400
committerDrew DeVault <sir@cmpwn.com>2015-08-23 13:17:53 -0400
commite2322414666488945ffcbcab06f9cca95ff731d3 (patch)
tree93325db3fc39393f1d876b88e80b90ed5695e472 /sway/log.c
parentac2034df99e1ec19e8bca60a802cd9f9d8fbbf83 (diff)
Do not log with colors unless stdout is a tty
Diffstat (limited to 'sway/log.c')
-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, ...) {
c = sizeof(verbosity_colors) / sizeof(char *) - 1;
}
- if (colored) {
+ if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "%s", verbosity_colors[c]);
}
@@ -62,7 +62,7 @@ void sway_log(log_importance_t verbosity, const char* format, ...) {
vfprintf(stderr, format, args);
va_end(args);
- if (colored) {
+ if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "\x1B[0m");
}
fprintf(stderr, "\n");
@@ -76,7 +76,7 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) {
c = sizeof(verbosity_colors) / sizeof(char *) - 1;
}
- if (colored) {
+ if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "%s", verbosity_colors[c]);
}
@@ -90,7 +90,7 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) {
strerror_r(errno, error, sizeof(error));
fprintf(stderr, "%s", error);
- if (colored) {
+ if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "\x1B[0m");
}
fprintf(stderr, "\n");