Selaa lähdekoodia

ZF-10308: sniff for Zend Server

- Sniff for Zend Server in constructor
- If using Zend Server, use zend_monitor_custom_event, with three
  arguments only (third is event)
- If using Zend Platform, use monitor_custom_event, with third argument
  being priority (and priorities > 4 reporting as "normal", <= 4 as
  "severe")

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23350 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 15 vuotta sitten
vanhempi
commit
8256cefeb9
1 muutettua tiedostoa jossa 20 lisäystä ja 1 poistoa
  1. 20 1
      library/Zend/Log/Writer/ZendMonitor.php

+ 20 - 1
library/Zend/Log/Writer/ZendMonitor.php

@@ -40,6 +40,12 @@ class Zend_Log_Writer_ZendMonitor extends Zend_Log_Writer_Abstract
     protected $_isEnabled = true;
 
     /**
+     * Is this for a Zend Server intance?
+     * @var bool
+     */
+    protected $_isZendServer = false;
+
+    /**
      * @throws Zend_Log_Exception if Zend Monitor extension not present
      */
     public function __construct()
@@ -47,6 +53,9 @@ class Zend_Log_Writer_ZendMonitor extends Zend_Log_Writer_Abstract
         if (!function_exists('monitor_custom_event')) {
             $this->_isEnabled = false;
         }
+        if (function_exists('zend_monitor_custom_event')) {
+            $this->_isZendServer = true;
+        }
     }
 
     /**
@@ -103,7 +112,17 @@ class Zend_Log_Writer_ZendMonitor extends Zend_Log_Writer_Abstract
         unset($event['priority'], $event['message']);
 
         if (!empty($event)) {
-            monitor_custom_event($priority, $message, false, $event);
+            if ($this->_isZendServer) {
+                // On Zend Server; third argument should be the event
+                zend_monitor_custom_event($priority, $message, $event);
+            } else {
+                // On Zend Platform; third argument is severity -- either 
+                // 0 or 1 -- and fourth is optional (event)
+                // Severity is either 0 (normal) or 1 (severe); classifying
+                // notice, info, and debug as "normal", and all others as 
+                // "severe"
+                monitor_custom_event($priority, $message, ($priority > 4) ? 0 : 1, $event);
+            }
         } else {
             monitor_custom_event($priority, $message);
         }