thedomeffm/monolog-discord-handler-bundle

Monolog handler to push your logs to discord via webhook

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

This package is not auto-updated.

Last update: 2024-05-16 15:33:01 UTC


README

Adds a handler to monolog which can post your logs directly via discord webhook to your discord server channel.

Installation

composer require thedomeffm/monolog-discord-handler-bundle

Configuration

I've not added a recipe (or what ever I need to create 🤷), so you need to create the config by yourself.

# thedomeffm_monolog_discord_handler.yaml

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

Add the env variable

DISCORD_WEBHOOK_URL="<your webhook url>"

Edit your monolog configuration

# monolog.yaml

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

Here is an example how a production config could look like:

# 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...