Skip to content

Commit

Permalink
Highlight error types
Browse files Browse the repository at this point in the history
  • Loading branch information
ToX82 committed Sep 19, 2023
1 parent 30ba529 commit 32cb506
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 35 deletions.
13 changes: 7 additions & 6 deletions parsers/apache24.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@
$line = preg_replace('[\[client(.*?)\]]', '', $line, 1);
$line = str_replace('PHP', '', $line);
$line = str_replace('\n', '<br>', $line);
$line = htmlentities($line);

// remove trailing spaces at the end of the line
$line = preg_replace('/\s+$/m', '', $line);

// Highlight the type of errors, using a badge
$line = preg_replace("/^Debug_log: /", "<span class='lh-badge' style='background-color: #1e88e5;'>Debug_log:</span> ", $line);
$line = preg_replace("/^Notice: /", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^Warning: /", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^Fatal error: /", "<span class='lh-badge' style='background-color: #a71616;'>Fatal error:</span> ", $line);
$line = preg_replace("/^Parse error: /", "<span class='lh-badge' style='background-color: #a71616;'>Parse error:</span> ", $line);
$line = preg_replace("/^Error: /", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);
$line = preg_replace("/^(\s*)Debug_log: /", "<span class='lh-badge' style='background-color: #1e88e5;'>Debug_log:</span> ", $line);
$line = preg_replace("/^(\s*)Notice: /", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^(\s*)Warning: /", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^(\s*)Fatal error: /", "<span class='lh-badge' style='background-color: #a71616;'>Fatal error:</span> ", $line);
$line = preg_replace("/^(\s*)Parse error: /", "<span class='lh-badge' style='background-color: #a71616;'>Parse error:</span> ", $line);
$line = preg_replace("/^(\s*)Error: /", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);

// Save the log entry
$logs[$time][] = $line;
Expand Down
13 changes: 7 additions & 6 deletions parsers/cakephp3.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

// remove trailing spaces at the end of the line
$line = preg_replace('/\s+$/m', '', $line);
$line = htmlentities($line);

