diff options
author | Thomas Adam <thomas@xteddy.org> | 2017-06-05 11:59:38 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2017-06-05 11:59:38 +0100 |
commit | e62e17d0461cfb0bfb55ae3c9c7a3815235298fb (patch) | |
tree | 258f2a1e09eb8553842383636a9f6f8a3f75074a /log.c | |
parent | 1c83c0ebcd483c668f02f5f7a8cb80f8a0dc162c (diff) | |
parent | 2f04108f3a35271ef60b3028699b6363e1714140 (diff) |
Merge branch 'obsd-master'
Conflicts:
tmux.1
window.c
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -61,12 +61,10 @@ log_open(const char *name) if (log_level == 0) return; - - if (log_file != NULL) - fclose(log_file); + log_close(); xasprintf(&path, "tmux-%s-%ld.log", name, (long)getpid()); - log_file = fopen(path, "w"); + log_file = fopen(path, "a"); free(path); if (log_file == NULL) return; @@ -75,6 +73,21 @@ log_open(const char *name) event_set_log_callback(log_event_cb); } +/* Toggle logging. */ +void +log_toggle(const char *name) +{ + if (log_level == 0) { + log_level = 1; + log_open(name); + log_debug("log opened"); + } else { + log_debug("log closed"); + log_level = 0; + log_close(); + } +} + /* Close logging. */ void log_close(void) |