This package provides a driver and trait to store command output as log messages in the database. It can also be used as a standalone package to store log messages in the database.
use Illuminate\Support\Facades\Log;
Log::channel('commands')->info('Your message');
You can install the package via composer:
composer require kussie/laravel-command-db-logger
You can publish and run the migrations with:
php artisan vendor:publish --tag="log-db-migrations"
php artisan migrate
Now add a new channel to config/logging.php
.
use Kussie\CommandDatabaseLogger\CommandLogger;
return [
'channels' => [
'commands' => [
'driver' => 'custom',
'via' => CommandLogger::class,
],
]
]
Add the following trait to the commands which you want to log the output of:
use Kussie\CommandDatabaseLogger\Traits\UseCommandLogger;
Any output that the command outputs via info
or error
commands will be logged to the database and output on the CLI as per normal.
- Ben Kuskopf
- Yoeri Boven
The MIT License (MIT). Please see License File for more information.