objectified/logtailminutes

日志提取工具

dev-master 2013-01-23 09:07 UTC

This package is not auto-updated.

Last update: 2024-09-22 03:14:16 UTC


README

这是一个非常简单、小巧的工具,可以从日志文件中根据时间范围提取行。用法

$tail = new LogTailMinutes(
    '/path/to/logfile',  // log file to extract files from
    'd/m/Y',            // date format used in the log file, see php.net/date
    10,                 // how many minutes to go back
    'now',              // time expression to start from, see php.net/strtotime
    '/path/to/egrep'    // path to egrep binary
);

// optionally, set a filter on the matching results (egrep compatible regex)
$tail->setFilterRegex('HTTP/1.1" (4|5)[0-9]{2}');

// get matched lines
$lines = $tail->getLines();