bobagold/monolog-bubble

Limit logging of similar records

1.0 2014-11-12 04:57 UTC

This package is not auto-updated.

Last update: 2024-12-21 17:35:01 UTC


README

Monolog handler for limiting logging of similar records

use Bubble\CatchBubble;
use Bubble\MemcacheArray;
use Bubble\Monolog\BubbleHandler;

$log = new \Monolog\Logger(/*...*/);
$log->pushHandler(/*...*/); // this handler will log everything

$mailHandler = new \Monolog\Handler\NativeMailerHandler('support@example.com', 'Error report', 'noreply@example.com');
$mailHandler->setFormatter(/*...*/);

//$mailHandler will not pollute support mailbox with similar records more than once an hour
$log->pushHandler(new BubbleHandler($mailHandler, new CatchBubble('PT1H', new MemcacheArray())));
$log->pushProcessor(/*...*/);

\Monolog\ErrorHandler::register($log);