1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 00:56:08 +02:00

Exception will be thrown if ZendMonitorHandler is instantiated without having Zend Server installed.

This commit is contained in:
ChristianB
2013-01-31 12:16:16 +01:00
parent 83b84ff818
commit f0ba64ad4b
3 changed files with 35 additions and 36 deletions

View File

@@ -36,22 +36,18 @@ class ZendMonitorHandler extends AbstractProcessingHandler
Logger::EMERGENCY => 0,
);
/**
* Is application running on a zend server?
*
* @var bool
*/
protected $isZendServer = false;
/**
* Construct
*
* @param int $level
* @param bool $bubble
* @throws MissingExtensionException
*/
public function __construct($level = Logger::DEBUG, $bubble = true)
{
$this->isZendServer = function_exists('zend_monitor_custom_event');
if (!function_exists('zend_monitor_custom_event')) {
throw new MissingExtensionException('You must have Zend Server installed in order to use this handler');
}
parent::__construct($level, $bubble);
}
@@ -60,13 +56,11 @@ class ZendMonitorHandler extends AbstractProcessingHandler
*/
protected function write(array $record)
{
if ($this->isZendServer()) {
$this->writeZendMonitorCustomEvent(
$this->levelMap[$record['level']],
$record['message'],
$record['formatted']
);
}
$this->writeZendMonitorCustomEvent(
$this->levelMap[$record['level']],
$record['message'],
$record['formatted']
);
}
/**
@@ -98,14 +92,4 @@ class ZendMonitorHandler extends AbstractProcessingHandler
{
return $this->levelMap;
}
/**
* Is Zend Server?
*
* @return bool
*/
public function isZendServer()
{
return $this->isZendServer;
}
}