From 32cb506bcd412b789770f5a96f590b06fc8b96e6 Mon Sep 17 00:00:00 2001 From: "Emanuele \"ToX\" Toscano" Date: Tue, 19 Sep 2023 10:54:01 +0200 Subject: [PATCH] Highlight error types --- parsers/apache24.php | 13 +++++++------ parsers/cakephp3.php | 13 +++++++------ parsers/cakephp4.php | 13 +++++++------ parsers/codeigniter.php | 9 +++++---- parsers/laravel.php | 11 ++++++----- parsers/php_custom.php | 15 ++++++++------- webroot/css/layout.css | 2 +- 7 files changed, 41 insertions(+), 35 deletions(-) diff --git a/parsers/apache24.php b/parsers/apache24.php index 115c714..15a6fb4 100644 --- a/parsers/apache24.php +++ b/parsers/apache24.php @@ -23,17 +23,18 @@ $line = preg_replace('[\[client(.*?)\]]', '', $line, 1); $line = str_replace('PHP', '', $line); $line = str_replace('\n', '
', $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: /", "Debug_log: ", $line); - $line = preg_replace("/^Notice: /", "Notice: ", $line); - $line = preg_replace("/^Warning: /", "Warning: ", $line); - $line = preg_replace("/^Fatal error: /", "Fatal error: ", $line); - $line = preg_replace("/^Parse error: /", "Parse error: ", $line); - $line = preg_replace("/^Error: /", "Error: ", $line); + $line = preg_replace("/^(\s*)Debug_log: /", "Debug_log: ", $line); + $line = preg_replace("/^(\s*)Notice: /", "Notice: ", $line); + $line = preg_replace("/^(\s*)Warning: /", "Warning: ", $line); + $line = preg_replace("/^(\s*)Fatal error: /", "Fatal error: ", $line); + $line = preg_replace("/^(\s*)Parse error: /", "Parse error: ", $line); + $line = preg_replace("/^(\s*)Error: /", "Error: ", $line); // Save the log entry $logs[$time][] = $line; diff --git a/parsers/cakephp3.php b/parsers/cakephp3.php index 3bf8af7..a63503d 100644 --- a/parsers/cakephp3.php +++ b/parsers/cakephp3.php @@ -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", "Debug_log: ", $line); - $line = preg_replace("/^Notice: /i", "Notice: ", $line); - $line = preg_replace("/^Warning: /i", "Warning: ", $line); - $line = preg_replace("/^Fatal error: /i", "Fatal error: ", $line); - $line = preg_replace("/^Parse error: /i", "Parse error: ", $line); - $line = preg_replace("/^Error: /i", "Error: ", $line); + $line = preg_replace("/^(\s*)Debug_log: /i", "Debug_log: ", $line); + $line = preg_replace("/^(\s*)Notice: /i", "Notice: ", $line); + $line = preg_replace("/^(\s*)Warning: /i", "Warning: ", $line); + $line = preg_replace("/^(\s*)Fatal error: /i", "Fatal error: ", $line); + $line = preg_replace("/^(\s*)Parse error: /i", "Parse error: ", $line); + $line = preg_replace("/^(\s*)Error: /i", "Error: ", $line); // Save the log entry $logs[$time][] = $line; diff --git a/parsers/cakephp4.php b/parsers/cakephp4.php index ff6859e..29806c4 100644 --- a/parsers/cakephp4.php +++ b/parsers/cakephp4.php @@ -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", "Debug_log ", $line); - $line = preg_replace("/^Notice: /i", "Notice ", $line); - $line = preg_replace("/^Warning: /i", "Warning ", $line); - $line = preg_replace("/^Fatal error: /i", "Fatal error ", $line); - $line = preg_replace("/^Parse error: /i", "Parse error ", $line); - $line = preg_replace("/^Error: /i", "Error ", $line); + $line = preg_replace("/^(\s*)Debug_log: /i", "Debug_log ", $line); + $line = preg_replace("/^(\s*)Notice: /i", "Notice ", $line); + $line = preg_replace("/^(\s*)Warning: /i", "Warning ", $line); + $line = preg_replace("/^(\s*)Fatal error: /i", "Fatal error ", $line); + $line = preg_replace("/^(\s*)Parse error: /i", "Parse error ", $line); + $line = preg_replace("/^(\s*)Error: /i", "Error ", $line); // Save the log entry $logs[$time][] = $line; diff --git a/parsers/codeigniter.php b/parsers/codeigniter.php index 97ed02e..9cd44eb 100644 --- a/parsers/codeigniter.php +++ b/parsers/codeigniter.php @@ -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 - /", "Notice: ", $line); - $line = preg_replace("/^WARNING - /", "Warning: ", $line); - $line = preg_replace("/^INFO - /", "Info: ", $line); - $line = preg_replace("/^ERROR - /", "Error: ", $line); + $line = preg_replace("/^(\s*)NOTICE - /", "Notice: ", $line); + $line = preg_replace("/^(\s*)WARNING - /", "Warning: ", $line); + $line = preg_replace("/^(\s*)INFO - /", "Info: ", $line); + $line = preg_replace("/^(\s*)ERROR - /", "Error: ", $line); $line = str_replace("Severity: Warning", "Warning ", $line); diff --git a/parsers/laravel.php b/parsers/laravel.php index 7b95ce2..fb3237d 100644 --- a/parsers/laravel.php +++ b/parsers/laravel.php @@ -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', '
', $line); @@ -23,11 +24,11 @@ $line = preg_replace('/\s+$/m', '', $line); // Highlight the type of errors, using a badge - $line = preg_replace("/^Debug_log: /", "Debug_log: ", $line); - $line = preg_replace("/^Notice: /", "Notice: ", $line); - $line = preg_replace("/^Warning: /", "Warning: ", $line); - $line = preg_replace("/^Fatal error: /", "Fatal error: ", $line); - $line = preg_replace("/^Parse error: /", "Parse error: ", $line); + $line = preg_replace("/^(\s*)Debug_log: /", "Debug_log: ", $line); + $line = preg_replace("/^(\s*)Notice: /", "Notice: ", $line); + $line = preg_replace("/^(\s*)Warning: /", "Warning: ", $line); + $line = preg_replace("/^(\s*)Fatal error: /", "Fatal error: ", $line); + $line = preg_replace("/^(\s*)Parse error: /", "Parse error: ", $line); $line = preg_replace("/^(.*)\.ERROR: /", "$1 Error: ", $line); // Save the log entry diff --git a/parsers/php_custom.php b/parsers/php_custom.php index e324af1..99aa712 100644 --- a/parsers/php_custom.php +++ b/parsers/php_custom.php @@ -22,19 +22,20 @@ $line = preg_replace('[\[client(.*?)\]]', '', $line, 1); $line = str_replace('PHP', '', $line); $line = str_replace('\n', '
', $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/", "Other: ", $line); - $line = preg_replace("/^E_NOTICE/", "Notice: ", $line); - $line = preg_replace("/^E_WARNING/", "Warning: ", $line); - $line = preg_replace("/^E_ERROR/", "Error: ", $line); - $line = preg_replace("/^E_USER_NOTICE/", "Notice: ", $line); - $line = preg_replace("/^E_USER_WARNING/", "Warning: ", $line); - $line = preg_replace("/^E_USER_ERROR/", "Error: ", $line); + $line = preg_replace("/^(\s*)OTHER/", "Other: ", $line); + $line = preg_replace("/^(\s*)E_NOTICE/", "Notice: ", $line); + $line = preg_replace("/^(\s*)E_WARNING/", "Warning: ", $line); + $line = preg_replace("/^(\s*)E_ERROR/", "Error: ", $line); + $line = preg_replace("/^(\s*)E_USER_NOTICE/", "Notice: ", $line); + $line = preg_replace("/^(\s*)E_USER_WARNING/", "Warning: ", $line); + $line = preg_replace("/^(\s*)E_USER_ERROR/", "Error: ", $line); $line = preg_replace("/^(\w*)Exception/", "Exception: ", $line); $line = preg_replace("/^(\w*)Error/", "Error: ", $line); diff --git a/webroot/css/layout.css b/webroot/css/layout.css index c050375..e98fc7e 100755 --- a/webroot/css/layout.css +++ b/webroot/css/layout.css @@ -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 {