diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-09-01 19:14:44 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-09-01 19:14:44 +0000 |
commit | 96749b6841b5675920aedf98de660560a9b71f21 (patch) | |
tree | dd923454aaebf36e99dd9280d0128b302494d571 /usr.bin/tmux | |
parent | 821a1794c9f098a35e79b09450468124574751cd (diff) |
Pass logging through vis(3).
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/log.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.bin/tmux/log.c b/usr.bin/tmux/log.c index 6a4e77ecd8d..0f85308af83 100644 --- a/usr.bin/tmux/log.c +++ b/usr.bin/tmux/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.14 2015/08/29 00:24:44 nicm Exp $ */ +/* $OpenBSD: log.c,v 1.15 2015/09/01 19:14:43 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); } |