Redirect libevent logging to tmux's log.

This commit is contained in:
Nicholas Marriott 2012-03-17 18:23:03 +00:00
parent 0489213b1b
commit a597e3546c

11
log.c
View File

@ -42,6 +42,13 @@ int log_level;
void log_vwrite(int, const char *, va_list); void log_vwrite(int, const char *, va_list);
__dead void log_vfatal(const char *, va_list); __dead void log_vfatal(const char *, va_list);
/* Log callback for libevent. */
void
log_event_cb(unused int severity, const char *msg)
{
log_warnx(msg);
}
/* Open logging to tty. */ /* Open logging to tty. */
void void
log_open_tty(int level) log_open_tty(int level)
@ -51,6 +58,7 @@ log_open_tty(int level)
setlinebuf(stderr); setlinebuf(stderr);
setlinebuf(stdout); setlinebuf(stdout);
event_set_log_callback(log_event_cb);
tzset(); tzset();
} }
@ -67,6 +75,7 @@ log_open_file(int level, const char *path)
log_level = level; log_level = level;
setlinebuf(log_file); setlinebuf(log_file);
event_set_log_callback(log_event_cb);
tzset(); tzset();
} }
@ -78,6 +87,8 @@ log_close(void)
if (log_type == LOG_TYPE_FILE) if (log_type == LOG_TYPE_FILE)
fclose(log_file); fclose(log_file);
event_set_log_callback(NULL);
log_type = LOG_TYPE_OFF; log_type = LOG_TYPE_OFF;
} }