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

Feature: Write scrollback buffer to disk #250

Closed
vossenjp opened this issue Aug 6, 2023 · 12 comments
Closed

Feature: Write scrollback buffer to disk #250

vossenjp opened this issue Aug 6, 2023 · 12 comments

Comments

@vossenjp
Copy link

vossenjp commented Aug 6, 2023

Feature request per #249, is there a way to get ROXTerm to (continuously?) write the scroll-back to disk, in addition to RAM?

Random ideas:

  • One time: File > Save Tab Scrollback buffer As.
  • Continuous: Some profile setting someplace. This needs to take tabs into account, so maybe a dir and/or prefix, with a suffix of tab number (since tab name probably varies).
  • File rotation? I'd say out-of-scope for ROXTerm, other than that it should ideally handle files getting rotated out from under it gracefully.
  • Food for thought: the ability to re-load an existing buffer file?
  • Food for thought: option to write periodic time-stamps? With optional prefix like "###"?

Use-cases:

  • Hack-around for Select All not working correctly in Linux Mint-21.x #249.
  • Personal, non-secure audit trail, like: I know I ran that command, but I forget the exact syntax or which ROXTerm tab I used, but I can grep 'thing' ~/ROXTerm/scrollback-*.txt to find it again.
  • Recover commands/results after a reboot or crash.
@vossenjp
Copy link
Author

vossenjp commented Aug 6, 2023

It occurred to me that using screen -L -Logfile <something> (or similar in ~/.screenrc) would probably work as a hack-around for this. It seems like tmux can do something as well. Or script come to think of it, and that might be simplest.

screen:

tmux:

script:

  • man script
  • Maybe: script --append --logging-format Advanced ~/script-test.log

@realh
Copy link
Owner

realh commented Aug 6, 2023

I don't think vte provides a method to stream the buffer continuously, only to write the whole lot in one go.

@vossenjp
Copy link
Author

vossenjp commented Aug 6, 2023

Hmmmm. That sounds like "File > Save Tab Scrollback buffer As" would work. Maybe an option to automate that as well, so it could be run from cron or possibly periodically by RT itself? The latter feels on the edge of out-of-scope.

@realh
Copy link
Owner

realh commented Aug 19, 2023

I've added a Save Buffer (As) feature in 3.13.1, but I forgot to refer to this issue in the git commit.

@realh realh closed this as completed Aug 19, 2023
@vossenjp
Copy link
Author

Awesome, thanks! 3.13.1 doesn't seem to have hit the PPA yet, but I'll keep an eye out.

In the meantime, to follow up, my script idea worked, but it's not nearly as simple as the Save Buffer As.

I have a script to start up a few ROXTerm tabs, each of which has a function. So I modified that script as follows:

...
# Scrollback buffer write via `script`, see `man script`
# See https://github.com/realh/roxterm/issues/250
# NOTE, output is BUFFERED unless using `--flush` (performance hit), but
# you can send SIGUSR1 to flush logs on demand.
printf -v TODAY "%(%F)T" '-1'  # Bash
SBDIR="$HOME/ROXTerm/scrollback"  # See also: roxterm-source.sh::RTDIR

roxterm --tab --tab-name='1 %s' --execute script --append --logging-format 'Advanced' "$SBDIR/$TODAY.tab01.script"
roxterm --tab --tab-name='2 %s' --execute script --append --logging-format 'Advanced' "$SBDIR/$TODAY.tab02.script"
roxterm --tab --tab-name='3 %s' --execute script --append --logging-format 'Advanced' "$SBDIR/$TODAY.tab03.script"
...

That results in per-tab script files of...everything. That can get quite messy and large, and I have not implemented any cleanup, that's manual as needed for now. But so far I've grepped a few things out of the files and it has worked well enough.

I think, Save Buffer As is a better solution for a one-off or ad hoc needs. script might be useful in some cases, with some extra work. I'll be playing with both to see how it works out.

@realh
Copy link
Owner

realh commented Aug 20, 2023

You should be able to see the update in the PPA. Which version of Ubuntu are you using?

@vossenjp
Copy link
Author

I'm using Linux Mint-21.2, which should be Jammy, but due to #242 I hack the PPA to use Focal:

$ cat /etc/apt/sources.list.d/roxterm.list 
deb http://ppa.launchpad.net/h-realh/roxterm/ubuntu focal main

$ cat /etc/os-release 
NAME="Linux Mint"
VERSION="21.2 (Victoria)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 21.2"
VERSION_ID="21.2"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=victoria
UBUNTU_CODENAME=jammy

### But after `apt update` I still see:
$ apt-cache show roxterm
...
Version: 3.12.1-1ppa1focal1

Could just be my local Ubuntu mirror hasn't caught up yet?

@realh
Copy link
Owner

realh commented Aug 20, 2023

This time I've uploaded versions for bionic, focal, jammy and lunar. I don't think mirrors affect PPAs. Try deleting the old roxterm file in /etc/sources.list.d and adding the PPA again. The jammy version should work for you without any hacking.

@vossenjp
Copy link
Author

tldr; I see build errors in https://launchpad.net/~h-realh/+archive/ubuntu/roxterm/+packages

Long version:
I think you are correct that PPAs don't use mirrors. I see the new build in the web UI at https://launchpad.net/~h-realh/+archive/ubuntu/roxterm. I have deleted my old /etc/apt/sources.list.d/roxterm.list and run sudo add-apt-repository ppa:h-realh/roxterm which worked! Then I ran sudo apt update, which gave me a Hit:11 https://ppa.launchpadcontent.net/h-realh/roxterm/ubuntu jammy InRelease so APT at least sees the PPA, but I still get:

$ deb policy roxterm
apt-cache policy roxterm
roxterm:
  Installed: 3.12.1-1ppa1focal1
  Candidate: 3.12.1-1ppa1focal1
  Version table:
 *** 3.12.1-1ppa1focal1 100
        100 /var/lib/dpkg/status

I'd say the problem is on my side, but I'm getting the same results on 2 computers, and I also have no clue what it could be. A sudo aptitude clean didn't help. Then I finally checked https://launchpad.net/~h-realh/+archive/ubuntu/roxterm/+packages which shows build errors for everything but Lunar.

@realh
Copy link
Owner

realh commented Aug 22, 2023

Sorry, I didn't spot those errors. The logs are nearly as long as my source code, but luckily the problem is nearly always easy to find near the bottom. I got a warning on my own PC because I was using '0' instead of an enum constant, so I started using the constant, not realising it wasn't available in older versions of GLib.

@vossenjp
Copy link
Author

vossenjp commented Aug 24, 2023

I have now gotten 3.13.2 from Jammy PPA. I haven't tested it yet because I am in the middle of things. I'll get to it Real Soon Now, though some folks at work might beat me to it.

@vossenjp
Copy link
Author

Tested and it's AWESOME, thanks! Someone at work did beat me to testing, and found #252.

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