gtcrais / application-log-parser
Application Log Parser
v1.1.2
2020-10-25 16:10 UTC
Requires
- php: >=7.0.0
This package is auto-updated.
Last update: 2024-12-26 00:37:51 UTC
README
Application Log Parser is a Laravel package for parsing various application logs. By default it ships with parser for Laravel 4.2+ and WordPress.
Requirements
- PHP 7.0+
- Laravel 5.5+ (it may work on lower versions of Laravel, but it hasn't been tested)
Installation
- add
"gtcrais/application-log-parser": "1.1.*"
to yourcomposer.json
and runcomposer update
- for Laravel
<=5.4
addGTCrais\ApplicationLogParser\LogParserServiceProvider::class,
to providers array in/config/app.php
and runcomposer dump-autoload
Note: this package has not been tested with Laravel versions prior to5.5
- optionally, run
php artisan vendor:publish --provider=GTCrais\ApplicationLogParser\LogParserServiceProvider
API
Writing a custom platform log parser
- publish the Application Log Parser config file by running
php artisan vendor:publish --provider=GTCrais\ApplicationLogParser\LogParserServiceProvider
- write your log parser class. It must implement
GTCrais\ApplicationLogParser\Contracts\LogParserContract
and return a Collection of Log Entries. EachLogEntry
must extendGTCrais\ApplicationLogParser\LogEntries\BaseLogEntry
- finally, register your platform and its log parser in the config file:
'platforms' => [ 'laravel' => GTCrais\ApplicationLogParser\Parsers\Laravel\LaravelLogParser::class, 'customPlatform' => CustomVendor\CustomNamespace\CustomLogParser::class, ]
For more details check out GTCrais\ApplicationLogParser\Parsers\LaravelLogParser
and GTCrais\ApplicationLogParser\LogEntries\BaseLogEntry
classes.
Usage examples
use GTCrais\ApplicationLogParser\Facades\LogParser; $logEntriesCollection = LogParser::get(); $logEntriesCollection = LogParser::setPlatform('customPlatform')->setLogPath('path/to/log/file/logfile.log')->get(); $logEntriesCollection = LogParser::setSortProperty('customProperty')->setSortDirection('asc')->get(); $logEntriesCollection = LogParser::disableDefaultSorting()->sortBy('propertyOrCallback')->get();
Note
This package uses some parts of code for parsing Laravel logs from JackieDo/Laravel-Log-Reader
.
License
Application Log Parser is open-sourced software licensed under the MIT license.