nackjicholson/monolog-gitter-im

Sends monolog notifications through the gitter.im api to a targeted gitter chat room.

v1.0.0 2014-10-29 07:21 UTC

This package is not auto-updated.

Last update: 2024-12-17 03:56:25 UTC


README

Build Status

Sends monolog notifications through the gitter.im api to a targeted gitter chat room.

screen shot 2014-10-25 at 1 02 42 pm

Install

With composer:

composer require "nackjicholson/monolog-gitter-im=1.x"

or in composer.json:

"require": {
    "nackjicholson/monolog-gitter-im": "1.x"
}

Basic usage

// Default level is Logger::CRITICAL
$gitterHandler = new GitterImHandler('apiToken', 'roomId');

$logger = new Logger('gitterIm.example');
$logger->pushHandler($gitterHandler);

$logger->debug('debug will not go', ['ctx' => 'minutia']);
$logger->critical('A gitter.im critical monolog', ['ctx' => 'investigate']);
$logger->alert('A gitter.im alert monolog', ['ctx' => 'take action']);
$logger->emergency('A gitter.im emergency monolog', ['ctx' => 'boom!']);

This example will make separate requests to gitter api making one message for each of the monolog calls that are >= Logger::CRITICAL.

Wrap with BufferHandler

Wrapping the GitterImHandler with monolog's built in BufferHandler makes it possible for you to only make one buffered message per execution of your program. All logs which are to be sent to Gitter are buffered and then when the program exits, they are all sent to the chat room as one batched message.

Setup is straight-forward:

$gitterHandler = new GitterImHandler('apiToken', 'roomId');
$bufferHandler = new BufferHandler($gitterHandler);

$logger = new Logger('gitterIm.buffered.example');
$logger->pushHandler($bufferHandler);

Author:
Will Vaughn
@nackjicholsonn
github:nackjicholson