summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/log.c')
-rw-r--r--usr.bin/tmux/log.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.bin/tmux/log.c b/usr.bin/tmux/log.c
index efde430e36b..4124cfbfa74 100644
--- a/usr.bin/tmux/log.c
+++ b/usr.bin/tmux/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.4 2009/12/03 22:50:10 nicm Exp $ */
+/* $OpenBSD: log.c,v 1.5 2012/03/17 18:23:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -42,6 +42,13 @@ int log_level;
void log_vwrite(int, 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. */
void
log_open_tty(int level)
@@ -51,6 +58,7 @@ log_open_tty(int level)
setlinebuf(stderr);
setlinebuf(stdout);
+ event_set_log_callback(log_event_cb);
tzset();
}
@@ -67,6 +75,7 @@ log_open_file(int level, const char *path)
log_level = level;
setlinebuf(log_file);
+ event_set_log_callback(log_event_cb);
tzset();
}
@@ -78,6 +87,8 @@ log_close(void)
if (log_type == LOG_TYPE_FILE)
fclose(log_file);
+ event_set_log_callback(NULL);
+
log_type = LOG_TYPE_OFF;
}