dyanakiev / laravel-logger-discord-channel
基于 Discord 的 Laravel Monolog 驱动器
6.1.1
2024-08-14 12:23 UTC
Requires
- php: ^7.2.5|^8.0
- guzzlehttp/guzzle: ^7.0.1|^7.2
- illuminate/contracts: ~7.0|~8.0|~9.0|~10.0|~11.0
- illuminate/queue: ~7.0|~8.0|~9.0|~10.0|~11.0
- illuminate/support: ~7.0|~8.0|~9.0|~10.0|~11.0
- monolog/monolog: ~1.12|^2.0|^3.0
README
基于 Discord 的 Laravel Monolog 驱动器
安装
composer require dyanakiev/laravel-logger-discord-channel
用法
- 在您的
config/logging.php
配置文件中添加新的 Discord 通道类型,找到通道部分并在其中添加 Discord 数组
'channels' => [ 'discord' => [ 'driver' => 'custom', 'via' => dyanakiev\LoggerDiscordChannel\DiscordLogger::class, 'suffix' => env('DISCORD_LOG_SUFFIX','Laravel Log'), // Message title suffix 'webhook' => env('DISCORD_LOG_WEBHOOK', false), // e.g. https://discordapp.com/api/webhooks/... 'level' => env('DISCORD_LOG_LEVEL', 'debug'), // You can choose from: emergency, alert, critical, error, warning, notice, info and debug 'context' => env('DISCORD_LOG_CONTEXT', false), // Enable this if you want to receive the full context of an error, usually useless 'environment' => env('DISCORD_LOG_ENVIRONMENT', 'production'), // Enable logging only for environment ['production', 'staging', 'local'] 'message' => env('DISCORD_LOG_MESSAGE', false), // Here you can put extra message or tag role or person via @personName ], ],
- 在
stack
通道内添加新的 Discord 通道,建议将LOG_CHANNEL
设置为stack
,这样您在运行生产环境时仍能保留日常日志 - 直接在配置中或在 .env 文件中自定义包设置
注意
如果您在安装后遇到 laravel.EMERGENCY: Unable to create configured logger. ... Log [discord] is not defined.
错误,可能需要清除缓存
php artisan config:clear
别忘了在清除缓存后在生产环境中再次缓存配置 :)
php artisan config:cache