Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging stops on detached session #27

Open
lasernite opened this issue Jun 5, 2018 · 3 comments
Open

Logging stops on detached session #27

lasernite opened this issue Jun 5, 2018 · 3 comments

Comments

@lasernite
Copy link

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
Copy link
Author

lasernite commented Jun 6, 2018

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
Copy link
Author

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
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants