piedweb / logs-analyzer
Can parse, filter and export to CSV via PHP or CLI your APACHE/Nginx/Microsoft/WhatYouWant logs.
Installs: 11 286
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ~7.1|^8.0
- cheprasov/php-cli-args: ^2.1
- kassner/log-parser: ^1.4
- vimeo/psalm: ^4.4
Requires (Dev)
- phpunit/phpunit: >=7.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-12-21 00:23:54 UTC
README
Logs Analyzer
This package can parse, filter and export to CSV via PHP or CLI your APACHE/Nginx/Microsoft/WhatYouWant logs.
FR: https://piedweb.com/seo/logs
Install
Via Packagist
$ composer require piedweb/logs-analyzer
Usage
Tu use it directly in php, see bin/analyzer example.
Else, you can use the command tools to filter and export to CSV your log files. Get the last args list via --help
:
bin/analyzer --help
About --format
Default parser work with Apache Access Logs :
^(?P<host>[a-zA-Z0-9\-\._:]+) (?P<logname>(?:-|[\w-]+)) (?P<user>(?:-|[\w\-\.]+)) \[(?P<time>\d{2}/(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/\d{4}:\d{2}:\d{2}:\d{2} (?:-|\+)\d{4})\] "(?P<request>(?:(?:[A-Z]+) .+? HTTP/(1\.0|1\.1|2\.0))|-|)" (?P<status>\d{3}|-) (?P<responseBytes>(\d+|-)) "(?P<HeaderReferer>.*?)" "(?P<HeaderUserAgent>.*?)"$
You can change the regex directly via the CLI or by creating a new Class managing your special format. Your new class must extends \PiedWeb\LogsAnalyzer\LogLine
.
About --resume
This arg permits to have only unique request (requestMethod
+ url
+ status
) keeping only the first date
and time
and counting the number of hit
Testing
$ composer test
Contributing
Please see contributing
Credits
License
The MIT License (MIT). Please see License File for more information.