Skip to content

stanxdev/monolog-xmpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

monolog-xmpp

XMPP handler for Monolog, uses XMPP Library

Installation

Install the latest version with

$ composer require stanx/monolog-xmpp

Usage

<?php

use Fabiang\Xmpp\Client as XmppClient;
use Fabiang\Xmpp\Options as XmppOptions;
use Monolog\Logger;
use Stanx\Monolog\Handler\XmppHandler;

// Create XMPP Client
$options = new XmppOptions('tcp://jabber.host:5222');
$options->setUsername('username')
        ->setPassword('password')
        ->setTimeout(10);
        
$xmpp = new XmppClient($options);

// Create log channel
$log = new Logger('name');

// Add XmppHandler with XmppClient, receivers and log level as parameters
$log->pushHandler(new XmppHandler($xmpp, ['[email protected]'], Logger::WARNING));

// Add records to log
$log->waring('Foo');
$log->error('Bar');

License

This library is licensed under the MIT license. See the LICENSE file for details.