diff options
author | nicm <nicm> | 2015-09-01 19:14:43 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-09-01 19:14:43 +0000 |
commit | 364a885b0c8b3bc58396775603c7927e1fb19cee (patch) | |
tree | c42bc40348cab8d9d4346512d9e473be558a7068 /log.c | |
parent | fa3d4fab85e4c1f807808640f75f50a41bbb2c5b (diff) |
Pass logging through vis(3).
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -22,6 +22,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <vis.h> #include "tmux.h" @@ -66,19 +67,24 @@ log_close(void) void log_vwrite(const char *msg, va_list ap) { - char *fmt; + char *fmt, *out; struct timeval tv; if (log_file == NULL) return; - gettimeofday(&tv, NULL); - if (asprintf(&fmt, "%lld.%06d %s\n", (long long)tv.tv_sec, - (int)tv.tv_usec, msg) == -1) + if (vasprintf(&fmt, msg, ap) == -1) exit(1); - if (vfprintf(log_file, fmt, ap) == -1) + if (stravis(&out, fmt, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL) == -1) + exit(1); + + gettimeofday(&tv, NULL); + if (fprintf(log_file, "%lld.%06d %s\n", (long long)tv.tv_sec, + (int)tv.tv_usec, out) == -1) exit(1); fflush(log_file); + + free(out); free(fmt); } |