Exemplo n.º 1
0
 /**
  * Log an error.
  *
  * @param PEAR_error $result The reponse of the transport.
  */
 function _log($result)
 {
     global $conf;
     $msg = $result->getMessage() . '; Code: ' . $result->getCode();
     $file = false;
     $line = false;
     $user_info = $result->getUserInfo();
     if (!empty($user_info)) {
         if (preg_match('/FILE: (.*), LINE: (.*)/', $user_info, $matches)) {
             $file = $matches[1];
             $line = $matches[2];
         }
     }
     if (!$file) {
         $frames = $result->getBacktrace();
         if (count($frames) > 1) {
             $frame = $frames[1];
         } else {
             if (count($frames) == 1) {
                 $frame = $frames[0];
             }
         }
         if (isset($frame['file'])) {
             $file = $frame['file'];
         }
         if (isset($frame['line'])) {
             $line = $frame['line'];
         }
     }
     if (!$file) {
         /* Log all errors */
         $file = __FILE__;
         $line = __LINE__;
     }
     /* In debugging mode the errors get delivered to the screen
      * without a time stamp (mainly because of unit testing)
      */
     if (!isset($conf['kolab']['filter']['debug']) || !$conf['kolab']['filter']['debug']) {
         Horde::log($msg, 'ERR');
     } else {
         $msg .= ' (Line ' . $frame['line'] . ' in ' . basename($frame['file']) . ")\n";
         fwrite(STDOUT, $msg);
     }
 }
Exemplo n.º 2
0
 /**
  * Rewrite the code to something postfix can understand.
  *
  * @param PEAR_error $result The reponse of the transport.
  *
  * @return PEAR_error An error with a rewritten error code.
  */
 function rewriteCode($result)
 {
     list($resultcode, $resultmessage) = $this->_transport->getResponse();
     if ($resultcode < 500) {
         $code = EX_TEMPFAIL;
     } else {
         $code = EX_UNAVAILABLE;
     }
     $append = sprintf(': %s, original code %s', $resultmessage, $resultcode);
     $result->message = $result->getMessage() . $append;
     $result->code = OUT_LOG | OUT_STDOUT | $code;
     return $result;
 }