unixoff/monolog-discord

此包用于将 Discord 的日志发送到 webhook 频道。

v0.1.3 2022-01-11 20:59 UTC

This package is auto-updated.

Last update: 2024-09-16 12:21:22 UTC


README

Latest Stable Version Latest Unstable Version License PHP Version Require

此包用于将 Discord 的日志发送到 webhook 频道

安装

composer require nullabler/monolog-discord

使用方法

<?php

require 'vendor/autoload.php';

use nullabler\MonologDiscord\DiscordWebhookHandler;

$webhook = 'Your Webhook URL';

$log = new Monolog\Logger('discord');
$log->pushHandler(new DiscordWebhookHandler($webhook));

$log->info('hello world!');

Sample image

Symfony 设置

monolog:
    handlers:
        main:
            ...
        discord_webhook_handler:
            type: service
            id: discord_webhook_handler

services:
    discord_webhook_handler:
        class: MonologDiscord\DiscordWebhookHandler
        arguments:
            $webhookUrl: '%env(string:DISCORD_WEBHOOK)%'

许可

查看 LICENSE Apache License 2.0。