mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
Merge branch 'obsd-master'
Conflicts: tmux.1 window.c
This commit is contained in:
21
log.c
21
log.c
@ -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)
|
||||
|
Reference in New Issue
Block a user