function test_logger()
 {
     if (tx_rnbase_util_Extensions::isLoaded('devlog')) {
         $minLog = tx_rnbase_configurations::getExtensionCfgValue('devlog', 'minLogLevel');
         if ($minLog === FALSE) {
             $ret = tx_rnbase_util_Logger::isNoticeEnabled();
             $this->assertTrue($ret, 'Notice funktioniert nicht.');
         }
         if ($minLog == 1) {
             $ret = tx_rnbase_util_Logger::isNoticeEnabled();
             $this->assertTrue($ret, 'Notice funktioniert nicht.');
             $ret = tx_rnbase_util_Logger::isWarningEnabled();
             $this->assertTrue($ret, 'Warning funktioniert nicht.');
             $ret = tx_rnbase_util_Logger::isFatalEnabled();
             $this->assertTrue($ret, 'Fatal funktioniert nicht.');
             $ret = tx_rnbase_util_Logger::isInfoEnabled();
             $this->assertFalse($ret, 'Info funktioniert nicht.');
             $ret = tx_rnbase_util_Logger::isDebugEnabled();
             $this->assertFalse($ret, 'Debug funktioniert nicht.');
         }
         if ($minLog == 3) {
             $ret = tx_rnbase_util_Logger::isNoticeEnabled();
             $this->assertFalse($ret, 'Notice funktioniert nicht.');
             $ret = tx_rnbase_util_Logger::isWarningEnabled();
             $this->assertFalse($ret, 'Warning funktioniert nicht.');
             $ret = tx_rnbase_util_Logger::isFatalEnabled();
             $this->assertTrue($ret, 'Fatal funktioniert nicht.');
             $ret = tx_rnbase_util_Logger::isInfoEnabled();
             $this->assertFalse($ret, 'Info funktioniert nicht.');
             $ret = tx_rnbase_util_Logger::isDebugEnabled();
             $this->assertFalse($ret, 'Debug funktioniert nicht.');
         }
     }
 }
 /**
  * Interne Verarbeitung der Exception
  *
  * @param string $actionName
  * @param Exception $e
  * @param tx_rnbase_configurations $configurations
  *
  * @return string error message
  */
 public function handleException($actionName, Exception $e, tx_rnbase_configurations $configurations)
 {
     // wir prüfen erst mal, ob die exception gefangen werden soll
     $catch = $this->catchException($actionName, $e, $configurations);
     if ($catch !== NULL) {
         return $catch;
     }
     // wenn nicht senden wir ggf den header
     if ($this->send503HeaderOnException($configurations)) {
         header('HTTP/1.1 503 Service Unavailable');
     }
     // wir loggen nun den fehler
     tx_rnbase::load('tx_rnbase_util_Logger');
     if (tx_rnbase_util_Logger::isFatalEnabled()) {
         $extKey = $configurations->getExtensionKey();
         $extKey = $extKey ? $extKey : 'rn_base';
         tx_rnbase_util_Logger::fatal('Fatal error for action ' . $actionName, $extKey, array('Exception' => array('message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTraceAsString()), '_GET' => $_GET, '_POST' => $_POST));
     }
     // wir senden eine fehlermail
     $addr = tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'sendEmailOnException');
     if ($addr) {
         tx_rnbase_util_Misc::sendErrorMail($addr, $actionName, $e);
     }
     // Now message for FE
     $ret = $this->getErrorMessage($actionName, $e, $configurations);
     return $ret;
 }
 /**
  * Function executed from the Scheduler.
  *
  * @return boolean	Returns true on successful execution, false on error
  */
 public function execute()
 {
     /* beispiel für das logging array.
     		$devLog = array('message' => '', 'extKey' => 'mklib', 'dataVar' => FALSE);
     		$devLog = array(
     			tx_rnbase_util_Logger::LOGLEVEL_DEBUG => $devLog,
     			tx_rnbase_util_Logger::LOGLEVEL_INFO => $devLog,
     			tx_rnbase_util_Logger::LOGLEVEL_NOTICE => $devLog,
     			tx_rnbase_util_Logger::LOGLEVEL_WARN => $devLog,
     			tx_rnbase_util_Logger::LOGLEVEL_FATAL => $devLog
     		);
     		*/
     $devLog = array();
     $options = $this->getOptions();
     $startTimeInMilliseconds = t3lib_div::milliseconds();
     $memoryUsageAtStart = memory_get_usage();
     tx_rnbase_util_Logger::info('[' . get_class($this) . ']: Scheduler starts', $this->getExtKey());
     try {
         $message = $this->executeTask($options, $devLog);
         $this->setLastRunTime();
         // devlog
         if (t3lib_extMgm::isLoaded('devlog')) {
             if (empty($devLog) || isset($devLog[tx_rnbase_util_Logger::LOGLEVEL_INFO]) && empty($devLog[tx_rnbase_util_Logger::LOGLEVEL_INFO]['message'])) {
                 $devLog[tx_rnbase_util_Logger::LOGLEVEL_INFO]['message'] = $message;
             }
             foreach ($devLog as $logLevel => $logData) {
                 if (empty($logData['message'])) {
                     continue;
                 }
                 t3lib_div::devLog('[' . get_class($this) . ']: ' . $logData['message'], isset($logData['extKey']) ? $logData['extKey'] : $this->getExtKey(), $logLevel, isset($logData['dataVar']) ? $logData['dataVar'] : FALSE);
             }
         }
     } catch (Exception $exception) {
         $dataVar = array('errorcode' => $exception->getCode(), 'errormsg' => $exception->getMessage(), 'trace' => $exception->getTraceAsString(), 'options' => $options, 'devlog' => $devLog);
         if ($exception instanceof tx_rnbase_util_Exception) {
             $dataVar['exception_data'] = $exception->getAdditional(FALSE);
         }
         if (tx_rnbase_util_Logger::isFatalEnabled()) {
             tx_rnbase_util_Logger::fatal('Task [' . get_class($this) . '] failed.' . ' Error(' . $exception->getCode() . '):' . $exception->getMessage(), $this->getExtKey(), $dataVar);
         }
         // Exception Mail an die Entwicker senden
         $mail = tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'sendEmailOnException');
         if (!empty($mail)) {
             $this->sendErrorMail($mail, tx_rnbase::makeInstance('tx_rnbase_util_Exception', get_class($exception) . ': ' . $exception->getMessage(), $exception->getCode(), $dataVar, $exception));
         }
         // Wir geben die Exception weiter,
         // damit der Scheduler eine entsprechende Meldung ausgeben kann.
         throw $exception;
     }
     $memoryUsageAtEnd = memory_get_usage();
     tx_rnbase_util_Logger::info('[' . get_class($this) . ']: Scheduler ends successful ', $this->getExtKey(), array('Execution Time' => t3lib_div::milliseconds() - $startTimeInMilliseconds . ' ms', 'Memory Start' => $memoryUsageAtStart . ' Bytes', 'Memory End' => $memoryUsageAtEnd . ' Bytes', 'Memory Consumed' => $memoryUsageAtEnd - $memoryUsageAtStart . ' Bytes'));
     return true;
 }