Download the PHP package drbiko/monolog-slack without Composer
On this page you can find all versions of the php package drbiko/monolog-slack. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download drbiko/monolog-slack
More information about drbiko/monolog-slack
Files in drbiko/monolog-slack
Package monolog-slack
Short Description This package contains handlers/processors for sending logs of monolog to a slack channel.
License MIT
Homepage https://github.com/drbiko/monolog-slack
Informations about the package monolog-slack
Send logs to Slack using Monolog
Description
This is a package that can help you send logs through monolog to Slack using webhooks. Monolog already has a handler for Slack using Webhooks but I am not in favor of it for these reasons:
It has some bugs
- Slack accepts 2000 characters. For more details see. Current package is not able to send more than 2000 characters but it is able to send until 2000 characters and be well formatted.
Performance
- Monolog has the
WhatFailureGroupHandler
but I consider it simpler not to wrap my handler around another handler and have a simpler and faster logic see - SlackWebhookHandler does not have timeouts and it executes retries when slack service is down see
Formatting
- Current package gives you the ability to add a custom formatter to the
SlackwebhookHandler
in order to format Attachments. Monolog allows you to pass a formatter to SlackHandlers but the formatter is applied only to simple messages of slack and they are not applied for Attachments. - I have created my custom formatters and I tend to like the formatting of Slack Records that I have created more than the one that monolog has.
Install
You can install this package through composer
Documentation
Simple initialization
You can initialize a SlackWebhookHandler
simple with the following lines:
$handler = new SlackWebhookHandler('your_webhook_url');
Formatters
Inject custom formatter
Now if you need to pass a custom slack formatter then you need to do the following:
$hanlder->setFormatter($yourFormatter);
- Note-1: The formatter passed inside the slack handler must be an instance of
SlackFormatterInterface
. - Note-2: If you do not pass a custom Formatter SlackWebhookHandler users the
SlackLineFormatter
by default. - Note-3: Some of the settings passed during constructing the Handler are overridden by the Formatter passed.
SlackLineFormatter
SlackShortAttachmentFormatter
SlackLongAttachmentFormatter
HTTP Client.
Initialize with a PSR-18 HTTP Client.
Inside SlackWebhookHandler
you can inject your PSR-18 HTTP client.
If no PSR-18 HTTP client is passed as argument then SlackwebhookHandler
initializes a \Http\Adapter\Guzzle6\Client
by default.
The initialized client has Timeout and Connection-Timeout to 1 second.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
- Run
composer install
from bash. - Run
composer tests
from bash.
All versions of monolog-slack with dependencies
ext-json Version *
monolog/monolog Version ^1.24
php-http/guzzle6-adapter Version ^2.0