Advertisement
Guest User

02.ErrorLogger

a guest
Sep 6th, 2014
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <?php
  2. $errorLog = $_GET['errorLog'];
  3. preg_match_all('/Exception in thread \"[A-Za-z_.]+\"\s*java\.(.)+[A-Za-z]+\: [0-9]+\s*at [A-Za-z_.]+\.[A-Za-z]+\([A-Za-z_]+\.[A-Za-z]+\:[0-9]+\)/', $errorLog, $lines);
  4.  
  5. $lineNumberArr = [];
  6. $methodArr = [];
  7. $fileNameArr = [];
  8. $exceptionsArr = [];
  9. foreach ($lines[0] as $line) {
  10.     preg_match('/[0-9]+\)/', $line, $lineNumberArr[]);
  11.     preg_match('/[A-Za-z_]+\(/', $line, $methodArr[]);
  12.     preg_match('/\([A-Za-z_]+\.[A-Za-z]+/', $line, $fileNameArr[]);
  13.     preg_match('/\.[A-Za-z]+\:/', $line, $exceptionsArr[]);
  14. }
  15.  
  16. // clear all the brackets from the entries
  17. $fileNames = [];
  18. foreach ($fileNameArr as $entry) {
  19.     foreach ($entry as $name) {
  20.         $fileNames[] = substr($name, 1, strlen($name));
  21.     }
  22. }
  23. // clear all the brackets from the entries
  24. $exceptions = [];
  25. foreach ($exceptionsArr as $line) {
  26.     foreach ($line as $str) {
  27.         $exceptions[] = substr($str, 1, strlen($str) - 2);
  28.     }
  29. }
  30. // clear all the brackets from the entries
  31. $lineNum = [];
  32. foreach ($lineNumberArr as $entry) {
  33.     foreach ($entry as $number) {
  34.         $lineNum[] = substr($number, 0, strlen($number) - 1);
  35.     }
  36. }
  37. // clear all the brackets from the entries
  38. $method= [];
  39. foreach ($methodArr as $entry) {
  40.     foreach ($entry as $name) {
  41.         $method[] = substr($name, 0, strlen($name) - 1);
  42.     }
  43. }
  44.  
  45. $output = "<ul>";
  46.  
  47. for ($i = 0; $i <count($lines[0]); $i++) {
  48.     $output .= "<li>line ";
  49.     $output .= "<strong>" . htmlspecialchars($lineNum[$i]) . "</strong> - ";
  50.     $output .= "<strong>" . htmlspecialchars($exceptions[$i]) . "</strong> in ";
  51.     $output .= "<em>" . htmlspecialchars($fileNames[$i]) . ":" . htmlspecialchars($method[$i]) . "</em></li>";
  52. }
  53.  
  54. $output .= "</ul>";
  55. echo $output;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement