diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2012-05-30 15:01:57 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2012-05-30 15:01:57 +0000 |
commit | eed7d9b47371531ce185f80b4be5bcba3da96955 (patch) | |
tree | 5d11bf5573e4a269fb2f9fa55b28ade78fa4827e | |
parent | bf4b02cea2f4483c07de16e5d408adf3421c8c4f (diff) | |
download | rtmux-eed7d9b47371531ce185f80b4be5bcba3da96955.tar.gz rtmux-eed7d9b47371531ce185f80b4be5bcba3da96955.tar.bz2 rtmux-eed7d9b47371531ce185f80b4be5bcba3da96955.zip |
Do not use stderr for log file and don't call log_close when not needed.
-rw-r--r-- | log.c | 7 | ||||
-rw-r--r-- | tmux.c | 1 |
2 files changed, 5 insertions, 3 deletions
@@ -28,7 +28,7 @@ #include "tmux.h" /* Log file, if needed. */ -FILE *log_file = stderr; +FILE *log_file; /* Debug level. */ int log_level = 0; @@ -63,7 +63,7 @@ log_open(int level, const char *path) void log_close(void) { - if (log_file != stderr) + if (log_file != NULL) fclose(log_file); event_set_log_callback(NULL); @@ -75,6 +75,9 @@ log_vwrite(const char *msg, va_list ap) { char *fmt; + if (log_file == NULL) + return; + if (asprintf(&fmt, "%s\n", msg) == -1) exit(1); if (vfprintf(log_file, fmt, ap) == -1) @@ -73,7 +73,6 @@ logfile(const char *name) { char *path; - log_close(); if (debug_level > 0) { xasprintf(&path, "tmux-%s-%ld.log", name, (long) getpid()); log_open(debug_level, path); |