=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/log.c,v retrieving revision 1.19 retrieving revision 1.20 diff -c -r1.19 -r1.20 *** src/usr.bin/tmux/log.c 2015/11/18 14:27:44 1.19 --- src/usr.bin/tmux/log.c 2015/11/24 21:19:46 1.20 *************** *** 1,4 **** ! /* $OpenBSD: log.c,v 1.19 2015/11/18 14:27:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: log.c,v 1.20 2015/11/24 21:19:46 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 22,51 **** #include #include #include #include #include "tmux.h" ! FILE *log_file; ! void log_event_cb(int, const char *); ! void log_vwrite(const char *, va_list); /* Log callback for libevent. */ ! void log_event_cb(__unused int severity, const char *msg) { log_debug("%s", msg); } /* Open logging to file. */ void ! log_open(const char *path) { if (log_file != NULL) fclose(log_file); log_file = fopen(path, "w"); if (log_file == NULL) return; --- 22,74 ---- #include #include #include + #include #include #include "tmux.h" ! static FILE *log_file; ! static int log_level; ! static void log_event_cb(int, const char *); ! static void log_vwrite(const char *, va_list); /* Log callback for libevent. */ ! static void log_event_cb(__unused int severity, const char *msg) { log_debug("%s", msg); } + /* Increment log level. */ + void + log_add_level(void) + { + log_level++; + } + + /* Get log level. */ + int + log_get_level(void) + { + return (log_level); + } + /* Open logging to file. */ void ! log_open(const char *name) { + char *path; + + if (log_level == 0) + return; + if (log_file != NULL) fclose(log_file); + xasprintf(&path, "tmux-%s-%ld.log", name, (long)getpid()); log_file = fopen(path, "w"); + free(path); if (log_file == NULL) return; *************** *** 65,71 **** } /* Write a log message. */ ! void log_vwrite(const char *msg, va_list ap) { char *fmt, *out; --- 88,94 ---- } /* Write a log message. */ ! static void log_vwrite(const char *msg, va_list ap) { char *fmt, *out;