Advertisement
Valleri

error logger

Sep 5th, 2014
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. <?php
  2. $text = $_GET['errorLog'];
  3.  
  4.  
  5. $myRegex = "/\s*Exception\s+in\s*thread\s+\"[^\"]+\s*\"\s*java.([^\:]+)\s*\:\s*\d+\s*at\s+([^\(]+)\s*\(\s*([^\)]+)\s*\)/m";
  6.  
  7. preg_match_all($myRegex, $text, $result);
  8. echo "<ul>";
  9. for($i = 0; $i < count($result[0]) ;$i++) {
  10.     $getFullErrorType = explode('.', $result[1][$i]);
  11.     $errorType = $getFullErrorType[count($getFullErrorType) - 1];
  12.     $getFunction = explode('.', $result[2][$i]);
  13.     $function = $getFunction[count($getFunction) - 1];
  14.  
  15.     $getLineAndFile = explode(":", $result[3][$i]);
  16.     $file = $getLineAndFile[0];
  17.     $line = $getLineAndFile[1];
  18.  
  19.     echo "<li>line <strong>" .htmlspecialchars($line) . "</strong> - ";
  20.     echo "<strong>" . htmlspecialchars($errorType) . "</strong> in ";
  21.     echo "<em>" . $file . ":" . $function . "</em></li>";
  22.  
  23. }
  24. echo "</ul>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement