diff options
author | Thomas Adam <thomas@xteddy.org> | 2015-09-06 20:47:50 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2015-09-06 20:47:50 +0100 |
commit | 76688d204071b76fd3388e46e944e4b917c09625 (patch) | |
tree | b6c7920003106991bbb8db46a432e47b16429c94 /log.c | |
parent | 2ebef95994953e49ae84862a65f9ee649a72e200 (diff) | |
parent | aceae73b9a401c0b124a3534079e9c0d998f0dbd (diff) | |
download | rtmux-76688d204071b76fd3388e46e944e4b917c09625.tar.gz rtmux-76688d204071b76fd3388e46e944e4b917c09625.tar.bz2 rtmux-76688d204071b76fd3388e46e944e4b917c09625.zip |
Merge branch 'obsd-master'
Conflicts:
cfg.c
tmux.c
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -23,6 +23,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <vis.h> #include "tmux.h" @@ -67,19 +68,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); } |