diff options
author | nicm <nicm> | 2017-06-04 08:25:57 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-06-04 08:25:57 +0000 |
commit | adf5628087829bed2eff635760d7cc456dd1e558 (patch) | |
tree | ceb0745ca673fb84658b4ba573ff6b3a04926b5f /log.c | |
parent | 184039044a92b83f38b880b0a4a1c5ebc272af9c (diff) |
Support SIGUSR2 to stop and start logging for an existing server. Also
we currently only have two log levels so just use -v and -vv rather than
-v and -vvvv, and clarify the man page entry for -v.
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -62,12 +62,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; @@ -76,6 +74,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) |