English description | Russian description
, (*1)
Laravel 5 Request Logger
![Latest Unstable Version][ico-unstable-version]
, (*2)
This package provides quick and easy setup for the requests logging., (*3)
This package requires Laravel 5.6+
Contents
Installation
This package can be installed via composer with this command:, (*4)
composer require bwt-team/laravel-request-logger
Set up
Laravel 5.6+ uses package auto-discovery, so there's no need to register the service provider manually.
If auto-discovery is disabled the service provider can be registered by adding these records into providers
array in config/app.php
file:, (*5)
BwtTeam\LaravelRequestLogger\Providers\RequestLoggerServiceProvider::class
This service provider will register the middleware that calls the logging itself and will allow configuring all the settings required for the package installation.
To use a facade add this record to the aliases
array:, (*6)
'RequestLogger' => \BwtTeam\LaravelRequestLogger\Facades\RequestLogger::class,
Here's an example of the function that describes the logging conditions:, (*7)
'enabled' => function(\Illuminate\Http\Request $request) {
return $request->isMethod('GET');
},
In order to publish the config file execute next command:, (*8)
php artisan vendor:publish --provider="BwtTeam\LaravelRequestLogger\Providers\RequestLoggerServiceProvider" --tag=config
Next options are available in the settings:
- enable/disable logging;
- titles of the fields that should be excluded from the logs (for example, "password");
- options for type casting and logs optimization;
- logs storage settings., (*9)
The default log storage is "database".
For this storage to work correctly it is necessary to execute a migration to create a table for logs.
In order to publish this migration execute this command:, (*10)
php artisan request-logger:table
It is possible to write custom data.
To do this, the data should be passed to "put" method of "BwtTeam\LaravelRequestLogger\RequestLoggerRepository" class.
For example:, (*11)
app(\BwtTeam\LaravelRequestLogger\RepositoryInterface::class)->put('test', ['some', 'data']);
Alternatively, a facade could be used:, (*12)
\RequestLogger::put('test', ['some', 'data']);
License
This package uses MIT., (*13)