Linux debugging: is there a pseudo-random circular buffer implementation?

I am developing on Linux with fairly strict disk usage restrictions. I would like to be able to specify an entry in a file of a fixed size. For example, if my application prints all the logs to stdout:

~/bin/myApp > /dev/debug1

and then to see the last output volume:

cat /dev/debug1

I would write, however, many debug1 bytes were set to save (if, at least, a lot was written there).

This post suggests using expecteither its library, but I was wondering if anyone had seen an implementation of a driver type like "pseudo-tty", as I would prefer not to link more libraries with my executable.

I understand that there are other mechanisms, such as logrotate , but I would prefer to have a non-cron solution.

Pointers, suggestions, questions are welcome!

+3
source share
1 answer

Perhaps you could achieve what you want by using mkfifo and reading a pipe with a suitable buffer. I have not tried, but less --buffers=XXXXXXmay work for this.

+1
source

Source: https://habr.com/ru/post/1753421/


All Articles