💾 Archived View for axionfield.space › gemlog › 20220602-tinylog.gmi captured on 2024-07-08 at 23:25:38. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-06-03)

-=-=-=-=-=-=-

Tinylog

I needed a simple solution to redirect the output of a program to a file, and I

wanted to be able to support basic log rotation. I know there is logrotate, but

it is a daemon, needs timer and config file, which is a bit overkill. I just

needed something stupid for piping stdout/stderr.

Enters tinylog, which is part of perp:

perp (persistend process supervision)

Install

I did not need perp, but just the tinylog binary. So I built it:

wget http://b0llix.net/perp/distfiles/perp-2.07.tar.gz
tar -xvf perp-2.07.tar.gz
cd perp-2.07
make && make strip

Now I simply copied perp/tinylog into a folder in my $PATH (if unsure, you can put

it in /usr/local/bin or /usr/bin)

cp perp/tinylog ~/.bin

Usage

tinylog is stupidly simple (and that's a great quality). You tell it the max

size of a log file (in bytes, not thanks to the manual...), how many rotations

you want to keep and where to store them.

my_program | tinylog -s $((1024*1024)) -k 3 /var/logs/my_program

This will log stdout from my_program to /var/logs/my_program/, will rotate

everytime the current log reaches 1MB and will keep 3 rotations.

Hard to be simpler.