Skip to content

Latest commit

 

History

History

logroller

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

logroller

Loop logging of standard inputs to several files

This is a command-line tool for circularly writing the output of other programs to some files via a pipe ("|").

Written using ulog's asynchronous fifo and extended headers for file loop writing.

Base Usage

your_program | logroller --file-path /tmp/example/log.txt --file-size=100KB --max-files=3

This will output the output of your program to /tmp/example/log.txt through logroller, and limit the size and number of a single file according to the options.

Eventually there will be log.3.txt, log.2.txt, log.1.txt, log.txt in the /tmp/example directory.

These files will circulate in the order log.(N).txt -> log.(N+1).txt, and always keep at least 3 complete files.

The log.txt can be viewed in real time using tail -F /tmp/example/log.txt.

Advanced Usage

your_program | logroller --file-path /tmp/example/log.txt --file-size=10MB --max-files=8 --flush-interval=3s --zstd-compress --zstd-params=level=3,window-log=16,chain-log=12,hash-log=13 

Please refer to the following command line options for more advanced usage.

Command line options

> logroller --help
Usage: logroller -f PATH [OPTIONS]...
Loop logging of standard inputs to several files.

Examples:
 your_program | logroller --file-path=log.txt --file-size=1MB --max-files=8
 your_program | logroller -f log.txt -s 1MB -n 8 --zstd-compress

  -h, --help                   Print help and exit
  -V, --version                Print version and exit

File options:
  -f, --file-path=PATH         File path to record log
  -s, --file-size=SIZE         Size of each file  (default=`1MB')
  -n, --max-files=NUM          Maximum number of files  (default=`8')
  -i, --flush-interval=time    Time interval between flushing to disk
                                 (default=`1s')
      --rotation-strategy=STR  File rotation strategy:
                                 rename: log.1.txt -> log.2.txt
                                 incremental: log-24.txt ... log-34.txt
                                 (possible values="rename", "incremental"
                                 default=`rename')
      --rotate-first           Should rotate first before write  (default=off)

Buffer options:
  -c, --fifo-size=SIZE         Size of the FIFO buffer  (default=`32KB')

Compress options:
      --zstd-compress          Compress with zstd  (default=off)
      --zstd-params=PARAMS     Parameters for zstd compression,
                                 larger == more compression and memory (e.g.,
                                 level=3,window-log=21,chain-log=16,hash-log=17)

The SIZE parameter units are K, M, G (power of 1024). If the unit is not
specified, the default is bytes.
The TIME parameter units are s, sec, ms, min, hour. If the unit is not
specified, the default is seconds.

Command line options are generated by the gnu gengetopt tool with getopt. cmdline.c/h files are generated by the gengetopt < logroller_getopt.ggo command.