nosun/laravel-api-log-middleware

Api Log Middleware for Laravel

v1.0.5 2020-11-02 09:10 UTC

This package is auto-updated.

Last update: 2024-10-29 05:28:42 UTC


README

有一些时候,你需要在线查看 API 返回的数据,此时,可以使用这个中间件。

Installing

$ composer require nosun/laravel-api-log-middleware

Usage

  1. 引入中间件 App/Http/kernel.php
    $routeMiddleware = [
        ...
       'api_log' => Nosun\ApiLog::class,
    ]
  1. 设置单独的日志通道 config/logging.php
    'api' => [
        'driver' => 'single',
        'path' => storage_path('logs/api.log'),
        'level' => 'debug',
        'days' => 1,
    ]
  1. 创建配置文件 config/api-log.php
    <?php
    
    return [
        'enable' => env('API_LOG_ENABLE','false'),
    ];
  1. api_log 加入路由, 将 API_LOG_ENABLE=true 加入 .env

  2. 查看输出日志: "storage/logs/api.log"

Todo

  • 开发 console,使用 artisan 发布 config file。

Contributing

File bug reports using the issue tracker.

License

MIT