public static function catchError($ex, $errorString = '', $errorFile = '', $errorLine = 0)
 {
     var_dump(array_reverse($ex->getTrace()));
     if ($ex instanceof \Error) {
         Log::logActivity($ex->getMessage() . '.' . ' [' . basename($ex->getFile()) . ':' . $ex->getLine() . ']', 'err', 'sys');
     } elseif ($ex instanceof \Exception) {
         Log::logActivity($ex->getMessage() . ' [' . basename($ex->getFile()) . ':' . $ex->getLine() . ']', 'exc', 'sys');
     } else {
         Log::logActivity($errorString . '.' . ' [' . basename($errorFile) . ':' . $errorLine . ']', 'err', 'sys');
     }
 }
Exemple #2
0
 /**
  * Gets the last line from the current log file.
  *
  * @param   bool    $thisSession    (Optional) Whether the log should be from
  *                                  the current session only.
  * @return  string|bool  A string containing the last log line.
  *                       False if the log file is empty or unreadable.
  */
 public static function getLastLog($thisSession = false)
 {
     if ($thisSession) {
         return self::$lastLog;
     } elseif (!$thisSession) {
         $logFileContent = Log::logRead();
         $logFileContentArray = @explode(PHP_EOL, $logFileContent);
         if (count($logFileContentArray) != 0) {
             // Last line is empty due to fwrite() and the next one is the one we need.
             return $logFileContentArray[count($logFileContentArray) - 2];
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Exemple #3
0
 /**
  * Returns the Nth segment of a URL or an empty string if the Nth segment is null.
  *
  * @param   $urlSegmentId
  * @return  string/bool
  */
 public function urlSegment($urlSegmentId = 0)
 {
     if (!self::validOffset($urlSegmentId)) {
         Log::logActivity('Invalid offset provided. Expecting valid array offset.', 'err', 'sys', __CLASS__, __METHOD__);
         return false;
     }
     return isset($this->urlSegments[$urlSegmentId]) ? $this->urlSegments[$urlSegmentId] : '';
 }