riimu/accesslogstats

访问日志解析和统计生成。

v0.1.0 2013-12-11 18:41 UTC

This package is auto-updated.

Last update: 2024-09-19 20:25:11 UTC


README

此库旨在从服务器软件(如Apache)生成的访问日志中生成有用的统计信息。目前,此库主要为我自己的需求和目的编写,以提供我想要了解的详细信息。因此,代码可能没有很好地文档化,并且可能不适合所有通用目的。

使用方法

基本思想是拥有解析器,并向其提供包含过滤器和视图的报告。过滤器用于删除与该报告不相关的行,而视图则确定应从行中提取哪些类型的信息。

例如

<?php
$parser = new Riimu\LogParser\LogParser(
    new Riimu\LogParser\Source\AccessLogSource('access.log'),
    'output');
$report = new Riimu\LogParser\Report('Referrers for www subdomain');
$report->addFilter(new Riimu\LogParser\Filter\FilterDomain('www.example.com'));
$report->addView((new Riimu\LogParser\View\ReferrerView())
    ->addInternalDomain('www.example.com'));

$parser->addReport($report);
$parser->process();
$parser->saveJSON();

上面的代码将为“example.com”网站的“www”子域生成关于引用者的信息。

致谢

此库版权所有 2013 Riikka Kalliomäki