Notifiers for Tracy\Debugger

Notice: This thread is very old.
finwe
Member | 58
+
+7
-

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.

finwe
Member | 58
+
0
-

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

Jan Tvrdík
Nette guru | 2595
+
0
-

Why not use Monolog?