bwt-team/laravel-request-logger 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bwt-team/laravel-request-logger

最新稳定版本:v1.0.5

Composer 安装命令:

composer require bwt-team/laravel-request-logger

包简介

A Laravel 5 package to log HTTP requests

README 文档

README

English description | Russian description

Laravel 5 Request Logger

Latest Stable Version Latest Unstable Version License

This package provides quick and easy setup for the requests logging.

This package requires Laravel 5.6+

Contents

Installation

This package can be installed via composer with this command:

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:

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:

'RequestLogger' => \BwtTeam\LaravelRequestLogger\Facades\RequestLogger::class,

IMPORTANT! By default, logging is disabled in the settings. This allows to configure the package after the installation and enable the logging once everything is ready. To activate the logging use an environment variable "RL_ENABLE". Alternatively, once the config file has been published, it is possible to describe a function that will activate the logging only for the requests of interest.

Here's an example of the function that describes the logging conditions:

'enabled' => function(\Illuminate\Http\Request $request) {
    return $request->isMethod('GET');
},

In order to publish the config file execute next command:

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.

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:

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:

app(\BwtTeam\LaravelRequestLogger\RepositoryInterface::class)->put('test', ['some', 'data']);

Alternatively, a facade could be used:

\RequestLogger::put('test', ['some', 'data']);

License

This package uses MIT.

统计信息

  • 总下载量: 5.35k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-24