touchdesign/logrotate

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

This package is auto-updated.

Last update: 2024-09-09 01:50:01 UTC


README

Minimum PHP Version

Logrotate

Linux 类型的日志轮转组件,用 PHP 编写。例如,如果你有一个简单的 logfile.log 文件,你可以将其轮转(移动)到 logfile.log.1 并依次类推。源日志文件将被截断。可以通过 $keep 选项控制保留的日志文件数量。

依赖项

  • PHP 7.4 或更高版本

安装

composer require touchdesign/logrotate

用法

$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();

更多示例,请查看本存储库中的示例文件夹。