// Highlight the type of errors, using a badge
$line = preg_replace("/^Debug_log: /i", "<span class='lh-badge' style='background-color: #1e88e5;'>Debug_log:</span> ", $line);
$line = preg_replace("/^Notice: /i", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^Warning: /i", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^Fatal error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Fatal error:</span> ", $line);
$line = preg_replace("/^Parse error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Parse error:</span> ", $line);
$line = preg_replace("/^Error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);
$line = preg_replace("/^(\s*)Debug_log: /i", "<span class='lh-badge' style='background-color: #1e88e5;'>Debug_log:</span> ", $line);
$line = preg_replace("/^(\s*)Notice: /i", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^(\s*)Warning: /i", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^(\s*)Fatal error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Fatal error:</span> ", $line);
$line = preg_replace("/^(\s*)Parse error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Parse error:</span> ", $line);
$line = preg_replace("/^(\s*)Error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);

// Save the log entry
$logs[$time][] = $line;
Expand Down
13 changes: 7 additions & 6 deletions parsers/cakephp4.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

// remove trailing spaces at the end of the line
$line = preg_replace('/\s+$/m', '', $line);
$line = htmlentities($line);

// Highlight the type of errors, using a badge
$line = preg_replace("/^Debug_log: /i", "<span class='lh-badge' style='background-color: #1e88e5;'>Debug_log</span> ", $line);
$line = preg_replace("/^Notice: /i", "<span class='lh-badge' style='background-color: #318418;'>Notice</span> ", $line);
$line = preg_replace("/^Warning: /i", "<span class='lh-badge' style='background-color: #a79716;'>Warning</span> ", $line);
$line = preg_replace("/^Fatal error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Fatal error</span> ", $line);
$line = preg_replace("/^Parse error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Parse error</span> ", $line);
$line = preg_replace("/^Error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Error</span> ", $line);
$line = preg_replace("/^(\s*)Debug_log: /i", "<span class='lh-badge' style='background-color: #1e88e5;'>Debug_log</span> ", $line);
$line = preg_replace("/^(\s*)Notice: /i", "<span class='lh-badge' style='background-color: #318418;'>Notice</span> ", $line);
$line = preg_replace("/^(\s*)Warning: /i", "<span class='lh-badge' style='background-color: #a79716;'>Warning</span> ", $line);
$line = preg_replace("/^(\s*)Fatal error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Fatal error</span> ", $line);
$line = preg_replace("/^(\s*)Parse error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Parse error</span> ", $line);
$line = preg_replace("/^(\s*)Error: /i", "<span class='lh-badge' style='background-color: #a71616;'>Error</span> ", $line);

// Save the log entry
$logs[$time][] = $line;
Expand Down
9 changes: 5 additions & 4 deletions parsers/codeigniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@

// remove trailing spaces at the end of the line
$line = preg_replace('/\s+$/m', '', $line);
$line = htmlentities($line);

// Highlight the type of errors, using a badge
$line = preg_replace("/^NOTICE - /", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^WARNING - /", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^INFO - /", "<span class='lh-badge' style='background-color: #a79716;'>Info:</span> ", $line);
$line = preg_replace("/^ERROR - /", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);
$line = preg_replace("/^(\s*)NOTICE - /", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^(\s*)WARNING - /", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^(\s*)INFO - /", "<span class='lh-badge' style='background-color: #a79716;'>Info:</span> ", $line);
$line = preg_replace("/^(\s*)ERROR - /", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);

$line = str_replace("Severity: Warning", "<span class='lh-badge' style='background-color: #a79716;'>Warning</span> ", $line);

Expand Down
11 changes: 6 additions & 5 deletions parsers/laravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
if ($time != '') {
// Remove date-time and other useless informations from the log details
$line = normalizeChars($line);
$line = htmlentities($line);
$line = substr($line, 22);
$line = str_replace('PHP', '', $line);
$line = str_replace('\n', '<br>', $line);
Expand All @@ -23,11 +24,11 @@
$line = preg_replace('/\s+$/m', '', $line);

// Highlight the type of errors, using a badge
$line = preg_replace("/^Debug_log: /", "<span class='lh-badge' style='background-color: #1e88e5;'>Debug_log:</span> ", $line);
$line = preg_replace("/^Notice: /", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^Warning: /", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^Fatal error: /", "<span class='lh-badge' style='background-color: #a71616;'>Fatal error:</span> ", $line);
$line = preg_replace("/^Parse error: /", "<span class='lh-badge' style='background-color: #a71616;'>Parse error:</span> ", $line);
$line = preg_replace("/^(\s*)Debug_log: /", "<span class='lh-badge' style='background-color: #1e88e5;'>Debug_log:</span> ", $line);
$line = preg_replace("/^(\s*)Notice: /", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^(\s*)Warning: /", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^(\s*)Fatal error: /", "<span class='lh-badge' style='background-color: #a71616;'>Fatal error:</span> ", $line);
$line = preg_replace("/^(\s*)Parse error: /", "<span class='lh-badge' style='background-color: #a71616;'>Parse error:</span> ", $line);
$line = preg_replace("/^(.*)\.ERROR: /", "<span class='lh-badge' style='background-color: #a71616;'>$1 Error:</span> ", $line);

// Save the log entry
Expand Down
15 changes: 8 additions & 7 deletions parsers/php_custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@
$line = preg_replace('[\[client(.*?)\]]', '', $line, 1);
$line = str_replace('PHP', '', $line);
$line = str_replace('\n', '<br>', $line);
$line = htmlentities($line);
$line = normalizeChars($line);

// remove trailing spaces at the end of the line
$line = preg_replace('/\s+$/m', '', $line);

// Highlight the type of errors, using a badge
$line = preg_replace("/^OTHER/", "<span class='lh-badge' style='background-color: #1e88e5;'>Other:</span> ", $line);
$line = preg_replace("/^E_NOTICE/", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^E_WARNING/", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^E_ERROR/", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);
$line = preg_replace("/^E_USER_NOTICE/", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^E_USER_WARNING/", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^E_USER_ERROR/", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);
$line = preg_replace("/^(\s*)OTHER/", "<span class='lh-badge' style='background-color: #1e88e5;'>Other:</span> ", $line);
$line = preg_replace("/^(\s*)E_NOTICE/", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^(\s*)E_WARNING/", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^(\s*)E_ERROR/", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);
$line = preg_replace("/^(\s*)E_USER_NOTICE/", "<span class='lh-badge' style='background-color: #318418;'>Notice:</span> ", $line);
$line = preg_replace("/^(\s*)E_USER_WARNING/", "<span class='lh-badge' style='background-color: #a79716;'>Warning:</span> ", $line);
$line = preg_replace("/^(\s*)E_USER_ERROR/", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);
$line = preg_replace("/^(\w*)Exception/", "<span class='lh-badge' style='background-color: #a71616;'>Exception:</span> ", $line);
$line = preg_replace("/^(\w*)Error/", "<span class='lh-badge' style='background-color: #a71616;'>Error:</span> ", $line);

Expand Down
2 changes: 1 addition & 1 deletion webroot/css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ li.nav-item {
background-color: #0d47a1;
color: #fff;
font-weight: bold;
font-size: 120%;
font-size: 100%;
padding: 1px 5px;
}
.badge {
Expand Down

0 comments on commit 32cb506

Please sign in to comment.