guskov/simple-logger

This package adds a middleware which can parse and log requests to the daily log driver

dev-master 2021-01-26 13:43 UTC

This package is auto-updated.

Last update: 2024-05-26 21:43:43 UTC


README

This Laravel package adds a middleware which can parse and log requests to the daily log driver.

Installation

You can install the package via composer:

composer require guskov/simple-logger

Optionally you can publish the configfile with:

php artisan vendor:publish --provider="Guskov\Logger\LoggerServiceProvider" --tag="simple-logger" 

This is the contents of the published config file:

return [
    /*
     * Enable/disable logging
     */
    'enable' => true,

    /*
     * Filter out body fields which will never be logged.
     */
    'except' => [
        'password',
        'confirmation',
        'token'
    ],

];   

Usage

This packages provides a middleware which can be added as a single route or as group route. Use 'log' alias in middleware.

// in a single route
 Route::get('/home', function () {
})->middleware('log');

// in a group route
 Route::group([
            'prefix' => 'admin',
            'as' => 'admin.',
            'middleware' => ['auth', 'admin' , 'log'],
        ], function () {
        //...
        }
        );

License

MIT