stephan-strate/monolog-discord

Monolog handler to support Discord webhooks as log target

v1.0.1 2021-11-28 18:15 UTC

README

Packagist Version GitHub license GitHub Workflow Status (branch)

Monolog Discord Handler

Simple monolog handler to send your logs to Discords webhooks. You may ask yourself "Why another Discord handler? There are already plenty out there..." and you are right. There are lefuturiste/monolog-discord-handler and den1008/monolog-discord-handler to only name two of them. What they all have in common is, they require guzzlehttp. Don't get me wrong. guzzlehttp is a great library, but kinda huge for sending one simple request to Discords webhooks. Unfortunately the existing Discord handlers dependencies are also not really up to date. With help of dependabot I will keep the handler up to date and release regular maintenance updates.

Installation

Using composer:

$ composer require stephan-strate/monlog-discord

Usage

Create handler

The webhook url can be obtained by following this tutorial by discord.

$handler = new Strate\Monolog\DiscordHandler('https://discord.com/api/webhooks/{webhook.id}/{webhook.token}', Logger::WARNING)

Add handler to Monolog

$log = new Monolog\Logger();
$log->pushHandler(handler);

Help & Donate

I am very curious about projects that use my libraries. Please drop me a short message about what you use the library for. You can find my contact information on my profile (LinkedIn, E-mail).

If this project saved you time and money or you just appreciate what I am doing, please consider sponsoring me 😊

Acknowledgment

This library was mainly created to resolve conflicting dependencies, which occured with my plugin stephan-strate/grav-plugin-logger-channels in combination with some other plugins of the Grav ecosystem.