summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2014-03-31 21:42:45 +0000
committernicm <nicm@openbsd.org>2014-03-31 21:42:45 +0000
commit46b1c757e165bd5a5b68a6eb8974ce02ea335358 (patch)
tree1c6d35b78ef6a4931493f68732c781f637704304
parentGRID_DEBUG is no longer needed. (diff)
downloadwireguard-openbsd-46b1c757e165bd5a5b68a6eb8974ce02ea335358.tar.xz
wireguard-openbsd-46b1c757e165bd5a5b68a6eb8974ce02ea335358.zip
Remove log_debug2 as well and simplify log.c.
-rw-r--r--usr.bin/tmux/input-keys.c8
-rw-r--r--usr.bin/tmux/log.c79
-rw-r--r--usr.bin/tmux/tmux.c4
3 files changed, 28 insertions, 63 deletions
diff --git a/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c
index f38ee8c422b..87b97f37147 100644
--- a/usr.bin/tmux/input-keys.c
+++ b/usr.bin/tmux/input-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input-keys.c,v 1.33 2013/05/07 11:00:16 nicm Exp $ */
+/* $OpenBSD: input-keys.c,v 1.34 2014/03/31 21:42:45 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -143,7 +143,7 @@ input_key(struct window_pane *wp, int key)
char *out;
u_char ch;
- log_debug2("writing key 0x%x", key);
+ log_debug("writing key 0x%x", key);
/*
* If this is a normal 7-bit key, just send it, with a leading escape
@@ -186,11 +186,11 @@ input_key(struct window_pane *wp, int key)
break;
}
if (i == nitems(input_keys)) {
- log_debug2("key 0x%x missing", key);
+ log_debug("key 0x%x missing", key);
return;
}
dlen = strlen(ike->data);
- log_debug2("found key 0x%x: \"%s\"", key, ike->data);
+ log_debug("found key 0x%x: \"%s\"", key, ike->data);
/* Prefix a \033 for escape. */
if (key & KEYC_ESCAPE)
diff --git a/usr.bin/tmux/log.c b/usr.bin/tmux/log.c
index b66a8f60292..83779151e7c 100644
--- a/usr.bin/tmux/log.c
+++ b/usr.bin/tmux/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.9 2014/03/31 21:42:05 nicm Exp $ */
+/* $OpenBSD: log.c,v 1.10 2014/03/31 21:42:45 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -22,20 +22,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <syslog.h>
-#include <time.h>
#include "tmux.h"
-/* Log file, if needed. */
-FILE *log_file;
+FILE *log_file;
-/* Debug level. */
-int log_level = 0;
-
-void log_event_cb(int, const char *);
-void log_vwrite(const char *, va_list);
-__dead void log_vfatal(const char *, va_list);
+void log_event_cb(int, const char *);
+void log_vwrite(const char *, va_list);
/* Log callback for libevent. */
void
@@ -46,12 +39,11 @@ log_event_cb(unused int severity, const char *msg)
/* Open logging to file. */
void
-log_open(int level, const char *path)
+log_open(const char *path)
{
log_file = fopen(path, "w");
if (log_file == NULL)
return;
- log_level = level;
setlinebuf(log_file);
event_set_log_callback(log_event_cb);
@@ -65,6 +57,7 @@ log_close(void)
{
if (log_file != NULL)
fclose(log_file);
+ log_file = NULL;
event_set_log_callback(NULL);
}
@@ -92,63 +85,35 @@ log_debug(const char *msg, ...)
{
va_list ap;
- if (log_level > 0) {
- va_start(ap, msg);
- log_vwrite(msg, ap);
- va_end(ap);
- }
-}
-
-/* Log a debug message at level 2. */
-void printflike1
-log_debug2(const char *msg, ...)
-{
- va_list ap;
-
- if (log_level > 1) {
- va_start(ap, msg);
- log_vwrite(msg, ap);
- va_end(ap);
- }
-}
-
-/* Log a critical error, with error string if necessary, and die. */
-__dead void
-log_vfatal(const char *msg, va_list ap)
-{
- char *fmt;
-
- if (errno != 0) {
- if (asprintf(&fmt, "fatal: %s: %s", msg, strerror(errno)) == -1)
- exit(1);
- log_vwrite(fmt, ap);
- } else {
- if (asprintf(&fmt, "fatal: %s", msg) == -1)
- exit(1);
- log_vwrite(fmt, ap);
- }
- free(fmt);
-
- exit(1);
+ va_start(ap, msg);
+ log_vwrite(msg, ap);
+ va_end(ap);
}
-/* Log a critical error, with error string, and die. */
+/* Log a critical error with error string and die. */
__dead void printflike1
log_fatal(const char *msg, ...)
{
- va_list ap;
+ char *fmt;
+ va_list ap;
va_start(ap, msg);
- log_vfatal(msg, ap);
+ if (asprintf(&fmt, "fatal: %s: %s", msg, strerror(errno)) == -1)
+ exit(1);
+ log_vwrite(fmt, ap);
+ exit(1);
}
/* Log a critical error and die. */
__dead void printflike1
log_fatalx(const char *msg, ...)
{
- va_list ap;
+ char *fmt;
+ va_list ap;
- errno = 0;
va_start(ap, msg);
- log_vfatal(msg, ap);
+ if (asprintf(&fmt, "fatal: %s", msg) == -1)
+ exit(1);
+ log_vwrite(fmt, ap);
+ exit(1);
}
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index bac0e42127b..457d0f4497e 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.129 2014/02/16 12:45:17 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.130 2014/03/31 21:42:45 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -70,7 +70,7 @@ logfile(const char *name)
if (debug_level > 0) {
xasprintf(&path, "tmux-%s-%ld.log", name, (long) getpid());
- log_open(debug_level, path);
+ log_open(path);
free(path);
}
}