7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
23 /** Zend_Log_Writer_Abstract */
24 require_once 'Zend/Log/Writer/Abstract.php';
30 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
31 * @license http://framework.zend.com/license/new-bsd New BSD License
34 class Zend_Log_Writer_ZendMonitor
extends Zend_Log_Writer_Abstract
37 * Is Zend Monitor enabled?
40 protected $_isEnabled = true;
43 * @throws Zend_Log_Exception if Zend Monitor extension not present
45 public function __construct()
47 if (!function_exists('monitor_custom_event')) {
48 $this->_isEnabled
= false;
53 * Create a new instance of Zend_Log_Writer_ZendMonitor
55 * @param array|Zend_Config $config
56 * @return Zend_Log_Writer_Syslog
57 * @throws Zend_Log_Exception
59 static public function factory($config)
65 * Is logging to this writer enabled?
67 * If the Zend Monitor extension is not enabled, this log writer will
68 * fail silently. You can query this method to determine if the log
73 public function isEnabled()
75 return $this->_isEnabled
;
79 * Log a message to this writer.
81 * @param array $event log data event
84 public function write($event)
86 if (!$this->isEnabled()) {
90 parent
::write($event);
94 * Write a message to the log.
96 * @param array $event log data event
99 protected function _write($event)
101 $priority = $event['priority'];
102 $message = $event['message'];
103 unset($event['priority'], $event['message']);
105 if (!empty($event)) {
106 monitor_custom_event($priority, $message, $event);
108 monitor_custom_event($priority, $message);