LogFormatter: more redundant starttime initialization
authorPaul Mehrer <p.mehrer@metaways.de>
Tue, 26 Nov 2013 16:11:26 +0000 (17:11 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 27 Nov 2013 15:58:08 +0000 (16:58 +0100)
tine20/Tinebase/Log/Formatter.php - if request start time is not registered in the registry, initialize starttime in constructor with current microtime

test/tine20/Tinebase/Log/FormatterTest.php - adjusted log message check based on configuration of logruntime and logdifftime

Change-Id: I033cbd65f6be053812a0eb807e12f167452d33eb
Reviewed-on: https://gerrit.tine20.org/tine20/2593
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Tinebase/Log/FormatterTest.php
tine20/Tinebase/Log/Formatter.php

index e1d6823..4a8a050 100644 (file)
@@ -71,6 +71,10 @@ class Tinebase_Log_FormatterTest extends PHPUnit_Framework_TestCase
         
         $this->assertFalse(strpos($loggerFile, $config->database->password), 'pw found!');
         $this->assertContains('********', $loggerFile);
-        $this->assertContains(Tinebase_Core::getUser()->accountLoginName . ' - ', $loggerFile);
+        if ($config->logger->logruntime || $config->logger->logdifftime) {
+            $this->assertTrue(preg_match('/' . Tinebase_Core::getUser()->accountLoginName . ' \d/', $loggerFile) === 1);
+        } else {
+            $this->assertContains(Tinebase_Core::getUser()->accountLoginName . ' - ', $loggerFile);
+        }
     }
 }
index b3ddd46..ccfd444 100644 (file)
@@ -96,6 +96,9 @@ class Tinebase_Log_Formatter extends Zend_Log_Formatter_Simple
         
         if (self::$_starttime === NULL) {
             self::$_starttime = Tinebase_Core::get(Tinebase_Core::STARTTIME);
+            if (self::$_starttime === NULL) {
+                self::$_starttime = microtime(true);
+            }
         }
         
         if (self::$_logruntime === NULL || self::$_logdifftime === NULL) {