vmpublishing/psr15-middleware-request-logger 问题修复 & 功能扩展

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

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

vmpublishing/psr15-middleware-request-logger

Composer 安装命令:

composer require vmpublishing/psr15-middleware-request-logger

包简介

middleware to log every incoming request and response with varying levels of detail. also log all exceptions (and rethrow them)

README 文档

README

Build Status Code Coverage Scrutinizer Code Quality

WHAT

PSR-15 request logging middleware with as low dependencies as possible.

for maintenance reasons we like a slim, configurable logging middleware, that handles all the logging for us.

  • every request
  • every response
  • every error
  • every exception

This will rethrow any errors. error handling should be done on layers further out than this middleware.

INSTALL

To install simply use composer require vmpublishing/psr15-middleware-request-logger:*@stable

USE

This is a fancy wrapper for psr/log. So you will need to setup your own logger in any way you wish. After that, you can just simply create the middleware and use it

use VM\RequestLogger\Services\StandardLogFormatter;
use VM\RequestLogger\Middlewares\RequestLogger;

// given a logger in $logger, build the StandardLogFormatter (or write your own log formatter, using the interface)
$formatter = new StandardLogFormatter($logger);
$middleware = new RequestLogger($formatter);

// and for slim, given $app
$app->add($middleware);

// or just add it on the routes you want it on

The default setting is notice, and it won't log anything below that, whatever you set as log level in your logger. This is for optimization reasons. The formatter won't build any string or do any array magic, before the log level is sufficient.

If you want to log with a different level than the default, just pass that in:

use VM\RequestLogger\Services\LogLevel;
use VM\RequestLogger\Services\StandardLogFormatter;

$logLevel = new LogLevel(LogLevel::LEVEL_ERROR);
$formatter = new StandardLogFormatter($logger, $logLevel);
// ...

The StandardLogFormatter can be configured as for which log level to send at which message. just pass in an array to override the defaults. ie:

use VM\RequestLogger\Services\StandardLogFormatter;
use VM\RequestLogger\Services\LogLevel

$logLevel = new LogLevel(LogLevel::LEVEL_ERROR);
$logLevelRequestUri = new LogLevel(LogLevel::LEVEL_DEBUG);
$logLevelMappings = [StandardLogFormatter::MESSAGE_REQUEST_URI => $logLevelRequestUri];
$formatter = new StandardLogFormatter($logger, $logLevel, $logLevelMappings);

report any issues/feature requests on github. enjoy!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固