Notifiers for Tracy\Debugger

about a year ago

finwe
Member | 53
+
+6
-

The e-mail notifications are too tightly integrated to the Logger class – when wanting to notify some other channels (mainly 3rd party APIs) I would have to extend the base logger class and edit the Logger::log() method.

Proposition

Introduce a Logger::$notifiers property with an array of Tracy\INotifier interface instances:

<?php

namespace Tracy;

interface INotifier
{

    public function notify($message);

}

Base Logger::log() method would then be changed from

if (in_array($priority, array(self::ERROR, self::EXCEPTION, self::CRITICAL), TRUE)) {
    $this->sendEmail($message);
}

to

foreach (self::$notifiers as $notifier) {
    $notifier->notify($message);
}

Error levels to notify would be handled by INotifier implementation.

Backwards compatibility

Basic EmailNotifier would be included in distribution and automatically set up on Debugger enabling. Also Debugger::$email, Debugger::$mailer and other related variables would be transferred to said notifier settings.

I propose removing e-mail related settings from Debugger class in the next significant version.

8 months ago

finwe
Member | 53
+
0
-

Made a WIP PR. Comments appreciated. https://github.com/…acy/pull/210

8 months ago

Jan Tvrdík
Nette guru | 2489
+
0
-

Why not use Monolog?

Board footer

Terms and conditions