Horde::logMessage() tweaks
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 22 Dec 2010 18:22:20 +0000 (11:22 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 22 Dec 2010 18:29:02 +0000 (11:29 -0700)
Don't try to log until we have the basic framework initialized.

Don't throw Exception if logMessage() was called before framework was
initialized; ignore instead.

framework/Core/lib/Horde.php

index 86945d0..3b751f2 100644 (file)
@@ -86,11 +86,12 @@ class Horde
     static public function logMessage($event, $priority = null,
                                       array $options = array())
     {
-        if (!isset($GLOBALS['injector'])) {
-            throw new Horde_Exception('The default environment is missing. Unable to write log entries!');
+        /* Chicken/egg: wait until we have basic framework setup before we
+         * start logging. */
+        if (isset($GLOBALS['conf'])) {
+            $options['trace'] = 2;
+            $GLOBALS['injector']->getInstance('Horde_Log_Logger')->log($event, $priority, $options);
         }
-        $options['trace'] = 2;
-        $GLOBALS['injector']->getInstance('Horde_Log_Logger')->log($event, $priority, $options);
     }
 
     /**