Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging under Linux: Is there a pseudo-tty-like circular buffer implementation?

I am developing under Linux with pretty tight constraints on disk usage. I'd like to be able to point logging to a fixed-size file. For example, if my application outputs all logs to stdout:

~/bin/myApp > /dev/debug1

and then, to see the last amount of output:

cat /dev/debug1

would write out however many bytes debug1 was setup to save (if at least that many had been written there).

This post suggests using expect or its library, but I was wondering if anyone has seen a "pseudo-tty" device driver-type implementation as I would prefer to not bind any more libraries to my executable.

I realize there are other mechanisms like logrotate, but I'd prefer to have a non-cron solution.

Pointers, suggestions, questions welcome!

like image 380
Peter K. Avatar asked May 28 '26 03:05

Peter K.


1 Answers

Perhaps you could achieve what you want using mkfifo and something that reads the pipe with a suitable buffer. I haven't tried, but less --buffers=XXXXXX might work for this.

like image 189
Bruno Avatar answered May 31 '26 09:05

Bruno



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!