New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

juststeveking/eloquent-log-driver

A Laravel Log Driver for Eloquent
3,241 7
Install
composer require juststeveking/eloquent-log-driver
Latest Version:1.2.0
PHP:~7.2
Laravel:6 · 7 · 8
License:MIT
Last Updated:Nov 4, 2020
Links: GitHub  ·  Packagist
Maintainer: JustSteveKing

Eloquent Log Driver

Latest Version on Packagist Software License Quality Score Total Downloads

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.

Related Packages

ss-ipg/laravel-auditable

Declarative model audit logging for Laravel using PHP attributes

16,020 0
oilstone/logging

A PSR\Log wrapper for handling static log classes that can be enabled/disabled o...

8,336 2
sofa/laravel-db-queries-alert

Insanely simple check against DB querying abuse in Laravel app AKA Check Your Qu...

2,537 7
sofa/hookable

Laravel Eloquent hooks system.

2,049,184 65
juststeveking/laravel-postcodes

A service wrapper around postcodes.io

161,758 82

Version History

Version Released PHP Laravel License
1.2.0 ~7.2 ^6.0|^7.0|^8.0 MIT
1.1.1 ~7.2 ^6.0|^7.0 MIT
1.1.0 ~7.2 ^6.0|^7.0 MIT
1.0.1 ~7.2 ^6.0|^7.0 MIT
1.0.0 ~7.2 ^6.0 MIT