thedomeffm/monolog-discord-handler-bundle

Monolog处理器,通过webhook将日志推送到Discord

安装: 880

依赖项: 0

建议者: 0

安全: 0

星星: 0

关注者: 0

分支: 1

开放问题: 0

类型:symfony-bundle

v0.0.5 2023-12-14 13:38 UTC

This package is not auto-updated.

Last update: 2024-09-19 17:16:01 UTC


README

为Monolog添加一个处理器,可以直接通过Discord webhook将日志发布到您的Discord服务器频道。

安装

composer require thedomeffm/monolog-discord-handler-bundle

配置

我没有添加配方(或者我需要创建什么 🤷),所以您需要自己创建配置。

# thedomeffm_monolog_discord_handler.yaml

thedomeffm_monolog_discord_handler:
    discord:
        webhook_url: "%env(DISCORD_WEBHOOK_URL)%"

添加环境变量

DISCORD_WEBHOOK_URL="<your webhook url>"

编辑您的Monolog配置

# monolog.yaml

monolog:
    handlers:
        # your other handler...
        discord:
            type: service
            id: thedomeffm_monolog_discord_handler

以下是一个生产配置的示例

# monolog.yaml

when@prod:
    monolog:
        handlers:
            main:
                type: fingers_crossed
                action_level: error
                handler: main_group
                excluded_http_codes: [404, 405]
                buffer_size: 50

            main_group:
                type: group
                members: ['error_stream', 'discord']

            error_stream:
                type: stream
                path: php://stderr
                level: debug
                formatter: monolog.formatter.json

            discord:
                type: service
                id: thedomeffm_monolog_discord_handler

            # your other handler...