tmux-plugins / tmux-logging

Easy logging and screen capturing for Tmux.
MIT License
1.05k stars 114 forks source link

Logging stops on detached session #27

Open lasernite opened 6 years ago

lasernite commented 6 years ago

The logging seems to work fine—but only so long as the tmux pane is active. As soon as I detach the session the logs stop being generated. I assume this is not intended behavior?

Nothing unusual about my setup except accessing from root, which perhaps is throwing it off? Or is this not designed to continue to log on a detached session, and if so, how is it intended to be used?

Thanks

lasernite commented 6 years ago

This was misdiagnosed. It seems that the file is created when the logging start, but it is not written to until the logging is stopped. Is this intended behavior? Is there a limit to how much it will cache before writing or might it save millions of lines only to write them all out when the logging is stopped? Is this put onto disk or just kept in memory prior to being written to the file path exposed?

lasernite commented 6 years ago

The actual behavior observed now is that periodically the log file is updated with a batch of updates over some prior time. Maybe every few minutes or something.

absorber commented 4 years ago

@lasernite: This was misdiagnosed. It seems that the file is created when the logging start, but it is not written to until the logging is stopped. Is this intended behavior? Is there a limit to how much it will cache before writing or might it save millions of lines only to write them all out when the logging is stopped? Is this put onto disk or just kept in memory prior to being written to the file path exposed?

Seems like it has something to do with the behavior of sed (see relevant code)

Try the following:

Note: This assumes your pane index starts at 1. If not, then first run tmux set-option -g pane-base-index 1

$ tmux pipe-pane -t your_session:test.1 -o "cat >> ~/tmux-pipe-pane--normal.log"

You'll now be able to see numbers printed in realtime.

However, in the test window, if you instead do this:

$ ansi_codes="(\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]|^M)"
$ tmux pipe-pane -t your_session:test.1 -o "cat | sed -r 's/$ansi_codes//g' >> ~/tmux-pipe-pane--with_sed.log"

I found that things only get printed into the logfile (~/tmux-pipe-pane--with_sed.log) once I close the pane.

Also, perhaps it's best if you change the title of this issue to reflect new findings.