smart-contact / sce-smart-log-client
此包最新版本(v2.0.0)没有提供许可信息。
v2.0.0
2022-01-31 16:42 UTC
Requires
- guzzlehttp/guzzle: ^6.3.1 | ^7.4
- illuminate/support: ^7.29 | ^8.80
- monolog/monolog: ^2.3
Requires (Dev)
- mockery/mockery: ^1.3
- orchestra/testbench: ^6.24
- phpunit/phpunit: ^8.5 | ^9.5
- sempro/phpunit-pretty-print: ^1.4
This package is auto-updated.
Last update: 2024-09-29 06:09:04 UTC
README
Smart Log Client 是一个 Laravel 包,用于与 SmartLog 系统通信,以监控和分析日志。该包使用已集成到 Laravel 中的 Monolog 库。
此包支持 laravel >=7.x 版本。
安装
composer require smart-contact/smart-log-client
发布配置文件
php artisan vendor:publish --tag="smartlog-client-config"
客户端配置
客户端需要以下环境变量
SMARTLOG_API_URL=https://smartlog.it SMARTLOG_APP_NAME="App Name"
Laravel 日志配置
在 config/logging.php 文件中添加以下代码
return [ //... 'channels' => [ //... 'smartlog' => [ 'driver' => 'monolog', 'handler' => \SmartContact\SmartLogClient\LogHandlers\SmartLogHandler::class, 'level' => config('logging.level') ] ] ];
使用方法
单通道
设置环境变量 LOG_CHANNEL 为 smartlog
// .env
LOG_CHANNEL=smartlog
多通道(堆栈)
向通道添加 'smartlog' 通道
... 'stack' => [ 'driver' => 'stack', 'channels' => ['single', 'smartlog'], 'ignore_exceptions' => false, ], ...
并设置 LOG_CHANNEL
// .env
LOG_CHANNEL=stack
自动生成日志
要生成 Laravel 抛出的异常的自动日志,需要修改 app/Exceptions/Handler.php 文件。类 Handler 需要扩展 SmartLogClientException 类。
例如:
// app/Exceptions/Handler.php <?php namespace App\Exceptions; use Throwable; use SmartContact\SmartLogClient\Exceptions\SmartLogClientException; class Handler extends SmartLogClientException{ //... }