Advertisement
coasterka

02_ErrorLogger.php

Sep 6th, 2014
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2.  
  3. $errorLogInput = $_GET['errorLog'];
  4.  
  5. $exceptionPattern = '/(Exception in thread[\s\"\'a-z\.]+[a-z\.]+([A-Za-z\.]+):\s*\d*)\s*(at\s*([A-Za-z_-]+\.([a-zA-Z]+)+)\(([A-Za-z_-]+\.[a-zA-Z\d]+):(\d+)\))/';
  6.  
  7. preg_match_all($exceptionPattern, $errorLogInput, $exceptionArr);
  8.  
  9. $exceptionName = $exceptionArr[2];
  10. $methodName = $exceptionArr[5];
  11. $fileName = $exceptionArr[6];
  12. $lineNumber = $exceptionArr[7];
  13.  
  14. $result = '';
  15.  
  16. if (sizeof($testObject > 0)) {
  17.     $result .= "<ul>";
  18.     foreach ($lineNumber as $key => $value) {
  19.         $result .= "<li>line <strong>";
  20.         $result .= htmlspecialchars($lineNumber[$key]);
  21.         $result .= "</strong> - <strong>";
  22.         $result .= htmlspecialchars($exceptionName[$key]);
  23.         $result .= "</strong> in <em>";
  24.         $result .= htmlspecialchars($fileName[$key]);
  25.         $result .= ":";
  26.         $result .= htmlspecialchars($methodName[$key]);
  27.         $result .= "</em></li>";
  28.     }
  29.     $result .= "</ul>";
  30. }
  31. echo $result;
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement