Open lasernite opened 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?
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.
@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
Make a window called test
inside a session (in my example it's called my_session
)
Then, in a different window / pane, run this:
$ tmux pipe-pane -t your_session:test.1 -o "cat >> ~/tmux-pipe-pane--normal.log"
Inside the test
window, run the following: for i in {1..1000}; do echo $i; sleep 0.1; done
- This will print out numbers every line from 1 to 1000 every 0.1 seconds.
In another window / pane, run:
tail -F ~/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.
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