mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-16 00:28:10 +02:00
Merge branch 'obsd-master'
Conflicts: cfg.c tmux.c
This commit is contained in:
16
log.c
16
log.c
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user