touchdesign/logrotate

v1.0.0-beta2 2020-12-20 18:11 UTC

This package is auto-updated.

Last update: 2024-05-09 01:12:52 UTC


README

Minimum PHP Version

Logrotate

Linux like log rotate component written in PHP. For example, if you have a simple logfile.log you can rotate (move) it to logfile.log.1 and so on. The source logfile will be truncated. The number of logfiles to keep can controlled with the $keep option.

Dependencies

  • PHP 7.4 or higher

Install

composer require touchdesign/logrotate

Usage

$rotate = new RotateWorker(
    (new LogfileLoader('/tmp/logfile.log'))
);

// Note: Keep 3 logfiles archived
$rotate->run(3);

$purge = new PurgeWorker(
    (new LogfileLoader('/tmp/logfile.log'))
);

$purge->run();

For more examples take a look at the example folder in this repository.