juststeveking / eloquent-log-driver
A Laravel Log Driver for Eloquent
Fund package maintenance!
JustSteveKing
Installs: 3 182
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 4
Open Issues: 2
Requires
- php: ~7.2
- illuminate/support: ^6.0|^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ^4.0
- phpunit/phpunit: >=7.0
- squizlabs/php_codesniffer: ^3.0
README
A Laravel Log Driver for Eloquent
Installation
Via Composer
$ composer require juststeveking/eloquent-log-driver
After installation, publish the migrations using:
Then we can run our migration, which will create a table called database_logs
.
$ php artisan migrate
Registering the driver with Laravel
In your .env
file add the following:
LOG_CHANNEL=eloquent
Then add the following to your config/logging.php
file under channels:
'eloquent' => [ 'driver' => 'custom', 'via' => \JustSteveKing\EloquentLogDriver\Logger\EloquentLogger::class ]
That is it! Your logs will now automatically start appearing in the database.
Querying Logs
There is a small selection of helper scope available on the DatabaseLog
model:
whereDebug()
whereInfo()
whereNotice()
whereWarning()
whereError()
whereCritical()
whereAlert()
whereEmergency()
whereLevel('log-level-case-insensitive')
All of the above will return an instance of an Eloquent Builder, allowing you to chain on further query parameters.
Testing
$ composer run test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email juststevemcd@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.