jspapp / monolog-discord-handler
Discord 的 Monolog 处理器
2.0.1
2018-08-09 14:30 UTC
Requires
- guzzlehttp/guzzle: ^6.3
- monolog/monolog: ^1.23
README
安装
composer require jspapp/monolog-discord-handler
使用方法
<?php require 'vendor/autoload.php'; use jspapp\MonologDiscord\DiscordHandler; $webhook = 'Your Webhook URL'; $log = new Monolog\Logger('discord'); $log->pushHandler(new DiscordHandler($webhook, Logger::INFO)); $log->info('This is the title!', [ 'Information' => 'Context data will be shown as embedded information.', 'Additional' => 'The footer of the card also displays the logger\'s name and error level, along with the event\'s timestamp.' ]);
Laravel 日志驱动器
将日志驱动器导入 config/logging.php
use jspapp\MonologDiscord\Laravel\DiscordChannel;
并添加以下驱动配置
'discord' => [ 'driver' => 'custom', 'via' => DiscordChannel::class, 'webhook' => env('LOG_DISCORD_WEBHOOK'), ],
速率限制说明
我已经尽可能尊重 Discord 的速率限制,但将驱动器添加到 Laravel 的默认日志堆栈中给我带来了问题。在生产环境中谨慎使用,并考虑选择性使用
Log::channel('discord')->info('Message');
而不是捕获一切。
