From e14766fb143d493d9084ff663fb2a85af3c7e4be Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 13:50:32 +0200 Subject: [PATCH 001/644] implementing features --- controllers/job.php | 1 + views/job/detail.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/controllers/job.php b/controllers/job.php index 4dd7d74921..ce68e0818e 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -145,6 +145,7 @@ public function detail() { $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); + $this->view->assign('logErrors', 5); } else { throw new Exception("No job with id: " . $this->get['id']); } diff --git a/views/job/detail.php b/views/job/detail.php index 40e23cb5aa..f849aead7c 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -224,6 +224,16 @@ function updateProgress() { +
+ + Errors: + +
+
+ + Warnings: + +
@@ -235,7 +245,7 @@ function updateProgress() {
- +
From 41788c87fd25453698e1a607c9d65534d58428a4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:11:18 +0200 Subject: [PATCH 002/644] implementing features --- controllers/job.php | 9 ++++++++- core/LogUtils.php | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 core/LogUtils.php diff --git a/controllers/job.php b/controllers/job.php index ce68e0818e..d265fcd412 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -30,6 +30,7 @@ use DBA\Job; use DBA\ProjectUser; use DBA\QueryFilter; +include 'core/LogUtils.php'; class Job_Controller extends Controller { @@ -145,7 +146,13 @@ public function detail() { $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); - $this->view->assign('logErrors', 5); + + // Log handling + $logUtil = new LogUtils($job); + $errors = $logUtil->countLogOccurances("error"); + $warnings = $logUtil->countLogOccurances("warning"); + $this->view->assign('logErrors', $errors); + $this->view->assign('logErrors', $warnings); } else { throw new Exception("No job with id: " . $this->get['id']); } diff --git a/core/LogUtils.php b/core/LogUtils.php new file mode 100644 index 0000000000..70c1f999ea --- /dev/null +++ b/core/LogUtils.php @@ -0,0 +1,23 @@ +count = 5; + + + return $this->count; + } +} + +?> \ No newline at end of file From a14acace15ee40ce11b5a68091f810ffcd302759 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:12:23 +0200 Subject: [PATCH 003/644] implementing features --- controllers/job.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/job.php b/controllers/job.php index d265fcd412..81d646d198 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -30,7 +30,7 @@ use DBA\Job; use DBA\ProjectUser; use DBA\QueryFilter; -include 'core/LogUtils.php'; +include '../core/LogUtils.php'; class Job_Controller extends Controller { From c1c7e563a8f24e40239dad3b41d54faf3ae7b5b6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:13:10 +0200 Subject: [PATCH 004/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 70c1f999ea..bdbbce2138 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -11,7 +11,7 @@ class LogUtils { * @param string $keyword * @returns int $count */ - public function countOccurances(string $keyword): int { + public function countLogOccurances(string $keyword): int { $this->count = 5; From 224dfdb435986bab5d81562a0a2cacd1398499db Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:13:36 +0200 Subject: [PATCH 005/644] implementing features --- controllers/job.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/job.php b/controllers/job.php index 81d646d198..017cc19f55 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -152,7 +152,7 @@ public function detail() { $errors = $logUtil->countLogOccurances("error"); $warnings = $logUtil->countLogOccurances("warning"); $this->view->assign('logErrors', $errors); - $this->view->assign('logErrors', $warnings); + $this->view->assign('logWarnings', $warnings); } else { throw new Exception("No job with id: " . $this->get['id']); } From 4d938bbd09460f23ec582d00bd4e3fac7ee899e8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:16:03 +0200 Subject: [PATCH 006/644] implementing features --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index f849aead7c..4914f0faff 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -224,12 +224,12 @@ function updateProgress() {
-
+
Errors:
-
+
Warnings: From 3d77147dd511af71cf7a5e9b569bbd7a389f91d3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:16:31 +0200 Subject: [PATCH 007/644] implementing features --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 4914f0faff..e98ce3a045 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -224,12 +224,12 @@ function updateProgress() {
-
+
Errors:
-
+
Warnings: From 375313ef1030cdb59fbd32fb299249412f992062 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:16:56 +0200 Subject: [PATCH 008/644] implementing features --- views/job/detail.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index e98ce3a045..7a97c91451 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -224,17 +224,17 @@ function updateProgress() {
-
+
Errors:
-
+
Warnings:
-
+
From b81c1af4747e64840f425b7998368716b9984ab0 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:17:35 +0200 Subject: [PATCH 009/644] implementing features --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 7a97c91451..6a417dafa8 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -224,12 +224,12 @@ function updateProgress() {
-
+
Errors:
-
+
Warnings: From 38f33b03b02160e72e4c835873f0b31cbeee1e63 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:18:02 +0200 Subject: [PATCH 010/644] implementing features --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 6a417dafa8..34b8b2d65c 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -234,7 +234,7 @@ function updateProgress() { Warnings:
-
+
From 10b09ecb7bf277ebc890e8df83506aac14a0240e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:18:27 +0200 Subject: [PATCH 011/644] implementing features --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 34b8b2d65c..c8f76fb4f2 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -234,7 +234,7 @@ function updateProgress() { Warnings:
-
+
From eba67c9a7d1c196634fd284f0d26c9cc544a3b39 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:19:20 +0200 Subject: [PATCH 012/644] implementing features --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index c8f76fb4f2..4f731dffff 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -234,7 +234,7 @@ function updateProgress() { Warnings:
-
+
From 1d3ca7de967943fbc6de78af5374fa322fb47422 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:19:40 +0200 Subject: [PATCH 013/644] implementing features --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 4f731dffff..34b8b2d65c 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -234,7 +234,7 @@ function updateProgress() { Warnings:
-
+
From 52aef665abbb2c6c7442d549137ea3a399198e5d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:21:04 +0200 Subject: [PATCH 014/644] implementing features --- views/job/detail.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 34b8b2d65c..59bc28c6f2 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -214,7 +214,7 @@ function updateProgress() {
-
+
-
+
Errors:
-
+
Warnings:
-
+
From 2b8691a473ee5f062bcd3cc6bc410cefa3676ec0 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:21:40 +0200 Subject: [PATCH 015/644] implementing features --- views/job/detail.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 59bc28c6f2..34b8b2d65c 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -214,7 +214,7 @@ function updateProgress() {
-
+
-
+
Errors:
-
+
Warnings:
-
+
From 6aa3998f08522215bc69bf9b903226288b7b2761 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:44:30 +0200 Subject: [PATCH 016/644] implementing features --- controllers/job.php | 4 +++- core/LogUtils.php | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 017cc19f55..6113002788 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -152,7 +152,9 @@ public function detail() { $errors = $logUtil->countLogOccurances("error"); $warnings = $logUtil->countLogOccurances("warning"); $this->view->assign('logErrors', $errors); - $this->view->assign('logWarnings', $warnings); + + $this->view->assign('logWarnings', 5); // TODO change to $warnings when done + // unset($logUtil); // TODO delete to require less space, since its a copy of log, might be big? } else { throw new Exception("No job with id: " . $this->get['id']); } diff --git a/core/LogUtils.php b/core/LogUtils.php index bdbbce2138..511df587f7 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -1,22 +1,30 @@ job = $job; + $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; + $log = Util::readFileContents($path); + if ($log === false) { + $this->log = ""; + } else { + $this->log = $log; + } + } /** * @param string $keyword * @returns int $count */ public function countLogOccurances(string $keyword): int { - - $this->count = 5; + $count = 0; + echo $this->log; - return $this->count; + return $count; } } From d763aad45061bc3568b046b44126663318d4dbd1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:49:04 +0200 Subject: [PATCH 017/644] implementing features --- controllers/job.php | 8 ++++---- core/LogUtils.php | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 6113002788..fc2ef0010b 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -149,11 +149,11 @@ public function detail() { // Log handling $logUtil = new LogUtils($job); - $errors = $logUtil->countLogOccurances("error"); - $warnings = $logUtil->countLogOccurances("warning"); - $this->view->assign('logErrors', $errors); + $errors = $logUtil->countLogOccurances("ERROR:"); + $warnings = $logUtil->countLogOccurances("WARNING:"); + $this->view->assign('logErrors', 5); - $this->view->assign('logWarnings', 5); // TODO change to $warnings when done + $this->view->assign('logWarnings', $warnings); // TODO change to $warnings when done // unset($logUtil); // TODO delete to require less space, since its a copy of log, might be big? } else { throw new Exception("No job with id: " . $this->get['id']); diff --git a/core/LogUtils.php b/core/LogUtils.php index 511df587f7..2bfe24d80a 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -20,11 +20,8 @@ public function __construct($job) { * @returns int $count */ public function countLogOccurances(string $keyword): int { - $count = 0; - echo $this->log; - - return $count; + return substr_count($this->log, $keyword); } } From 47afb0c0c799794374c306a57f67443d9fc87f72 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:49:57 +0200 Subject: [PATCH 018/644] implementing features --- controllers/job.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index fc2ef0010b..9fdc720ce5 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -151,9 +151,8 @@ public function detail() { $logUtil = new LogUtils($job); $errors = $logUtil->countLogOccurances("ERROR:"); $warnings = $logUtil->countLogOccurances("WARNING:"); - $this->view->assign('logErrors', 5); - - $this->view->assign('logWarnings', $warnings); // TODO change to $warnings when done + $this->view->assign('logErrors', $errors); + $this->view->assign('logWarnings', $warnings); // unset($logUtil); // TODO delete to require less space, since its a copy of log, might be big? } else { throw new Exception("No job with id: " . $this->get['id']); From 598ce290a6e6cc7726aeb7427d4485efa5d1181e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:51:27 +0200 Subject: [PATCH 019/644] implementing features --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 34b8b2d65c..c00bab3654 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -225,12 +225,12 @@ function updateProgress() {
- + = 0) { ?> Errors:
- + = 0) { ?> Warnings:
From ef9ba1edb78942ca1ad2f24b0767a08b41952f47 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 14:57:52 +0200 Subject: [PATCH 020/644] implementing features --- controllers/job.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/job.php b/controllers/job.php index 9fdc720ce5..37c3282578 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -153,7 +153,7 @@ public function detail() { $warnings = $logUtil->countLogOccurances("WARNING:"); $this->view->assign('logErrors', $errors); $this->view->assign('logWarnings', $warnings); - // unset($logUtil); // TODO delete to require less space, since its a copy of log, might be big? + unset($logUtil); // TODO delete to require less space, since its a copy of log, might be big? } else { throw new Exception("No job with id: " . $this->get['id']); } From 075e0c492d84f3a9ad83a163c6f054f9ba0906cb Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 19:43:55 +0200 Subject: [PATCH 021/644] implementing features --- controllers/job.php | 4 ++-- libraries/dba/models/Job.class.php | 8 +++++++- views/evaluation/detail.php | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 37c3282578..06314caf61 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -147,13 +147,13 @@ public function detail() { $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); - // Log handling + // Calculate Log errors and warnings TODO naive approach, do so during runtime of a job to be able to react early $logUtil = new LogUtils($job); $errors = $logUtil->countLogOccurances("ERROR:"); $warnings = $logUtil->countLogOccurances("WARNING:"); $this->view->assign('logErrors', $errors); $this->view->assign('logWarnings', $warnings); - unset($logUtil); // TODO delete to require less space, since its a copy of log, might be big? + unset($logUtil); } else { throw new Exception("No job with id: " . $this->get['id']); } diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index a64f8f5bbc..1d9fbd77aa 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -43,6 +43,7 @@ class Job extends AbstractModel { private $evaluationId; private $internalId; private $configurationIdentifier; + private $logAlert = "critical"; //TODO setting alert during runtime not implemented yet function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier) { $this->jobId = $jobId; @@ -220,7 +221,12 @@ function getConfigurationIdentifier(){ function setConfigurationIdentifier($configurationIdentifier){ $this->configurationIdentifier = $configurationIdentifier; } - + function getLogAlert() { + return $this->logAlert; + } + function setLogAlert($alert) { + $this->logAlert = $alert; + } const JOB_ID = "jobId"; const USER_ID = "userId"; const DESCRIPTION = "description"; diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 86a609a7f3..86e831cc3b 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -198,6 +198,7 @@ function submitData() { # Description + Status @@ -207,6 +208,7 @@ function submitData() { getInternalId(); ?> getDescription(); ?> + getLogAlert(); ?> getStatus() == Define::JOB_STATUS_SCHEDULED) { ?> scheduled From 27e60150b140e8484c5d0a7aa09b00114855a2c0 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 19:54:04 +0200 Subject: [PATCH 022/644] implementing features --- libraries/dba/models/Job.class.php | 2 +- views/evaluation/detail.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 1d9fbd77aa..0de787f256 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -43,7 +43,7 @@ class Job extends AbstractModel { private $evaluationId; private $internalId; private $configurationIdentifier; - private $logAlert = "critical"; //TODO setting alert during runtime not implemented yet + private $logAlert = "error"; //TODO setting alert during runtime not implemented yet function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier) { $this->jobId = $jobId; diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 86e831cc3b..34db8b79b2 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -208,7 +208,13 @@ function submitData() { getInternalId(); ?> getDescription(); ?> - getLogAlert(); ?> + + getLogAlert() == 'error') { ?> + Error + getLogAlert() == 'warning') { ?> + Warning + + getStatus() == Define::JOB_STATUS_SCHEDULED) { ?> scheduled From 07e2e7ed27c397f173e20f71f389c7f6363cecef Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 19:55:28 +0200 Subject: [PATCH 023/644] implementing features --- views/evaluation/detail.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 34db8b79b2..f2f173a5e8 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -209,10 +209,10 @@ function submitData() { getInternalId(); ?> getDescription(); ?> - getLogAlert() == 'error') { ?> - Error - getLogAlert() == 'warning') { ?> - Warning + getLogAlert() == "error") { ?> + + getLogAlert() == "warning") { ?> + From 0a7f501e5c9d88f56d2a93f1b4d44e7b64516272 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 19:56:33 +0200 Subject: [PATCH 024/644] implementing features --- views/evaluation/detail.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index f2f173a5e8..21ae384be2 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -213,6 +213,8 @@ function submitData() { getLogAlert() == "warning") { ?> + + All clear From e2dcf031c77ae1a24e978a77c07919b3cf507cd4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 19:56:59 +0200 Subject: [PATCH 025/644] implementing features --- views/evaluation/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 21ae384be2..6ed23c3e30 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -210,9 +210,9 @@ function submitData() { getDescription(); ?> getLogAlert() == "error") { ?> - + getLogAlert() == "warning") { ?> - + All clear From 872edb4c0da7405455671c67a43971440fa3c577 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 19:58:09 +0200 Subject: [PATCH 026/644] implementing features --- views/evaluation/detail.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 6ed23c3e30..82730e24ad 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -210,11 +210,9 @@ function submitData() { getDescription(); ?> getLogAlert() == "error") { ?> - + getLogAlert() == "warning") { ?> - - - All clear + From 5770f52934ec4e9cfc4e44d49d5149b213b5d63c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 20:00:59 +0200 Subject: [PATCH 027/644] implementing features --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 82730e24ad..0100900efc 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -210,7 +210,7 @@ function submitData() { getDescription(); ?> getLogAlert() == "error") { ?> - + getLogAlert() == "warning") { ?> From 889fb258cdd84825b824cfbd71607be2a0a87682 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 20:01:35 +0200 Subject: [PATCH 028/644] implementing features --- views/evaluation/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 0100900efc..3be820652c 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -210,9 +210,9 @@ function submitData() { getDescription(); ?> getLogAlert() == "error") { ?> - - getLogAlert() == "warning") { ?> + getLogAlert() == "warning") { ?> + From 652f7a526f2c2e8eb35e206bd4c33b78ad855d0a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 20:12:18 +0200 Subject: [PATCH 029/644] implementing features --- controllers/evaluation.php | 2 ++ core/LogUtils.php | 3 +++ libraries/dba/models/Job.class.php | 3 +++ 3 files changed, 8 insertions(+) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 333ece9f9d..4d057d6570 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -159,6 +159,8 @@ public function detail() { $isFinished = false; } else { $resultsAvailable = true; + $logUtil = new LogUtils($subJob); + $logUtil->examineLogAndSetAlert(); } } if (sizeof($jobs) == 0) { diff --git a/core/LogUtils.php b/core/LogUtils.php index 2bfe24d80a..01cf0cc97d 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -23,6 +23,9 @@ public function countLogOccurances(string $keyword): int { return substr_count($this->log, $keyword); } + public function examineLogAndSetAlert() { + echo gettype($this->log) . "\n"; + } } ?> \ No newline at end of file diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 0de787f256..8bf2a47b28 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -26,6 +26,8 @@ namespace DBA; +include '../../../core/LogUtils.php'; + class Job extends AbstractModel { private $jobId; private $userId; @@ -227,6 +229,7 @@ function getLogAlert() { function setLogAlert($alert) { $this->logAlert = $alert; } + const JOB_ID = "jobId"; const USER_ID = "userId"; const DESCRIPTION = "description"; From 61b85e85107dc30a801c8c9eddc7e6a04f88d386 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 20:15:04 +0200 Subject: [PATCH 030/644] implementing features --- libraries/dba/models/Job.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 8bf2a47b28..03c677dd0a 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -26,8 +26,6 @@ namespace DBA; -include '../../../core/LogUtils.php'; - class Job extends AbstractModel { private $jobId; private $userId; From 5d91620c180538493f2e7a3874e45ec3799d6ae6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 20:15:44 +0200 Subject: [PATCH 031/644] implementing features --- controllers/evaluation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 4d057d6570..19006ab8b4 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -32,6 +32,7 @@ use DBA\Job; use DBA\ProjectUser; use DBA\QueryFilter; +include '../core/LogUtils.php'; class Evaluation_Controller extends Controller { From 18a53887396862829f464cc4a779e3db546d5305 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 20:38:38 +0200 Subject: [PATCH 032/644] implementing features --- core/LogUtils.php | 33 ++++++++++++++++++++++++++++-- libraries/dba/models/Job.class.php | 2 +- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 01cf0cc97d..33724d5f02 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -3,6 +3,12 @@ class LogUtils { private $job; private $log; + private $logLength = -1; + private $thresholdError = 1; + private $thresholdWarning = 3; + private $thresholdLogSize = 100; + private $logSizeWarning = false; + private $keyWordDict = ['error' => 0, 'warning' => 0]; public function __construct($job) { $this->job = $job; @@ -19,12 +25,35 @@ public function __construct($job) { * @param string $keyword * @returns int $count */ - public function countLogOccurances(string $keyword): int { + public function countLogOccurances(string $keyword) { return substr_count($this->log, $keyword); } public function examineLogAndSetAlert() { - echo gettype($this->log) . "\n"; + // Check if log is too long + $this->length = strlen($this->log); + if ($this->length > $this->thresholdError) { + $this->logSizeWarning = true; + } + // count occurances of all defined keywords. default 'error' and 'warning' + // later, system admins can define more keywords, which will be added to the dict + foreach ($this->keyWordDict as $key => $value) { + $this->keyWordDict[$key] = $this->countLogOccurances($key); + } + if ($this->keyWordDict['error'] >= $this->thresholdError) { + $this->job->setLogAlert('error'); + } + else if ($this->keyWordDict['warning'] >= $this->thresholdWarning) { + $this->job->setLogAlert('warning'); + } + } + + // Will be changed in the systems settings + public function setThresholdLogSize($size) { + $this->thresholdLogSize = $size; + } + public function getThresholdLogSize($size) { + return $this->thresholdLogSize; } } diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 03c677dd0a..dcd29f0036 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -43,7 +43,7 @@ class Job extends AbstractModel { private $evaluationId; private $internalId; private $configurationIdentifier; - private $logAlert = "error"; //TODO setting alert during runtime not implemented yet + private $logAlert; function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier) { $this->jobId = $jobId; From 16af334bf30ecfd28e176ed712687b1caebd5455 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 20:50:02 +0200 Subject: [PATCH 033/644] implementing features --- controllers/job.php | 4 ++-- core/LogUtils.php | 14 ++++++-------- libraries/dba/models/Job.class.php | 6 +++++- views/evaluation/detail.php | 2 ++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 06314caf61..1db5d5058f 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -149,8 +149,8 @@ public function detail() { // Calculate Log errors and warnings TODO naive approach, do so during runtime of a job to be able to react early $logUtil = new LogUtils($job); - $errors = $logUtil->countLogOccurances("ERROR:"); - $warnings = $logUtil->countLogOccurances("WARNING:"); + $errors = $logUtil->countLogOccurances("error"); + $warnings = $logUtil->countLogOccurances("warning"); $this->view->assign('logErrors', $errors); $this->view->assign('logWarnings', $warnings); unset($logUtil); diff --git a/core/LogUtils.php b/core/LogUtils.php index 33724d5f02..21c57d1669 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -5,9 +5,8 @@ class LogUtils { private $log; private $logLength = -1; private $thresholdError = 1; - private $thresholdWarning = 3; + private $thresholdWarning = 13; private $thresholdLogSize = 100; - private $logSizeWarning = false; private $keyWordDict = ['error' => 0, 'warning' => 0]; public function __construct($job) { @@ -35,19 +34,18 @@ public function examineLogAndSetAlert() { if ($this->length > $this->thresholdError) { $this->logSizeWarning = true; } - // count occurances of all defined keywords. default 'error' and 'warning' + // count occurances of all defined keywords. default keywords are 'error' and 'warning' // later, system admins can define more keywords, which will be added to the dict foreach ($this->keyWordDict as $key => $value) { $this->keyWordDict[$key] = $this->countLogOccurances($key); } - if ($this->keyWordDict['error'] >= $this->thresholdError) { - $this->job->setLogAlert('error'); - } - else if ($this->keyWordDict['warning'] >= $this->thresholdWarning) { + if ($this->keyWordDict['warning'] >= $this->thresholdError) { $this->job->setLogAlert('warning'); } + else if ($this->keyWordDict['error'] >= $this->thresholdWarning) { + $this->job->setLogAlert('error'); + } } - // Will be changed in the systems settings public function setThresholdLogSize($size) { $this->thresholdLogSize = $size; diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index dcd29f0036..8ee87ca9cd 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -44,6 +44,7 @@ class Job extends AbstractModel { private $internalId; private $configurationIdentifier; private $logAlert; + private $logSizeWarning = false; function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier) { $this->jobId = $jobId; @@ -225,9 +226,12 @@ function getLogAlert() { return $this->logAlert; } function setLogAlert($alert) { + // TODO last call of this method overwrites previous value. logic in other class first checks if its warning and then if its error $this->logAlert = $alert; } - + public function getSizeWarnining() { + return $this->logSizeWarning; + } const JOB_ID = "jobId"; const USER_ID = "userId"; const DESCRIPTION = "description"; diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 3be820652c..4b4c79f255 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -213,6 +213,8 @@ function submitData() { getLogAlert() == "warning") { ?> + getSizeWarning() == "warning") { ?> + From d09ea178f03c9dd257cfa2ae017e4bd6bd865735 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 20:58:50 +0200 Subject: [PATCH 034/644] implementing features --- core/LogUtils.php | 6 +++--- libraries/dba/models/Job.class.php | 5 ++++- views/evaluation/detail.php | 8 ++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 21c57d1669..d8f11868f9 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -30,9 +30,9 @@ public function countLogOccurances(string $keyword) { } public function examineLogAndSetAlert() { // Check if log is too long - $this->length = strlen($this->log); - if ($this->length > $this->thresholdError) { - $this->logSizeWarning = true; + $this->logLength = strlen($this->log); + if ($this->logLength > $this->thresholdLogSize) { + $this->job->SetSizeWarning(true); } // count occurances of all defined keywords. default keywords are 'error' and 'warning' // later, system admins can define more keywords, which will be added to the dict diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 8ee87ca9cd..0743d59017 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -229,9 +229,12 @@ function setLogAlert($alert) { // TODO last call of this method overwrites previous value. logic in other class first checks if its warning and then if its error $this->logAlert = $alert; } - public function getSizeWarnining() { + function getSizeWarnining() { return $this->logSizeWarning; } + function setSizeWarnining($bool) { + $this->logSizeWarning = $bool; + } const JOB_ID = "jobId"; const USER_ID = "userId"; const DESCRIPTION = "description"; diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 4b4c79f255..4b044292ab 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -199,6 +199,7 @@ function submitData() { # Description + Status @@ -213,8 +214,11 @@ function submitData() { getLogAlert() == "warning") { ?> - getSizeWarning() == "warning") { ?> - + + + + getSizeWarning()) { ?> + From cbeae0c7f0c8ed6547d6777795e0edfa30c58bd6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 20:59:49 +0200 Subject: [PATCH 035/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index d8f11868f9..f7bdb3db9a 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -1,5 +1,5 @@ Date: Mon, 8 Jul 2024 21:00:54 +0200 Subject: [PATCH 036/644] implementing features --- libraries/dba/models/Job.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 0743d59017..a79d67b465 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -229,10 +229,10 @@ function setLogAlert($alert) { // TODO last call of this method overwrites previous value. logic in other class first checks if its warning and then if its error $this->logAlert = $alert; } - function getSizeWarnining() { + function getSizeWarning() { return $this->logSizeWarning; } - function setSizeWarnining($bool) { + function setSizeWarning($bool) { $this->logSizeWarning = $bool; } const JOB_ID = "jobId"; From cb6d768e0777f4d459a799e5aa59fae1e12caea8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:03:02 +0200 Subject: [PATCH 037/644] implementing features --- controllers/job.php | 4 ++-- core/LogUtils.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 1db5d5058f..06314caf61 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -149,8 +149,8 @@ public function detail() { // Calculate Log errors and warnings TODO naive approach, do so during runtime of a job to be able to react early $logUtil = new LogUtils($job); - $errors = $logUtil->countLogOccurances("error"); - $warnings = $logUtil->countLogOccurances("warning"); + $errors = $logUtil->countLogOccurances("ERROR:"); + $warnings = $logUtil->countLogOccurances("WARNING:"); $this->view->assign('logErrors', $errors); $this->view->assign('logWarnings', $warnings); unset($logUtil); diff --git a/core/LogUtils.php b/core/LogUtils.php index f7bdb3db9a..3d01bede6a 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -7,7 +7,7 @@ class LogUtils { private $thresholdError = 1; private $thresholdWarning = 13; private $thresholdLogSize = 100; - private $keyWordDict = ['error' => 0, 'warning' => 0]; + private $keyWordDict = ['ERROR:' => 0, 'WARNING:' => 0]; public function __construct($job) { $this->job = $job; From 31b2dce72ba578fa4741bc0e1f113663051ab089 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:03:19 +0200 Subject: [PATCH 038/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 3d01bede6a..e84122be4b 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -6,7 +6,7 @@ class LogUtils { private $logLength = -1; private $thresholdError = 1; private $thresholdWarning = 13; - private $thresholdLogSize = 100; + private $thresholdLogSize = 150; private $keyWordDict = ['ERROR:' => 0, 'WARNING:' => 0]; public function __construct($job) { From 106d0895cf578423a26a025d053946d6db61da48 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:04:50 +0200 Subject: [PATCH 039/644] implementing features --- core/LogUtils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index e84122be4b..87dbc6bf50 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -39,10 +39,10 @@ public function examineLogAndSetAlert() { foreach ($this->keyWordDict as $key => $value) { $this->keyWordDict[$key] = $this->countLogOccurances($key); } - if ($this->keyWordDict['warning'] >= $this->thresholdError) { + if ($this->keyWordDict['WARNING:'] >= $this->thresholdWarning) { $this->job->setLogAlert('warning'); } - else if ($this->keyWordDict['error'] >= $this->thresholdWarning) { + else if ($this->keyWordDict['ERROR:'] >= $this->thresholdError) { $this->job->setLogAlert('error'); } } From de4a142678675c5a9a0b6799b3b7e09581906ac9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:09:14 +0200 Subject: [PATCH 040/644] implementing features --- core/LogUtils.php | 1 + libraries/dba/models/Job.class.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 87dbc6bf50..72794faad2 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -39,6 +39,7 @@ public function examineLogAndSetAlert() { foreach ($this->keyWordDict as $key => $value) { $this->keyWordDict[$key] = $this->countLogOccurances($key); } + // for now, these are fixed. potentially expand and allow any keyword if ($this->keyWordDict['WARNING:'] >= $this->thresholdWarning) { $this->job->setLogAlert('warning'); } diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index a79d67b465..c21a959a61 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -226,7 +226,7 @@ function getLogAlert() { return $this->logAlert; } function setLogAlert($alert) { - // TODO last call of this method overwrites previous value. logic in other class first checks if its warning and then if its error + // last call of this method overwrites previous value. For now logic in LogUtils.php first checks if its warning and then if its error $this->logAlert = $alert; } function getSizeWarning() { From 410ac6a253f54d6a8ab24e1fff67eeff4a0ac1f4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:10:27 +0200 Subject: [PATCH 041/644] implementing features --- views/evaluation/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 4b044292ab..2e27edc997 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -198,8 +198,8 @@ function submitData() { # Description - - + Keywords + Log Size Status From 5a85ccdf0142dfd389d7984eeb2e98ae6c4e40f3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:12:18 +0200 Subject: [PATCH 042/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 72794faad2..71d516639b 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -5,7 +5,7 @@ class LogUtils { private $log; private $logLength = -1; private $thresholdError = 1; - private $thresholdWarning = 13; + private $thresholdWarning = 5; private $thresholdLogSize = 150; private $keyWordDict = ['ERROR:' => 0, 'WARNING:' => 0]; From 4510625d47ab6ebf9b6f86f28bc44e7da74eab74 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:13:18 +0200 Subject: [PATCH 043/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 71d516639b..22f8cb813c 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -37,7 +37,7 @@ public function examineLogAndSetAlert() { // count occurances of all defined keywords. default keywords are 'error' and 'warning' // later, system admins can define more keywords, which will be added to the dict foreach ($this->keyWordDict as $key => $value) { - $this->keyWordDict[$key] = $this->countLogOccurances($key); + $this->keyWordDict[$value] = $this->countLogOccurances($key); } // for now, these are fixed. potentially expand and allow any keyword if ($this->keyWordDict['WARNING:'] >= $this->thresholdWarning) { From ca331befd8d9cccff5a487ac3dfb3b66a959ecd4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:18:39 +0200 Subject: [PATCH 044/644] implementing features --- core/LogUtils.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/LogUtils.php b/core/LogUtils.php index 22f8cb813c..b0a586c970 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -46,6 +46,7 @@ public function examineLogAndSetAlert() { else if ($this->keyWordDict['ERROR:'] >= $this->thresholdError) { $this->job->setLogAlert('error'); } + print_r($this->keyWordDict); } // Will be changed in the systems settings public function setThresholdLogSize($size) { From 19439df754f76be68559aa7758a045f656f7151f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:19:37 +0200 Subject: [PATCH 045/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index b0a586c970..19e14d10c8 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -37,7 +37,7 @@ public function examineLogAndSetAlert() { // count occurances of all defined keywords. default keywords are 'error' and 'warning' // later, system admins can define more keywords, which will be added to the dict foreach ($this->keyWordDict as $key => $value) { - $this->keyWordDict[$value] = $this->countLogOccurances($key); + $this->keyWordDict[$key] = $this->countLogOccurances($key); } // for now, these are fixed. potentially expand and allow any keyword if ($this->keyWordDict['WARNING:'] >= $this->thresholdWarning) { From b3e97e257f8e46ef65d73ad79caef0c00a9e4924 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:21:09 +0200 Subject: [PATCH 046/644] implementing features --- core/LogUtils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 19e14d10c8..e4e32050db 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -5,7 +5,7 @@ class LogUtils { private $log; private $logLength = -1; private $thresholdError = 1; - private $thresholdWarning = 5; + private $thresholdWarning = 10; private $thresholdLogSize = 150; private $keyWordDict = ['ERROR:' => 0, 'WARNING:' => 0]; @@ -41,12 +41,12 @@ public function examineLogAndSetAlert() { } // for now, these are fixed. potentially expand and allow any keyword if ($this->keyWordDict['WARNING:'] >= $this->thresholdWarning) { + echo "too many warnings" $this->job->setLogAlert('warning'); } else if ($this->keyWordDict['ERROR:'] >= $this->thresholdError) { $this->job->setLogAlert('error'); } - print_r($this->keyWordDict); } // Will be changed in the systems settings public function setThresholdLogSize($size) { From 8eff291d3719ba94d447cda4eefe27d99ea0e137 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:21:44 +0200 Subject: [PATCH 047/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index e4e32050db..7d3bcf293e 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -41,7 +41,7 @@ public function examineLogAndSetAlert() { } // for now, these are fixed. potentially expand and allow any keyword if ($this->keyWordDict['WARNING:'] >= $this->thresholdWarning) { - echo "too many warnings" + echo "too many warnings"; $this->job->setLogAlert('warning'); } else if ($this->keyWordDict['ERROR:'] >= $this->thresholdError) { From bd272950cdbef1a62c1c3248dccec98c0251e642 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:23:36 +0200 Subject: [PATCH 048/644] implementing features --- core/LogUtils.php | 1 - views/evaluation/detail.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 7d3bcf293e..2547f5335c 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -41,7 +41,6 @@ public function examineLogAndSetAlert() { } // for now, these are fixed. potentially expand and allow any keyword if ($this->keyWordDict['WARNING:'] >= $this->thresholdWarning) { - echo "too many warnings"; $this->job->setLogAlert('warning'); } else if ($this->keyWordDict['ERROR:'] >= $this->thresholdError) { diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 2e27edc997..ce91a73419 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -211,9 +211,9 @@ function submitData() { getDescription(); ?> getLogAlert() == "error") { ?> - + getLogAlert() == "warning") { ?> - + WARNING From b5482df04d344db0e74f81edebdf7273bff15b74 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:24:21 +0200 Subject: [PATCH 049/644] implementing features --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index ce91a73419..22ab185e08 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -213,7 +213,7 @@ function submitData() { getLogAlert() == "error") { ?> getLogAlert() == "warning") { ?> - WARNING + From 40aceaafc3f01f5f8aedb1969b3f14f1f3b0ba3a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:24:44 +0200 Subject: [PATCH 050/644] implementing features --- views/evaluation/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 22ab185e08..bf510ccaba 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -198,8 +198,8 @@ function submitData() { # Description - Keywords - Log Size + + Status From 5727c77bfb13f1b23140c4375b2d4fcf5a7e938b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:26:00 +0200 Subject: [PATCH 051/644] implementing features --- views/evaluation/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index bf510ccaba..db59f0e965 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -211,9 +211,9 @@ function submitData() { getDescription(); ?> getLogAlert() == "error") { ?> - + getLogAlert() == "warning") { ?> - + From 379c633a7246fa7e6b5c9cacc85a7583fc8a4160 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:26:26 +0200 Subject: [PATCH 052/644] implementing features --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index db59f0e965..d2dc7282e3 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -213,7 +213,7 @@ function submitData() { getLogAlert() == "error") { ?> getLogAlert() == "warning") { ?> - + From dc85250394002c68144002fd0beca9a219e34495 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:27:15 +0200 Subject: [PATCH 053/644] implementing features --- core/LogUtils.php | 2 +- views/evaluation/detail.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 2547f5335c..4f25028632 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -6,7 +6,7 @@ class LogUtils { private $logLength = -1; private $thresholdError = 1; private $thresholdWarning = 10; - private $thresholdLogSize = 150; + private $thresholdLogSize = 300; private $keyWordDict = ['ERROR:' => 0, 'WARNING:' => 0]; public function __construct($job) { diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index d2dc7282e3..c849287b06 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -218,7 +218,7 @@ function submitData() { getSizeWarning()) { ?> - + From 5c16c2604ec8c8e1ac629f1ec0196b4c76f7e6e5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:27:36 +0200 Subject: [PATCH 054/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 4f25028632..43d610208a 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -6,7 +6,7 @@ class LogUtils { private $logLength = -1; private $thresholdError = 1; private $thresholdWarning = 10; - private $thresholdLogSize = 300; + private $thresholdLogSize = 400; private $keyWordDict = ['ERROR:' => 0, 'WARNING:' => 0]; public function __construct($job) { From b56d9c7be7e95a3fa1f6bcaab3165e2fd9d04e2b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:27:47 +0200 Subject: [PATCH 055/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 43d610208a..ce401bc445 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -5,7 +5,7 @@ class LogUtils { private $log; private $logLength = -1; private $thresholdError = 1; - private $thresholdWarning = 10; + private $thresholdWarning = 12; private $thresholdLogSize = 400; private $keyWordDict = ['ERROR:' => 0, 'WARNING:' => 0]; From 01d66dd74bb8c107a9c99e8a424b76b353178fbf Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:28:11 +0200 Subject: [PATCH 056/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index ce401bc445..58769094cc 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -6,7 +6,7 @@ class LogUtils { private $logLength = -1; private $thresholdError = 1; private $thresholdWarning = 12; - private $thresholdLogSize = 400; + private $thresholdLogSize = 700; private $keyWordDict = ['ERROR:' => 0, 'WARNING:' => 0]; public function __construct($job) { From 963ae1491555a1daad30017e10623f10910a123c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:28:51 +0200 Subject: [PATCH 057/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 58769094cc..4894648825 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -25,12 +25,12 @@ public function __construct($job) { * @returns int $count */ public function countLogOccurances(string $keyword) { - return substr_count($this->log, $keyword); } public function examineLogAndSetAlert() { // Check if log is too long $this->logLength = strlen($this->log); + echo $this->logLength; if ($this->logLength > $this->thresholdLogSize) { $this->job->SetSizeWarning(true); } From 440d991f34e157f48431b6fec1266413af7ce7e9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:29:18 +0200 Subject: [PATCH 058/644] implementing features --- core/LogUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 4894648825..52e4f34e04 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -30,7 +30,7 @@ public function countLogOccurances(string $keyword) { public function examineLogAndSetAlert() { // Check if log is too long $this->logLength = strlen($this->log); - echo $this->logLength; + echo $this->logLength . "\n"; if ($this->logLength > $this->thresholdLogSize) { $this->job->SetSizeWarning(true); } From 569f5ad04560519653e60e5a59956f47d316acf9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 8 Jul 2024 21:29:51 +0200 Subject: [PATCH 059/644] implementing features --- core/LogUtils.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/LogUtils.php b/core/LogUtils.php index 52e4f34e04..7362f2078c 100644 --- a/core/LogUtils.php +++ b/core/LogUtils.php @@ -6,7 +6,7 @@ class LogUtils { private $logLength = -1; private $thresholdError = 1; private $thresholdWarning = 12; - private $thresholdLogSize = 700; + private $thresholdLogSize = 10000; private $keyWordDict = ['ERROR:' => 0, 'WARNING:' => 0]; public function __construct($job) { @@ -30,7 +30,6 @@ public function countLogOccurances(string $keyword) { public function examineLogAndSetAlert() { // Check if log is too long $this->logLength = strlen($this->log); - echo $this->logLength . "\n"; if ($this->logLength > $this->thresholdLogSize) { $this->job->SetSizeWarning(true); } From e5bb880e1cf7b3a58e7ae92686e6935bd07a8586 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 15:19:44 +0200 Subject: [PATCH 060/644] implementing features --- controllers/evaluation.php | 5 +- controllers/job.php | 6 +- core/LogUtils.php | 58 ---------------- libraries/dba/models/Job.class.php | 2 +- libraries/logalyzer.php | 106 +++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+), 63 deletions(-) delete mode 100644 core/LogUtils.php create mode 100644 libraries/logalyzer.php diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 19006ab8b4..a5c47521ad 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -32,7 +32,8 @@ use DBA\Job; use DBA\ProjectUser; use DBA\QueryFilter; -include '../core/LogUtils.php'; +//use libraries\logalyzer; + class Evaluation_Controller extends Controller { @@ -160,7 +161,7 @@ public function detail() { $isFinished = false; } else { $resultsAvailable = true; - $logUtil = new LogUtils($subJob); + $logUtil = new Logalyzer_Library($subJob); $logUtil->examineLogAndSetAlert(); } } diff --git a/controllers/job.php b/controllers/job.php index 06314caf61..d3e8b095d4 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -30,7 +30,9 @@ use DBA\Job; use DBA\ProjectUser; use DBA\QueryFilter; -include '../core/LogUtils.php'; +use libraries\logalyzer; + +include '../core/logalyzer.php'; class Job_Controller extends Controller { @@ -148,7 +150,7 @@ public function detail() { $this->view->assign('events', $events); // Calculate Log errors and warnings TODO naive approach, do so during runtime of a job to be able to react early - $logUtil = new LogUtils($job); + $logUtil = new logalyzer($job); $errors = $logUtil->countLogOccurances("ERROR:"); $warnings = $logUtil->countLogOccurances("WARNING:"); $this->view->assign('logErrors', $errors); diff --git a/core/LogUtils.php b/core/LogUtils.php deleted file mode 100644 index 7362f2078c..0000000000 --- a/core/LogUtils.php +++ /dev/null @@ -1,58 +0,0 @@ - 0, 'WARNING:' => 0]; - - public function __construct($job) { - $this->job = $job; - $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; - $log = Util::readFileContents($path); - if ($log === false) { - $this->log = ""; - } else { - $this->log = $log; - } - } - - /** - * @param string $keyword - * @returns int $count - */ - public function countLogOccurances(string $keyword) { - return substr_count($this->log, $keyword); - } - public function examineLogAndSetAlert() { - // Check if log is too long - $this->logLength = strlen($this->log); - if ($this->logLength > $this->thresholdLogSize) { - $this->job->SetSizeWarning(true); - } - // count occurances of all defined keywords. default keywords are 'error' and 'warning' - // later, system admins can define more keywords, which will be added to the dict - foreach ($this->keyWordDict as $key => $value) { - $this->keyWordDict[$key] = $this->countLogOccurances($key); - } - // for now, these are fixed. potentially expand and allow any keyword - if ($this->keyWordDict['WARNING:'] >= $this->thresholdWarning) { - $this->job->setLogAlert('warning'); - } - else if ($this->keyWordDict['ERROR:'] >= $this->thresholdError) { - $this->job->setLogAlert('error'); - } - } - // Will be changed in the systems settings - public function setThresholdLogSize($size) { - $this->thresholdLogSize = $size; - } - public function getThresholdLogSize($size) { - return $this->thresholdLogSize; - } -} - -?> \ No newline at end of file diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index c21a959a61..057f01cf63 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -226,7 +226,7 @@ function getLogAlert() { return $this->logAlert; } function setLogAlert($alert) { - // last call of this method overwrites previous value. For now logic in LogUtils.php first checks if its warning and then if its error + // last call of this method overwrites previous value. For now logic in logalyzer.php first checks if its warning and then if its error $this->logAlert = $alert; } function getSizeWarning() { diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php new file mode 100644 index 0000000000..f0ac55069d --- /dev/null +++ b/libraries/logalyzer.php @@ -0,0 +1,106 @@ + 0]; + private $errorKeys = ['ERROR:' => 0]; + + public function __construct($job) + { + $this->job = $job; + $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; + $log = Util::readFileContents($path); + if ($log === false) { + $this->log = ""; + } else { + $this->log = $log; + } + } + + /** + * @param string $keyword + * @return int + */ + public function countLogOccurances(string $keyword) { + return substr_count($this->log, $keyword); + } + + public function examineLogAndSetAlert() + { + // Check if log is too long + $this->logLength = strlen($this->log); + if ($this->logLength > $this->thresholdLogSize) { + $this->job->SetSizeWarning(true); + } + // count occurrences of all defined keywords. Default keywords are 'error' and 'warning' + foreach ($this->warningKeys as $key => $value) { + $this->warningKeys[$key] = $this->countLogOccurances($key); + } + foreach ($this->errorKeys as $key => $value) { + $this->errorKeys[$key] = $this->countLogOccurances($key); + } + + // Check if errors/warnings are more than the threshold + foreach ($this->warningKeys as $key => $value) { + if ($value >= $this->thresholdWarning) { + $this->job->setLogAlert('warning'); + } + } + foreach ($this->errorKeys as $key => $value) { + if ($value >= $this->thresholdError) { + $this->job->setLogAlert('error'); + } + } + } + + /** + * @param int $size + */ + // TODO Threshold not a static value but a percentage compared to the other job's logs + public function setThresholdLogSize($size) + { + $this->thresholdLogSize = $size; + } + + /** + * @param int $size + * @return int + */ + public function getThresholdLogSize($size) + { + return $this->thresholdLogSize; + } + + public function addKey(string $identifier, string $key) { + if ($identifier == 'warning') { + $this->warningKeys[$key] = 0; + } + else if ($identifier == 'error') { + $this->errorKeys[$key] = 0; + } + else { + echo "identifier not recognized."; + } + } + public function removeKey(string $identifier, string $key) { + if ($identifier == 'warning') { + unset($this->warningKeys[$key]); + } + else if ($identifier == 'error') { + unset($this->errorKeys[$key]); + } + else { + echo "identifier not recognized."; + } + } +} + +?> \ No newline at end of file From 2e053cad5a348cd267a46e544b91198c7e9cd632 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 15:33:41 +0200 Subject: [PATCH 061/644] implementing features --- libraries/logalyzer.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index f0ac55069d..a3a6fb2f56 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -12,6 +12,8 @@ class Logalyzer_Library { private $thresholdLogSize = 10000; private $warningKeys = ['WARNING:' => 0]; private $errorKeys = ['ERROR:' => 0]; + private $warningAlert = false; + private $errorAlert = false; public function __construct($job) { @@ -78,7 +80,10 @@ public function getThresholdLogSize($size) { return $this->thresholdLogSize; } - + /** + * @param string $identifier add $key as warning or error? + * @param string $key name of new keyword + */ public function addKey(string $identifier, string $key) { if ($identifier == 'warning') { $this->warningKeys[$key] = 0; @@ -90,6 +95,10 @@ public function addKey(string $identifier, string $key) { echo "identifier not recognized."; } } + /** + * @param string $identifier remove $key as warning or error? + * @param string $key name of keyword to be deleted + */ public function removeKey(string $identifier, string $key) { if ($identifier == 'warning') { unset($this->warningKeys[$key]); From 1f74e8e0be9a11fcfa5a03404697b9fe5aca4add Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 15:52:15 +0200 Subject: [PATCH 062/644] implementing features --- libraries/dba/models/Job.class.php | 1 + libraries/logalyzer.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 057f01cf63..75c786ad26 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -45,6 +45,7 @@ class Job extends AbstractModel { private $configurationIdentifier; private $logAlert; private $logSizeWarning = false; + private $logHash; function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier) { $this->jobId = $jobId; diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index a3a6fb2f56..4e35ea0561 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -15,6 +15,7 @@ class Logalyzer_Library { private $warningAlert = false; private $errorAlert = false; + public function __construct($job) { $this->job = $job; @@ -35,8 +36,14 @@ public function countLogOccurances(string $keyword) { return substr_count($this->log, $keyword); } - public function examineLogAndSetAlert() - { + public function examineLogAndSetAlert() { + // Check if there have been changes to the log + if ($this->job->logHash == hash('sha256', $this->log)) { + // no changes since last function call + echo "same hash\n"; + return; + } + $this->job->hash = hash('sha256', $this->log); // Check if log is too long $this->logLength = strlen($this->log); if ($this->logLength > $this->thresholdLogSize) { From 2d8b7d4c0f15cbb817045279b206fb14c03d7184 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 15:54:33 +0200 Subject: [PATCH 063/644] implementing features --- libraries/dba/models/Job.class.php | 7 +++++++ libraries/logalyzer.php | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 75c786ad26..dffb9a55e0 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -236,6 +236,13 @@ function getSizeWarning() { function setSizeWarning($bool) { $this->logSizeWarning = $bool; } + + function setLogHash($value) { + $this->logHash = $value; + } + function getLogHash() { + return $this->logHash; + } const JOB_ID = "jobId"; const USER_ID = "userId"; const DESCRIPTION = "description"; diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4e35ea0561..576452e342 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -38,12 +38,12 @@ public function countLogOccurances(string $keyword) { public function examineLogAndSetAlert() { // Check if there have been changes to the log - if ($this->job->logHash == hash('sha256', $this->log)) { + if ($this->job->getLogHash() == hash('sha256', $this->log)) { // no changes since last function call echo "same hash\n"; return; } - $this->job->hash = hash('sha256', $this->log); + $this->job->setLogHash = hash('sha256', $this->log); // Check if log is too long $this->logLength = strlen($this->log); if ($this->logLength > $this->thresholdLogSize) { From fb5725119ecb68c2ce32d61df343e1e861a02f8d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 15:56:56 +0200 Subject: [PATCH 064/644] implementing features --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 576452e342..4de4a7f0a9 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -43,7 +43,7 @@ public function examineLogAndSetAlert() { echo "same hash\n"; return; } - $this->job->setLogHash = hash('sha256', $this->log); + $this->job->setLogHash(hash('sha256', $this->log)); // Check if log is too long $this->logLength = strlen($this->log); if ($this->logLength > $this->thresholdLogSize) { From cc1fa2e52af1b2509a692d3087e4cc802ca5c02e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 15:57:40 +0200 Subject: [PATCH 065/644] implementing features --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4de4a7f0a9..5e8db56895 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -43,6 +43,7 @@ public function examineLogAndSetAlert() { echo "same hash\n"; return; } + echo "new hash\n"; $this->job->setLogHash(hash('sha256', $this->log)); // Check if log is too long $this->logLength = strlen($this->log); From 5c4f0e3b1c599a08945383799ae0974698495b89 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 17:55:24 +0200 Subject: [PATCH 066/644] implementing features --- libraries/dba/models/Job.class.php | 8 ---- libraries/logalyzer.php | 70 ++++++++++++++++++------------ 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index dffb9a55e0..057f01cf63 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -45,7 +45,6 @@ class Job extends AbstractModel { private $configurationIdentifier; private $logAlert; private $logSizeWarning = false; - private $logHash; function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier) { $this->jobId = $jobId; @@ -236,13 +235,6 @@ function getSizeWarning() { function setSizeWarning($bool) { $this->logSizeWarning = $bool; } - - function setLogHash($value) { - $this->logHash = $value; - } - function getLogHash() { - return $this->logHash; - } const JOB_ID = "jobId"; const USER_ID = "userId"; const DESCRIPTION = "description"; diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 5e8db56895..7ff657ca60 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -14,12 +14,24 @@ class Logalyzer_Library { private $errorKeys = ['ERROR:' => 0]; private $warningAlert = false; private $errorAlert = false; - + private $changes = false; + private $hashPath; public function __construct($job) { $this->job = $job; $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; + + $this->hashPath = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.hash'; + $hashFile = fopen($this->hashPath, 'w'); + if (fgets($hashFile) == hash_file('sha256', $path)) { + $this->changes = false; + } + else { + $this->changes = true; + } + fclose($hashFile); + $log = Util::readFileContents($path); if ($log === false) { $this->log = ""; @@ -38,37 +50,36 @@ public function countLogOccurances(string $keyword) { public function examineLogAndSetAlert() { // Check if there have been changes to the log - if ($this->job->getLogHash() == hash('sha256', $this->log)) { - // no changes since last function call - echo "same hash\n"; - return; - } - echo "new hash\n"; - $this->job->setLogHash(hash('sha256', $this->log)); - // Check if log is too long - $this->logLength = strlen($this->log); - if ($this->logLength > $this->thresholdLogSize) { - $this->job->SetSizeWarning(true); - } - // count occurrences of all defined keywords. Default keywords are 'error' and 'warning' - foreach ($this->warningKeys as $key => $value) { - $this->warningKeys[$key] = $this->countLogOccurances($key); - } - foreach ($this->errorKeys as $key => $value) { - $this->errorKeys[$key] = $this->countLogOccurances($key); - } + if ($this->changes) { + $this->setHash(); + // Check if log is too long + $this->logLength = strlen($this->log); + if ($this->logLength > $this->thresholdLogSize) { + $this->job->SetSizeWarning(true); + } + // count occurrences of all defined keywords. Default keywords are 'error' and 'warning' + foreach ($this->warningKeys as $key => $value) { + $this->warningKeys[$key] = $this->countLogOccurances($key); + } + foreach ($this->errorKeys as $key => $value) { + $this->errorKeys[$key] = $this->countLogOccurances($key); + } - // Check if errors/warnings are more than the threshold - foreach ($this->warningKeys as $key => $value) { - if ($value >= $this->thresholdWarning) { - $this->job->setLogAlert('warning'); + // Check if errors/warnings are more than the threshold + foreach ($this->warningKeys as $key => $value) { + if ($value >= $this->thresholdWarning) { + $this->job->setLogAlert('warning'); + } } - } - foreach ($this->errorKeys as $key => $value) { - if ($value >= $this->thresholdError) { - $this->job->setLogAlert('error'); + foreach ($this->errorKeys as $key => $value) { + if ($value >= $this->thresholdError) { + $this->job->setLogAlert('error'); + } } } + else { + echo "same hash"; //debug + } } /** @@ -118,6 +129,9 @@ public function removeKey(string $identifier, string $key) { echo "identifier not recognized."; } } + function setHash() { + file_put_contents($this->hashPath, hash('sha256', $this->log)); + } } ?> \ No newline at end of file From 710fc7c18d931b4ffb71d53e9c3b3c73bd4e552a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 17:57:18 +0200 Subject: [PATCH 067/644] implementing features --- libraries/logalyzer.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 7ff657ca60..7c4c82ce66 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -17,18 +17,19 @@ class Logalyzer_Library { private $changes = false; private $hashPath; - public function __construct($job) - { + public function __construct($job) { $this->job = $job; $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; $this->hashPath = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.hash'; $hashFile = fopen($this->hashPath, 'w'); - if (fgets($hashFile) == hash_file('sha256', $path)) { - $this->changes = false; - } - else { - $this->changes = true; + if (!feof($hashFile)) { + if (fgets($hashFile) == hash_file('sha256', $path)) { + $this->changes = false; + } + else { + $this->changes = true; + } } fclose($hashFile); From 458ec9f971a11f49ca5b6d98b010004bdf078c00 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 17:57:56 +0200 Subject: [PATCH 068/644] implementing features --- libraries/logalyzer.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 7c4c82ce66..29e0934576 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -27,10 +27,11 @@ public function __construct($job) { if (fgets($hashFile) == hash_file('sha256', $path)) { $this->changes = false; } - else { - $this->changes = true; - } } + else { + $this->changes = true; + } + fclose($hashFile); $log = Util::readFileContents($path); From 70efdb8eb3ac19126c03857cb4d833b1420ebfd0 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:03:15 +0200 Subject: [PATCH 069/644] implementing features --- libraries/logalyzer.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 29e0934576..60c86d3c56 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -23,10 +23,9 @@ public function __construct($job) { $this->hashPath = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.hash'; $hashFile = fopen($this->hashPath, 'w'); - if (!feof($hashFile)) { - if (fgets($hashFile) == hash_file('sha256', $path)) { - $this->changes = false; - } + $line = fgets($hashFile); + if ($line == hash_file('sha256', $path)) { + $this->changes = false; } else { $this->changes = true; From 89e3f89c13dc22eade6af8c10926056de9758b8f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:03:26 +0200 Subject: [PATCH 070/644] implementing features --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 60c86d3c56..9c7e4e711a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -24,6 +24,7 @@ public function __construct($job) { $this->hashPath = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.hash'; $hashFile = fopen($this->hashPath, 'w'); $line = fgets($hashFile); + echo $line; if ($line == hash_file('sha256', $path)) { $this->changes = false; } From 9b22589484d0abede94b261f0bc496b2662cb7f3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:06:50 +0200 Subject: [PATCH 071/644] implementing features --- libraries/logalyzer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 9c7e4e711a..fcd47a8272 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -23,6 +23,9 @@ public function __construct($job) { $this->hashPath = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.hash'; $hashFile = fopen($this->hashPath, 'w'); + if(!$hashFile) { + echo "failed to open file" . $hashFile; + } $line = fgets($hashFile); echo $line; if ($line == hash_file('sha256', $path)) { From fb1e7389f79a5cd2aff1c4204f80c468925063e2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:09:19 +0200 Subject: [PATCH 072/644] implementing features --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index fcd47a8272..93b2c9a67a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -26,7 +26,7 @@ public function __construct($job) { if(!$hashFile) { echo "failed to open file" . $hashFile; } - $line = fgets($hashFile); + $line = fgets($hashFile, 200); echo $line; if ($line == hash_file('sha256', $path)) { $this->changes = false; From a3c60f982d7e48f964537e15b29d6463a7ee9b24 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:10:11 +0200 Subject: [PATCH 073/644] implementing features --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 93b2c9a67a..14dd3ad3e8 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -23,6 +23,7 @@ public function __construct($job) { $this->hashPath = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.hash'; $hashFile = fopen($this->hashPath, 'w'); + echo $this->hashPath; if(!$hashFile) { echo "failed to open file" . $hashFile; } From 627d58b0e0c03c55bdbd9c382cbeaa9dedf27fd6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:10:50 +0200 Subject: [PATCH 074/644] implementing features --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 14dd3ad3e8..d8a145207e 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -21,7 +21,7 @@ public function __construct($job) { $this->job = $job; $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; - $this->hashPath = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.hash'; + $this->hashPath = UPLOADED_DATA_PATH . 'log/' . $job->getId() . '.hash'; $hashFile = fopen($this->hashPath, 'w'); echo $this->hashPath; if(!$hashFile) { From c5f4e093b479436dc2ad603eb43d49d3397710bf Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:12:37 +0200 Subject: [PATCH 075/644] implementing features --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index d8a145207e..fb243d6153 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -27,7 +27,7 @@ public function __construct($job) { if(!$hashFile) { echo "failed to open file" . $hashFile; } - $line = fgets($hashFile, 200); + $line = file_get_contents($hashFile); echo $line; if ($line == hash_file('sha256', $path)) { $this->changes = false; From 403f4fd5c5490b164fb952ab0a3196f318bdc3a1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:19:32 +0200 Subject: [PATCH 076/644] implementing features --- libraries/logalyzer.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index fb243d6153..227f531c9c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -20,24 +20,24 @@ class Logalyzer_Library { public function __construct($job) { $this->job = $job; $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; - $this->hashPath = UPLOADED_DATA_PATH . 'log/' . $job->getId() . '.hash'; - $hashFile = fopen($this->hashPath, 'w'); - echo $this->hashPath; - if(!$hashFile) { - echo "failed to open file" . $hashFile; - } - $line = file_get_contents($hashFile); - echo $line; - if ($line == hash_file('sha256', $path)) { - $this->changes = false; + + if (!$line = file_get_contents($this->hashPath)) { + $hashFile = fopen($this->hashPath, 'c'); + fwrite($hashFile, hash("sha256", $this->log)); + fclose($hashFile); + $this->changes = true; } else { - $this->changes = true; + echo $line; + if ($line == hash_file('sha256', $path)) { + $this->changes = false; + } + else { + $this->changes = true; + } } - fclose($hashFile); - $log = Util::readFileContents($path); if ($log === false) { $this->log = ""; From 203c565d3621a55faab67e4187b7eee9381fae1d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:21:21 +0200 Subject: [PATCH 077/644] implementing features --- libraries/logalyzer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 227f531c9c..eb7eb95822 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -23,9 +23,7 @@ public function __construct($job) { $this->hashPath = UPLOADED_DATA_PATH . 'log/' . $job->getId() . '.hash'; if (!$line = file_get_contents($this->hashPath)) { - $hashFile = fopen($this->hashPath, 'c'); - fwrite($hashFile, hash("sha256", $this->log)); - fclose($hashFile); + file_put_contents($this->hashPath, hash("sha256", $this->log)); $this->changes = true; } else { From 6439a6c5e7ff409b9b145ead4841b995464b3707 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:23:09 +0200 Subject: [PATCH 078/644] implementing features --- libraries/logalyzer.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index eb7eb95822..dd84237d90 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -20,6 +20,15 @@ class Logalyzer_Library { public function __construct($job) { $this->job = $job; $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; + $log = Util::readFileContents($path); + if ($log === false) { + $this->log = ""; + } else { + $this->log = $log; + } + + + $this->hashPath = UPLOADED_DATA_PATH . 'log/' . $job->getId() . '.hash'; if (!$line = file_get_contents($this->hashPath)) { @@ -27,7 +36,6 @@ public function __construct($job) { $this->changes = true; } else { - echo $line; if ($line == hash_file('sha256', $path)) { $this->changes = false; } @@ -35,13 +43,6 @@ public function __construct($job) { $this->changes = true; } } - - $log = Util::readFileContents($path); - if ($log === false) { - $this->log = ""; - } else { - $this->log = $log; - } } /** From d43f178840df96e57bbd3542cd261f53d582611d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:28:54 +0200 Subject: [PATCH 079/644] implementing features --- libraries/logalyzer.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index dd84237d90..89a5dc0496 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -27,10 +27,7 @@ public function __construct($job) { $this->log = $log; } - - $this->hashPath = UPLOADED_DATA_PATH . 'log/' . $job->getId() . '.hash'; - if (!$line = file_get_contents($this->hashPath)) { file_put_contents($this->hashPath, hash("sha256", $this->log)); $this->changes = true; @@ -56,13 +53,14 @@ public function countLogOccurances(string $keyword) { public function examineLogAndSetAlert() { // Check if there have been changes to the log if ($this->changes) { + // Log changed, set new hash $this->setHash(); // Check if log is too long $this->logLength = strlen($this->log); if ($this->logLength > $this->thresholdLogSize) { $this->job->SetSizeWarning(true); } - // count occurrences of all defined keywords. Default keywords are 'error' and 'warning' + // Count occurrences of all defined keywords. Default keywords are 'error' and 'warning' foreach ($this->warningKeys as $key => $value) { $this->warningKeys[$key] = $this->countLogOccurances($key); } @@ -83,7 +81,7 @@ public function examineLogAndSetAlert() { } } else { - echo "same hash"; //debug + echo "same hash: " . $this->getHash() . " and " . hash('sha256', $this->log); //debug } } @@ -137,6 +135,9 @@ public function removeKey(string $identifier, string $key) { function setHash() { file_put_contents($this->hashPath, hash('sha256', $this->log)); } + function getHash() { + return file_get_contents($this->hashPath); + } } ?> \ No newline at end of file From 998bcb43fff99f354201018938001ac97b5508b7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 9 Jul 2024 18:30:00 +0200 Subject: [PATCH 080/644] implementing features --- libraries/logalyzer.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 89a5dc0496..b614bcf6eb 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -80,9 +80,6 @@ public function examineLogAndSetAlert() { } } } - else { - echo "same hash: " . $this->getHash() . " and " . hash('sha256', $this->log); //debug - } } /** From 6ac26e1534c8c276bae2d69ce3bbb2878b3c12d7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 13 Jul 2024 22:13:57 +0200 Subject: [PATCH 081/644] implementing features --- chronos.sql | 8 ++++++-- libraries/dba/models/generator.php | 8 ++++++-- libraries/logalyzer.php | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/chronos.sql b/chronos.sql index 9f38cc92f5..fcd56e80db 100644 --- a/chronos.sql +++ b/chronos.sql @@ -70,7 +70,10 @@ CREATE TABLE `Job` ( `finished` datetime DEFAULT NULL, `evaluationId` int(11) NOT NULL, `internalId` int(11) NOT NULL, - `configurationIdentifier` varchar(256) COLLATE utf8_unicode_ci NOT NULL + `configurationIdentifier` varchar(256) COLLATE utf8_unicode_ci NOT NULL, + `logalyzerWarnings` smallint, + `logalyzerErrors` smallint, + `logalyzerHash` VARCHAR(64) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -130,7 +133,8 @@ CREATE TABLE `System` ( `vcsPassword` varchar(256) COLLATE utf8_unicode_ci NOT NULL, `created` datetime NOT NULL, `lastEdit` datetime NOT NULL, - `isArchived` int(11) NOT NULL + `isArchived` int(11) NOT NULL, + `logalyzerKeywords` json ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/libraries/dba/models/generator.php b/libraries/dba/models/generator.php index c55b9a9845..62deeac8c2 100644 --- a/libraries/dba/models/generator.php +++ b/libraries/dba/models/generator.php @@ -41,7 +41,8 @@ 'vcsPassword', 'created', 'lastEdit', - 'isArchived' + 'isArchived', + `logalyzerKeywords` ]; $CONF['Project'] = [ 'projectId', @@ -94,7 +95,10 @@ 'finished', 'evaluationId', 'internalId', - 'configurationIdentifier' + 'configurationIdentifier', + `logalyzerWarnings`, + `logalyzerErrors`, + `logalyzerHash` ]; $CONF['Result'] = [ 'resultId', diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b614bcf6eb..72aacdbe0e 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -1,7 +1,7 @@ Date: Sat, 13 Jul 2024 22:17:13 +0200 Subject: [PATCH 082/644] cleaned up include and use statements --- controllers/evaluation.php | 1 - controllers/job.php | 3 --- 2 files changed, 4 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index a5c47521ad..8a220be90d 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -32,7 +32,6 @@ use DBA\Job; use DBA\ProjectUser; use DBA\QueryFilter; -//use libraries\logalyzer; class Evaluation_Controller extends Controller { diff --git a/controllers/job.php b/controllers/job.php index d3e8b095d4..424ed96988 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -30,9 +30,6 @@ use DBA\Job; use DBA\ProjectUser; use DBA\QueryFilter; -use libraries\logalyzer; - -include '../core/logalyzer.php'; class Job_Controller extends Controller { From 4d67ba64bb60e44accf2c47433e4c5c1e47f7fc9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 13 Jul 2024 22:19:15 +0200 Subject: [PATCH 083/644] cleaned up include and use statements --- controllers/evaluation.php | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 8a220be90d..5dbf611456 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -33,7 +33,6 @@ use DBA\ProjectUser; use DBA\QueryFilter; - class Evaluation_Controller extends Controller { public $overview_access = Auth_Library::A_LOGGEDIN; From d433f4024bedcf788559430f623d3d3e8cf9ad5b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 13 Jul 2024 22:19:55 +0200 Subject: [PATCH 084/644] fixed values in generator.php to be strings --- libraries/dba/models/generator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/dba/models/generator.php b/libraries/dba/models/generator.php index 62deeac8c2..051a3539ef 100644 --- a/libraries/dba/models/generator.php +++ b/libraries/dba/models/generator.php @@ -42,7 +42,7 @@ 'created', 'lastEdit', 'isArchived', - `logalyzerKeywords` + 'logalyzerKeywords' ]; $CONF['Project'] = [ 'projectId', @@ -96,9 +96,9 @@ 'evaluationId', 'internalId', 'configurationIdentifier', - `logalyzerWarnings`, - `logalyzerErrors`, - `logalyzerHash` + 'logalyzerWarnings', + 'logalyzerErrors', + 'logalyzerHash' ]; $CONF['Result'] = [ 'resultId', From 64f40845aaff8019b08a82a1dfdbbcdcabf049eb Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 13 Jul 2024 22:37:33 +0200 Subject: [PATCH 085/644] fixed values in generator.php to be strings --- libraries/dba/models/generator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/dba/models/generator.php b/libraries/dba/models/generator.php index 051a3539ef..1ea985572e 100644 --- a/libraries/dba/models/generator.php +++ b/libraries/dba/models/generator.php @@ -205,7 +205,10 @@ 'evaluationId', 'internalId', 'configurationIdentifier', - 'projectUserId' + 'projectUserId', + 'logalyzerWarnings', + 'logalyzerErrors', + 'logalyzerHash' ]; foreach ($CONF as $NAME => $COLUMNS) { From adab7749c38b290c52dbe49a6fe5fd9441eba285 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 13 Jul 2024 22:39:46 +0200 Subject: [PATCH 086/644] Added indexes for new columns --- chronos.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chronos.sql b/chronos.sql index fcd56e80db..79cc79ceaf 100644 --- a/chronos.sql +++ b/chronos.sql @@ -219,6 +219,10 @@ CREATE INDEX job_idx_2 ON `Job`(systemId); CREATE INDEX job_idx_3 ON `Job`(status); CREATE INDEX job_idx_4 ON `Job`(evaluationId); CREATE INDEX job_idx_5 ON `Job`(internalId); +CREATE INDEX job_idx_6 ON `Job`(logalyzerHash); +CREATE INDEX job_idx_7 ON `Job`(logalyzerWarnings); +CREATE INDEX job_idx_8 ON `Job`(logalyzerErrors); + CREATE INDEX project_idx_1 ON `Project`(userId); CREATE INDEX project_idx_2 ON `Project`(systemId); From 2f0958da047e4e63ce859e42ee41f4b30f520d84 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 13 Jul 2024 22:41:45 +0200 Subject: [PATCH 087/644] Added indexes for new columns --- chronos.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/chronos.sql b/chronos.sql index 79cc79ceaf..f0a325c62c 100644 --- a/chronos.sql +++ b/chronos.sql @@ -220,9 +220,6 @@ CREATE INDEX job_idx_3 ON `Job`(status); CREATE INDEX job_idx_4 ON `Job`(evaluationId); CREATE INDEX job_idx_5 ON `Job`(internalId); CREATE INDEX job_idx_6 ON `Job`(logalyzerHash); -CREATE INDEX job_idx_7 ON `Job`(logalyzerWarnings); -CREATE INDEX job_idx_8 ON `Job`(logalyzerErrors); - CREATE INDEX project_idx_1 ON `Project`(userId); CREATE INDEX project_idx_2 ON `Project`(systemId); From 37b4d8baa5ced61ad5e29bd1c49bc590dd9029ad Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 13:36:37 +0200 Subject: [PATCH 088/644] Logalyzer System frontend --- views/admin/system.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/views/admin/system.php b/views/admin/system.php index 76ff2de939..c8cea3fe9a 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -454,6 +454,24 @@
+ +
+
+
+

Log Keywords

+
+
+

Error

+
+
+

Warning

+
+ +
+
From 069c9731881a54fbb42763be57e104cad678792b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 13:46:06 +0200 Subject: [PATCH 089/644] Logalyzer System frontend --- views/admin/system.php | 50 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index c8cea3fe9a..173670b25b 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -461,10 +461,56 @@

Log Keywords

-

Error

+ + +
+
+ + + + + + Delete + + +
+
+ +
+
+
+ + + +
+
+
-

Warning

+ + +
+
+ + + + + + Delete + + +
+
+ +
+
+
+ + + +
+
+
+
+
+
+ + + +
+
+
@@ -476,17 +485,17 @@
+
+
- - - + + +
-
-
@@ -502,15 +511,6 @@
-
-
-
- - - -
-
-
+ +
@@ -512,10 +516,6 @@
-
From 1caa98fc590b6d5cc6c7a288f015bd812b7ff00c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:15:34 +0200 Subject: [PATCH 093/644] Logalyzer System frontend --- views/admin/system.php | 114 ++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 54 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 80bbc12c3f..294477e9e8 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -456,67 +456,73 @@
-
-
-

Log Keywords

-
-
- -
-
- - - -
- - -
- - - +
+

Log Keywords

+
+
+
+
-
- - - - - - Delete - - +
+
Errors
+ + +
- -
-
- -
-
- - - -
- - + + +
+ + + +
+
+ + + + + + Delete + +
- - - +
+ +
+
+
+
+
+
-
- - - - - - Delete - - +
+
Warnings
+ + +
- -
- + + +
+ + + +
+
+ + + + + + Delete + + +
+
+ +
From 603d69d749f9542d10936527b4a7ed7ea1f838e2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:17:04 +0200 Subject: [PATCH 094/644] Logalyzer System frontend --- views/admin/system.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 294477e9e8..277ad88039 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -490,15 +490,13 @@
-
-
+
+
Warnings
+
-
-
Warnings
-
From 7dfb0a1c35126973632c3f174ee3bb223a9b4704 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:17:58 +0200 Subject: [PATCH 095/644] Logalyzer System frontend --- views/admin/system.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 277ad88039..59e0dc7760 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -461,11 +461,11 @@
+
+
Errors
+
-
-
Errors
-
From 62cefedeb1834131a5d6e06997ea49240b35282f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:19:50 +0200 Subject: [PATCH 096/644] Logalyzer System frontend --- views/admin/system.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 59e0dc7760..2d4e5c78cd 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -461,9 +461,7 @@
-
-
Errors
-
+
Errors
@@ -490,9 +488,7 @@
-
-
Warnings
-
+
Warnings
From c1fbfd2c2f4dbb7a35910a51e57f6436fb938d15 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:22:11 +0200 Subject: [PATCH 097/644] Logalyzer System frontend --- views/admin/system.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 2d4e5c78cd..7ddd695ec8 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -455,9 +455,9 @@
-
+
-

Log Keywords

+

Log Analysis

@@ -488,10 +488,9 @@
-
Warnings
-
- -
+ +
Warnings
+
@@ -516,7 +515,7 @@
-
+
From 7ba05acc83788ac7161bbe64babb978f59e2b146 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:22:59 +0200 Subject: [PATCH 098/644] Logalyzer System frontend --- views/admin/system.php | 1 - 1 file changed, 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 7ddd695ec8..f584356d0d 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -487,7 +487,6 @@
-
Warnings
From c5e036cadce293c195eeca301e9d18b6fa65c52e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:23:25 +0200 Subject: [PATCH 099/644] Logalyzer System frontend --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index f584356d0d..03e4dbddc1 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -461,7 +461,7 @@
-
Errors
+

Errors

@@ -488,7 +488,7 @@
-
Warnings
+

Warnings

From e4a6d6c5f80a360b1164e22f3c64cbb0a0836028 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:27:25 +0200 Subject: [PATCH 100/644] Logalyzer System frontend --- views/admin/system.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 03e4dbddc1..19b5faf80f 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -473,13 +473,13 @@
- +
- + - + Delete @@ -500,13 +500,13 @@
- +
- + - + Delete From 93fb5d395641d860331d297c8c49911bd7ca637e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:28:01 +0200 Subject: [PATCH 101/644] Logalyzer System frontend --- controllers/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin.php b/controllers/admin.php index 824b8cf72f..2b5e3ce03f 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -500,6 +500,7 @@ public function system() { // TODO implement back end and assign error and warning key arrays to view $this->view->assign('errorKeys', ['error', 'failed']); + $this->view->assign('warningKeys', ['warning', 'warn']); } else { throw new Exception("No id provided!"); } From dd5d35790d5255dae287282afc942ab789fedaca Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:32:40 +0200 Subject: [PATCH 102/644] Logalyzer System frontend --- views/admin/system.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 19b5faf80f..ccfde6591b 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -455,7 +455,7 @@
-
+

Log Analysis

@@ -487,15 +487,16 @@
- -

Warnings

-
+
+
+ +

Warnings

+
-
@@ -503,7 +504,6 @@ - +
From b64af7ea23eb1d83ba3476fbdc12e95e478a3a7e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:37:26 +0200 Subject: [PATCH 103/644] Logalyzer System frontend --- views/admin/system.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index ccfde6591b..f0461c1f1a 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -462,15 +462,13 @@

Errors

-
-
- - - -
- - +
+ + +
+ + From 54545b30e538fa88094425b2990ff7399580d503 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:38:53 +0200 Subject: [PATCH 104/644] Logalyzer System frontend --- views/admin/system.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index f0461c1f1a..1cc57f1a67 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -474,10 +474,10 @@
- + - + Delete @@ -504,7 +504,7 @@
- + Delete From 50dbb634332ec18b2f6c01cf081e42ec31b7d768 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:40:29 +0200 Subject: [PATCH 105/644] Logalyzer System frontend --- views/admin/system.php | 45 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 1cc57f1a67..8b8b607d4a 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -460,16 +460,18 @@

Log Analysis

-
-

Errors

-
- - - -
- - -
+
+
+

Errors

+
+ + + +
+ + +
+
@@ -487,21 +489,24 @@
-
-

Warnings

-
-
- - - +
+ +

Warnings

+
+
+ + + +
+
- -
- + +
+ From 008e78de002e4160969e2f13a1544858e3bd6e76 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:41:49 +0200 Subject: [PATCH 106/644] Logalyzer System frontend --- views/admin/system.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 8b8b607d4a..4f4051fb77 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -492,14 +492,12 @@

Warnings

-
-
From 33f4c302ca08036524649bc2851b28be92953c23 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 18:42:22 +0200 Subject: [PATCH 107/644] Logalyzer System frontend --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 4f4051fb77..33ffe5f20b 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -464,7 +464,7 @@

Errors

- +
@@ -493,7 +493,7 @@

Warnings

- +
From 75b195b8b3b1c4654941f007e32f2a49931fb281 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:26:35 +0200 Subject: [PATCH 108/644] Logalyzer System frontend --- controllers/admin.php | 2 +- views/admin/system.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 2b5e3ce03f..f8379f75f1 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -500,7 +500,7 @@ public function system() { // TODO implement back end and assign error and warning key arrays to view $this->view->assign('errorKeys', ['error', 'failed']); - $this->view->assign('warningKeys', ['warning', 'warn']); + $this->view->assign('warningKeys', ['warning', '!warn']); } else { throw new Exception("No id provided!"); } diff --git a/views/admin/system.php b/views/admin/system.php index 33ffe5f20b..d0609c5c10 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -458,6 +458,8 @@

Log Analysis

+ +
From 5dd24f2e9a9b8b9f471d022a65a17929f3743338 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:27:33 +0200 Subject: [PATCH 109/644] Logalyzer System frontend --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index d0609c5c10..1d34f46e92 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -459,7 +459,7 @@

Log Analysis

-
From a177aa7a47f7d66752c7d24f7588ab44bdd46f54 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:28:16 +0200 Subject: [PATCH 110/644] Logalyzer System frontend --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 1d34f46e92..ec4e82e765 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -457,7 +457,7 @@
-

Log Analysis

+

Log Analysis

From 79000b0e336230712b43222b4fa88e5b7d6e69ef Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:28:50 +0200 Subject: [PATCH 111/644] Logalyzer System frontend --- views/admin/system.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/admin/system.php b/views/admin/system.php index ec4e82e765..2e3b95cfde 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -490,6 +490,7 @@

+
From b675fca935cb54a29f6f7a1fc9f323da623df080 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:30:02 +0200 Subject: [PATCH 112/644] Logalyzer System frontend --- views/admin/system.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/views/admin/system.php b/views/admin/system.php index 2e3b95cfde..3bad295bee 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -465,6 +465,7 @@

Errors

+
@@ -472,6 +473,7 @@
+
@@ -495,12 +497,14 @@

Warnings

+
+
From dbd675f91f61918a47c50480b79c72ff83ed22e8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:33:45 +0200 Subject: [PATCH 113/644] Logalyzer System frontend --- views/admin/system.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 3bad295bee..7bc3904a34 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -459,7 +459,8 @@

Log Analysis

-

Enter a regex expression by starting with a slash /

+

For example /[error|fail|crash] or !success

From bc57734bceae7473389d71604afb44f4d03dd3d3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:34:23 +0200 Subject: [PATCH 114/644] Logalyzer System frontend --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 7bc3904a34..d88ed6e2ec 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -458,7 +458,7 @@

Log Analysis

- +

Enter a regex expression by starting with a slash /

For example /[error|fail|crash] or !success

From 73c7d1b91b69e5fc73beef7ad95063a9439f8d8f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:34:51 +0200 Subject: [PATCH 115/644] Logalyzer System frontend --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index d88ed6e2ec..7849a31ea5 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -458,7 +458,7 @@

Log Analysis

-
+

Enter a regex expression by starting with a slash /

For example /[error|fail|crash] or !success

From 085fc6075a98de3e2661c5e21eabd906e3dd64f2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:35:54 +0200 Subject: [PATCH 116/644] Logalyzer System frontend --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 7849a31ea5..848ffd0bff 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -459,8 +459,8 @@

Log Analysis

-

Enter a regex expression by starting with a slash /

-

For example /[error|fail|crash] or !success

+

Enter a regex expression by starting with /

+

For example /[error|fail|crash] or /[^success] no 'success' in log > something failed

From 5f5cf37f0356321508cc2988a3134edc4737c7c5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:38:43 +0200 Subject: [PATCH 117/644] Logalyzer System frontend --- views/admin/system.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 848ffd0bff..b02627527b 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -459,8 +459,7 @@

Log Analysis

-

Enter a regex expression by starting with /

-

For example /[error|fail|crash] or /[^success] no 'success' in log > something failed

+

Regex Expression?

From ed42192454224f552ab4882fa22be05ca185e80d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:40:05 +0200 Subject: [PATCH 118/644] Logalyzer System frontend --- views/admin/system.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index b02627527b..d71f7fe314 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -459,7 +459,8 @@

Log Analysis

-

Regex Expression?

+

Regex Expression

+

Enter a regex expression by starting with /. For example /[error|fail|crash] or /[^success]

From 5df586d726236f8b4c686862c9c7cd950d564e8d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:40:47 +0200 Subject: [PATCH 119/644] Logalyzer System frontend --- views/admin/system.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index d71f7fe314..f9c23a26a7 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -459,8 +459,7 @@

Log Analysis

-

Regex Expression

-

Enter a regex expression by starting with /. For example /[error|fail|crash] or /[^success]

+

Regex Expression: Enter a Regex expression by starting with /. For example /[error|fail|crash] or /[^success]

From d42a02dd9a05e3551e4db7e13d7a0556a57f02d3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:44:36 +0200 Subject: [PATCH 120/644] Logalyzer System frontend --- views/admin/system.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index f9c23a26a7..639ebe2abe 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -498,13 +498,14 @@

Warnings


-
- - - -
- -
+
+ + + +
+ + +
From 397e456775edd17162ab5102306f1a7d2e7e998b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:50:07 +0200 Subject: [PATCH 121/644] Logalyzer System frontend --- controllers/admin.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/controllers/admin.php b/controllers/admin.php index f8379f75f1..e5b6204896 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -453,6 +453,13 @@ public function system() { } $systemLib = new System($system->getId()); $systemLib->deleteResults($resultId); + } else if (!empty($this->post['newWarning'])) { + $key = $this->post['newWarningKey']; + if ($key != "") { + $systemLib = new System($system->getId()); + // TODO add and delete warning error keywords + //$systemLib->get; + } } else if (!empty($this->get['logo']) && $this->get['logo'] == 'upload') { // check for error values switch ($_FILES['logoUpload']['error']) { From a2e742415e87e8170806760bc3b2e15a4f91ba74 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:51:15 +0200 Subject: [PATCH 122/644] Logalyzer System frontend --- chronos.sql | 3 ++- libraries/dba/models/generator.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/chronos.sql b/chronos.sql index f0a325c62c..eaafe5b69a 100644 --- a/chronos.sql +++ b/chronos.sql @@ -134,7 +134,8 @@ CREATE TABLE `System` ( `created` datetime NOT NULL, `lastEdit` datetime NOT NULL, `isArchived` int(11) NOT NULL, - `logalyzerKeywords` json + `logalyzerWarnings` json, + `logalyzerErrors` json ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/libraries/dba/models/generator.php b/libraries/dba/models/generator.php index 1ea985572e..7a31321746 100644 --- a/libraries/dba/models/generator.php +++ b/libraries/dba/models/generator.php @@ -42,7 +42,8 @@ 'created', 'lastEdit', 'isArchived', - 'logalyzerKeywords' + 'logalyzerWarnings', + 'logalyzerErrors' ]; $CONF['Project'] = [ 'projectId', From 3a2e3609a87e9425b186911cf92592ef673a14f7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:55:53 +0200 Subject: [PATCH 123/644] Logalyzer System frontend --- controllers/admin.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index e5b6204896..42d5de7d11 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -454,8 +454,33 @@ public function system() { $systemLib = new System($system->getId()); $systemLib->deleteResults($resultId); } else if (!empty($this->post['newWarning'])) { - $key = $this->post['newWarningKey']; + $key = $this->post['newWarningKeyword']; if ($key != "") { + echo $key; + $systemLib = new System($system->getId()); + // TODO add and delete warning error keywords + //$systemLib->get; + } + } else if (!empty($this->post['newError'])) { + $key = $this->post['newErrorKeyword']; + if ($key != "") { + echo $key; + $systemLib = new System($system->getId()); + // TODO add and delete warning error keywords + //$systemLib->get; + } + } else if (!empty($this->post['deleteWarningKeyword'])) { + $key = $this->post['deleteWarningKeyword']; + if ($key != "") { + echo $key; + $systemLib = new System($system->getId()); + // TODO add and delete warning error keywords + //$systemLib->get; + } + } else if (!empty($this->post['deleteErrorKeyword'])) { + $key = $this->post['deleteErrorKeyword']; + if ($key != "") { + echo $key; $systemLib = new System($system->getId()); // TODO add and delete warning error keywords //$systemLib->get; From 5370d8e23a141d45f4390f6a40f92d4dd382a332 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:57:48 +0200 Subject: [PATCH 124/644] Logalyzer System frontend --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 639ebe2abe..bd53c8b425 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -483,7 +483,7 @@ - + Delete @@ -515,7 +515,7 @@ - + Delete From 2c3da8dbba524568316e5ee0387250845522f43f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:58:19 +0200 Subject: [PATCH 125/644] Logalyzer System frontend --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index bd53c8b425..7b05e55990 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -483,7 +483,7 @@ -
+ Delete @@ -515,7 +515,7 @@ - + Delete From 02c5b04168851dfdcdf55821b28f3e77e684f628 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 19:59:27 +0200 Subject: [PATCH 126/644] Logalyzer System frontend --- controllers/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 42d5de7d11..d6d81703fe 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -469,7 +469,7 @@ public function system() { // TODO add and delete warning error keywords //$systemLib->get; } - } else if (!empty($this->post['deleteWarningKeyword'])) { + } else if (!empty($this->get['deleteWarningKeyword'])) { $key = $this->post['deleteWarningKeyword']; if ($key != "") { echo $key; @@ -477,7 +477,7 @@ public function system() { // TODO add and delete warning error keywords //$systemLib->get; } - } else if (!empty($this->post['deleteErrorKeyword'])) { + } else if (!empty($this->get['deleteErrorKeyword'])) { $key = $this->post['deleteErrorKeyword']; if ($key != "") { echo $key; From e8136f346387a47f6ff2e37a7d4e6ccb17bbafec Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 20:00:58 +0200 Subject: [PATCH 127/644] Logalyzer System frontend --- controllers/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index d6d81703fe..0873daaa5f 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -470,7 +470,7 @@ public function system() { //$systemLib->get; } } else if (!empty($this->get['deleteWarningKeyword'])) { - $key = $this->post['deleteWarningKeyword']; + $key = $this->get['deleteWarningKeyword']; if ($key != "") { echo $key; $systemLib = new System($system->getId()); @@ -478,7 +478,7 @@ public function system() { //$systemLib->get; } } else if (!empty($this->get['deleteErrorKeyword'])) { - $key = $this->post['deleteErrorKeyword']; + $key = $this->get['deleteErrorKeyword']; if ($key != "") { echo $key; $systemLib = new System($system->getId()); From 5f9c1567f822ffd2ef5b0b68e81981f21d34bcd2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 15 Jul 2024 20:01:36 +0200 Subject: [PATCH 128/644] Logalyzer System frontend --- controllers/admin.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 0873daaa5f..40907bed7f 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -456,7 +456,6 @@ public function system() { } else if (!empty($this->post['newWarning'])) { $key = $this->post['newWarningKeyword']; if ($key != "") { - echo $key; $systemLib = new System($system->getId()); // TODO add and delete warning error keywords //$systemLib->get; @@ -464,7 +463,6 @@ public function system() { } else if (!empty($this->post['newError'])) { $key = $this->post['newErrorKeyword']; if ($key != "") { - echo $key; $systemLib = new System($system->getId()); // TODO add and delete warning error keywords //$systemLib->get; @@ -472,7 +470,6 @@ public function system() { } else if (!empty($this->get['deleteWarningKeyword'])) { $key = $this->get['deleteWarningKeyword']; if ($key != "") { - echo $key; $systemLib = new System($system->getId()); // TODO add and delete warning error keywords //$systemLib->get; @@ -480,7 +477,6 @@ public function system() { } else if (!empty($this->get['deleteErrorKeyword'])) { $key = $this->get['deleteErrorKeyword']; if ($key != "") { - echo $key; $systemLib = new System($system->getId()); // TODO add and delete warning error keywords //$systemLib->get; From 37ba8b6ee627f17d784188414e6c24f52fd15c19 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 16 Jul 2024 14:20:47 +0200 Subject: [PATCH 129/644] Changed naming of db columns --- chronos.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chronos.sql b/chronos.sql index eaafe5b69a..5f948f4a5c 100644 --- a/chronos.sql +++ b/chronos.sql @@ -71,8 +71,8 @@ CREATE TABLE `Job` ( `evaluationId` int(11) NOT NULL, `internalId` int(11) NOT NULL, `configurationIdentifier` varchar(256) COLLATE utf8_unicode_ci NOT NULL, - `logalyzerWarnings` smallint, - `logalyzerErrors` smallint, + `logalyzerCountWarnings` smallint, + `logalyzerCountErrors` smallint, `logalyzerHash` VARCHAR(64) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -134,8 +134,8 @@ CREATE TABLE `System` ( `created` datetime NOT NULL, `lastEdit` datetime NOT NULL, `isArchived` int(11) NOT NULL, - `logalyzerWarnings` json, - `logalyzerErrors` json + `logalyzerWarningKeywords` json, + `logalyzerErrorKeywords` json ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; From ab330575d4c4769a8f1a75836002923f1bb8d79b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 16 Jul 2024 22:32:03 +0200 Subject: [PATCH 130/644] Implemented backend changes to logalyzer behaviour. Missing the connection of front end in another branch to this backend. Some changes must be made to the controllers responsible for handling forms and buttons --- api/v1/job.php | 4 + controllers/job.php | 8 -- libraries/logalyzer.php | 195 ++++++++++++++++++++++-------------- views/evaluation/detail.php | 12 +-- 4 files changed, 131 insertions(+), 88 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index 064973e4af..38ef9cee2b 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -298,5 +298,9 @@ private function appendLog($id) { mkdir(UPLOADED_DATA_PATH . 'log'); } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); + + // TODO keep one object per job, not one per logLine + $logalyzer = new Logalyzer_Library($job); + $logalyzer->examineLogLine($this->request['log']); } } diff --git a/controllers/job.php b/controllers/job.php index 424ed96988..4dd7d74921 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -145,14 +145,6 @@ public function detail() { $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); - - // Calculate Log errors and warnings TODO naive approach, do so during runtime of a job to be able to react early - $logUtil = new logalyzer($job); - $errors = $logUtil->countLogOccurances("ERROR:"); - $warnings = $logUtil->countLogOccurances("WARNING:"); - $this->view->assign('logErrors', $errors); - $this->view->assign('logWarnings', $warnings); - unset($logUtil); } else { throw new Exception("No job with id: " . $this->get['id']); } diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 72aacdbe0e..eb3635a02c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -5,20 +5,17 @@ */ class Logalyzer_Library { private $job; + private $system; private $log; - private $logLength = -1; - private $thresholdError = 1; - private $thresholdWarning = 12; - private $thresholdLogSize = 10000; - private $warningKeys = ['WARNING:' => 0]; - private $errorKeys = ['ERROR:' => 0]; - private $warningAlert = false; - private $errorAlert = false; - private $changes = false; - private $hashPath; + private $warningKeys; + private $errorKeys; + /** + * @throws Exception + */ public function __construct($job) { $this->job = $job; + $this->system = new System($this->job->getSystemId()); $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; $log = Util::readFileContents($path); if ($log === false) { @@ -27,114 +24,164 @@ public function __construct($job) { $this->log = $log; } - $this->hashPath = UPLOADED_DATA_PATH . 'log/' . $job->getId() . '.hash'; - if (!$line = file_get_contents($this->hashPath)) { - file_put_contents($this->hashPath, hash("sha256", $this->log)); - $this->changes = true; - } - else { - if ($line == hash_file('sha256', $path)) { - $this->changes = false; - } - else { - $this->changes = true; - } - } + // Grab keyword arrays at creation of this object. Changes during a job run make the result outdated, but consistent + $this->warningKeys = json_decode($this->system->getLogalyzerWarningKeywords()); + $this->errorKeys = json_decode($this->system->getLogalyzerErrorKeywords()); + $this->calculateAndSetHash(); + } /** * @param string $keyword + * @param string $target + * @param bool $regex * @return int */ - public function countLogOccurances(string $keyword) { - return substr_count($this->log, $keyword); + public function countLogOccurances(string $keyword, string $target, bool $regex = false) { + if ($regex) { + return preg_match_all($keyword, $target); + } + else { + return substr_count($target, $keyword); + } } + private function checkHashDifference() { + $errorArray = json_decode($this->system->getLogalyzerErrorKeywords); + $warningArray = json_decode($this->system->getLogalyzerWarningKeywords); + $mergedArray = array_merge($errorArray, $warningArray); + $mergedJson = json_encode($mergedArray); - public function examineLogAndSetAlert() { + if($this->job->getLogalyzerHash() == hash('sha1', $mergedJson)) { + return false; + } + else { + return true; + } + } + public function examineEntireLog() { // Check if there have been changes to the log - if ($this->changes) { - // Log changed, set new hash - $this->setHash(); - // Check if log is too long - $this->logLength = strlen($this->log); - if ($this->logLength > $this->thresholdLogSize) { - $this->job->SetSizeWarning(true); + if ($this->checkHashDifference()) { + // Count occurrences of all defined keywords. + $warningCount = 0; + $errorCount = 0; + foreach ($this->warningKeys as $key) { + if(str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { + // $key is regex + $warningCount += $this->countLogOccurances($key, $this->log, true); + } + else { + $warningCount += $this->countLogOccurances($key, $this->log); + } } - // Count occurrences of all defined keywords. Default keywords are 'error' and 'warning' - foreach ($this->warningKeys as $key => $value) { - $this->warningKeys[$key] = $this->countLogOccurances($key); + foreach ($this->errorKeys as $key) { + if(str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { + // $key is regex. + $errorCount += $this->countLogOccurances($key, $this->log, true); + } + else { + $errorCount += $this->countLogOccurances($key, $this->log); + } } - foreach ($this->errorKeys as $key => $value) { - $this->errorKeys[$key] = $this->countLogOccurances($key); + // Log is reexamined using up-to-date keys, save new hash. + $this->job->setLogalyzerCountWarnings($warningCount); + $this->job->setLogalyzerCountErrors($errorCount); + $this->calculateAndSetHash(); + } + } + public function examineLogLine($logLine) { + foreach ($this->warningKeys as $key) { + if(str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { + // $key is regex + for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountWarnings(); + } } - - // Check if errors/warnings are more than the threshold - foreach ($this->warningKeys as $key => $value) { - if ($value >= $this->thresholdWarning) { - $this->job->setLogAlert('warning'); + else { + for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountWarnings(); } } - foreach ($this->errorKeys as $key => $value) { - if ($value >= $this->thresholdError) { - $this->job->setLogAlert('error'); + } + foreach ($this->errorKeys as $key) { + if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { + // $key is regex. + for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountWarnings(); + } + } else { + for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountWarnings(); } } } } - /** - * @param int $size - */ - // TODO Threshold not a static value but a percentage compared to the other job's logs - public function setThresholdLogSize($size) - { - $this->thresholdLogSize = $size; - } - - /** - * @param int $size - * @return int - */ - public function getThresholdLogSize($size) - { - return $this->thresholdLogSize; - } /** * @param string $identifier add $key as warning or error? * @param string $key name of new keyword + * @return void */ public function addKey(string $identifier, string $key) { if ($identifier == 'warning') { - $this->warningKeys[$key] = 0; + $warningArray = json_decode($this->system->getLogalyzerWarningKeywords); + $warningArray[] = $key; + $warningArray = json_encode($warningArray); + $this->system->setLogalyzerWarningKeywords($warningArray); + } else if ($identifier == 'error') { - $this->errorKeys[$key] = 0; + $errorArray = json_decode($this->system->getLogalyzerErrorKeywords); + $errorArray[] = $key; + $errorArray = json_encode($errorArray); + $this->system->setLogalyzerWarningKeywords($errorArray); } else { echo "identifier not recognized."; } } /** - * @param string $identifier remove $key as warning or error? + * @param string $identifier remove $key from warning or error * @param string $key name of keyword to be deleted + * @return void */ public function removeKey(string $identifier, string $key) { if ($identifier == 'warning') { - unset($this->warningKeys[$key]); + $warningArray = json_decode($this->system->getLogalyzerWarningKeywords); + if (($index = array_search($key, $warningArray)) !== false) { + unset($warningArray[$index]); + $this->system->setLogalyzerWarningKeywords(json_encode($warningArray)); + } } else if ($identifier == 'error') { - unset($this->errorKeys[$key]); + $errorArray = json_decode($this->system->getLogalyzerErrorKeywords); + if (($index = array_search($key, $errorArray)) !== false) { + unset($errorArray[$index]); + $this->system->setLogalyzerErrorKeywords(json_encode($errorArray)); + } + } else { echo "identifier not recognized."; } } - function setHash() { - file_put_contents($this->hashPath, hash('sha256', $this->log)); + /** + * gets current keywords from system, calculates its hash and saves it into this jobs db + * @return void + */ + function calculateAndSetHash() { + $mergedArray = array_merge($this->errorKeys, $this->warningKeys); + $mergedJson = json_encode($mergedArray); + $this->job->setLogalyzerHash(hash('sha1', $mergedJson)); } + + /** + * @return string + */ function getHash() { - return file_get_contents($this->hashPath); + return $this->job->getLogalyzerHash(); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index c849287b06..0250c0e91c 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -210,16 +210,16 @@ function submitData() { getInternalId(); ?> getDescription(); ?> - getLogAlert() == "error") { ?> - - getLogAlert() == "warning") { ?> - + getLogalyzerCountErrors() > 0) { ?> + + getLogalyzerCountWarnings() > 0) { ?> + - getSizeWarning()) { ?> + getStatus() == Define::JOB_STATUS_SCHEDULED) { ?> From 42e6ccc7e0000e46944efc3fdcc7745ad6201100 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 16 Jul 2024 22:51:28 +0200 Subject: [PATCH 131/644] Implemented backend changes to logalyzer behaviour. Missing the connection of front end in another branch to this backend. Some changes must be made to the controllers responsible for handling forms and buttons --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index eb3635a02c..0747bf24a1 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -14,6 +14,7 @@ class Logalyzer_Library { * @throws Exception */ public function __construct($job) { + // TODO singleton if a logalyzer for this job already exists? Is that possible? $this->job = $job; $this->system = new System($this->job->getSystemId()); $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; From 4f1b71a2190783e88b5bcd3f08fcebcaf91ca8ed Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 16 Jul 2024 23:03:43 +0200 Subject: [PATCH 132/644] Implemented backend changes to logalyzer behaviour. Missing the connection of front end in another branch to this backend. Some changes must be made to the controllers responsible for handling forms and buttons --- libraries/logalyzer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 0747bf24a1..eb3635a02c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -14,7 +14,6 @@ class Logalyzer_Library { * @throws Exception */ public function __construct($job) { - // TODO singleton if a logalyzer for this job already exists? Is that possible? $this->job = $job; $this->system = new System($this->job->getSystemId()); $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; From 09e92f22fc3753ad21efd5fe221b1bb3e9725c13 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 16 Jul 2024 23:26:32 +0200 Subject: [PATCH 133/644] Implemented sanity check, can be done as a global magic number --- libraries/logalyzer.php | 49 ++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index eb3635a02c..048af0fcbf 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -89,32 +89,35 @@ public function examineEntireLog() { } } public function examineLogLine($logLine) { - foreach ($this->warningKeys as $key) { - if(str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { - // $key is regex - for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountWarnings(); - } - } - else { - for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountWarnings(); + if($this->getLogalyzerCountWarnings <= 10) { + foreach ($this->warningKeys as $key) { + if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { + // $key is regex + for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountWarnings(); + } + } else { + for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountWarnings(); + } } } } - foreach ($this->errorKeys as $key) { - if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { - // $key is regex. - for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountWarnings(); - } - } else { - for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountWarnings(); + if($this->getLogalyzerCountErrors <= 10) { + foreach ($this->errorKeys as $key) { + if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { + // $key is regex. + for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountWarnings(); + } + } else { + for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountWarnings(); + } } } } From 39c306e160cb870468f733b7045553c7fad96a2d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 16 Jul 2024 23:29:39 +0200 Subject: [PATCH 134/644] fixed typo --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 048af0fcbf..512a9449de 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -111,12 +111,12 @@ public function examineLogLine($logLine) { // $key is regex. for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { // TODO implement increment - $this->job->incrementLogalyzerCountWarnings(); + $this->job->incrementLogalyzerCountErrors(); } } else { for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { // TODO implement increment - $this->job->incrementLogalyzerCountWarnings(); + $this->job->incrementLogalyzerCountErrors(); } } } From 0f84f0004b328d5bc85642e4ac7853e5d60df91d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 16 Jul 2024 23:55:34 +0200 Subject: [PATCH 135/644] fixed typo --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 512a9449de..ddb2c72cab 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -89,7 +89,7 @@ public function examineEntireLog() { } } public function examineLogLine($logLine) { - if($this->getLogalyzerCountWarnings <= 10) { + if($this->job->getLogalyzerCountWarnings <= 10) { foreach ($this->warningKeys as $key) { if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { // $key is regex @@ -105,7 +105,7 @@ public function examineLogLine($logLine) { } } } - if($this->getLogalyzerCountErrors <= 10) { + if($this->job->getLogalyzerCountErrors <= 10) { foreach ($this->errorKeys as $key) { if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { // $key is regex. From f324b7be8903e2564cdcde20bfee1ffd406d7185 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 12:14:03 +0200 Subject: [PATCH 136/644] fixed typo --- chronos.sql | 10 +++--- libraries/logalyzer.php | 71 +++++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/chronos.sql b/chronos.sql index 5f948f4a5c..636c3c89e1 100644 --- a/chronos.sql +++ b/chronos.sql @@ -71,9 +71,9 @@ CREATE TABLE `Job` ( `evaluationId` int(11) NOT NULL, `internalId` int(11) NOT NULL, `configurationIdentifier` varchar(256) COLLATE utf8_unicode_ci NOT NULL, - `logalyzerCountWarnings` smallint, - `logalyzerCountErrors` smallint, - `logalyzerHash` VARCHAR(64) + `logalyzerCountWarnings` int(11), + `logalyzerCountErrors` int(11), + `logalyzerHash` varchar(64) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -134,8 +134,8 @@ CREATE TABLE `System` ( `created` datetime NOT NULL, `lastEdit` datetime NOT NULL, `isArchived` int(11) NOT NULL, - `logalyzerWarningKeywords` json, - `logalyzerErrorKeywords` json + `logalyzerWarningPatterns` json, + `logalyzerErrorPatterns` json ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index ddb2c72cab..988b6aa16d 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -7,8 +7,8 @@ class Logalyzer_Library { private $job; private $system; private $log; - private $warningKeys; - private $errorKeys; + private $warningPatterns; + private $errorPatterns; /** * @throws Exception @@ -16,18 +16,11 @@ class Logalyzer_Library { public function __construct($job) { $this->job = $job; $this->system = new System($this->job->getSystemId()); - $path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; - $log = Util::readFileContents($path); - if ($log === false) { - $this->log = ""; - } else { - $this->log = $log; - } // Grab keyword arrays at creation of this object. Changes during a job run make the result outdated, but consistent - $this->warningKeys = json_decode($this->system->getLogalyzerWarningKeywords()); - $this->errorKeys = json_decode($this->system->getLogalyzerErrorKeywords()); - $this->calculateAndSetHash(); + $this->warningPatterns = json_decode($this->system->getLogalyzerWarningPatterns()); + $this->errorPatterns = json_decode($this->system->getLogalyzerErrorPatterns()); + //$this->calculateAndSetHash(); } @@ -46,8 +39,8 @@ public function countLogOccurances(string $keyword, string $target, bool $regex } } private function checkHashDifference() { - $errorArray = json_decode($this->system->getLogalyzerErrorKeywords); - $warningArray = json_decode($this->system->getLogalyzerWarningKeywords); + $errorArray = json_decode($this->system->getLogalyzerErrorPatterns); + $warningArray = json_decode($this->system->getLogalyzerWarningPatterns); $mergedArray = array_merge($errorArray, $warningArray); $mergedJson = json_encode($mergedArray); @@ -59,12 +52,19 @@ private function checkHashDifference() { } } public function examineEntireLog() { + $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId() . '.log'; + $log = Util::readFileContents($path); + if ($log === false) { + $this->log = ""; + } else { + $this->log = $log; + } // Check if there have been changes to the log if ($this->checkHashDifference()) { // Count occurrences of all defined keywords. $warningCount = 0; $errorCount = 0; - foreach ($this->warningKeys as $key) { + foreach ($this->warningPatterns as $key) { if(str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { // $key is regex $warningCount += $this->countLogOccurances($key, $this->log, true); @@ -73,7 +73,7 @@ public function examineEntireLog() { $warningCount += $this->countLogOccurances($key, $this->log); } } - foreach ($this->errorKeys as $key) { + foreach ($this->errorPatterns as $key) { if(str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { // $key is regex. $errorCount += $this->countLogOccurances($key, $this->log, true); @@ -90,7 +90,7 @@ public function examineEntireLog() { } public function examineLogLine($logLine) { if($this->job->getLogalyzerCountWarnings <= 10) { - foreach ($this->warningKeys as $key) { + foreach ($this->warningPatterns as $key) { if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { // $key is regex for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { @@ -106,7 +106,7 @@ public function examineLogLine($logLine) { } } if($this->job->getLogalyzerCountErrors <= 10) { - foreach ($this->errorKeys as $key) { + foreach ($this->errorPatterns as $key) { if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { // $key is regex. for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { @@ -130,17 +130,17 @@ public function examineLogLine($logLine) { */ public function addKey(string $identifier, string $key) { if ($identifier == 'warning') { - $warningArray = json_decode($this->system->getLogalyzerWarningKeywords); + $warningArray = json_decode($this->system->getLogalyzerWarningPatterns); $warningArray[] = $key; $warningArray = json_encode($warningArray); - $this->system->setLogalyzerWarningKeywords($warningArray); + $this->system->setLogalyzerWarningPatterns($warningArray); } else if ($identifier == 'error') { - $errorArray = json_decode($this->system->getLogalyzerErrorKeywords); + $errorArray = json_decode($this->system->getLogalyzerErrorPatterns); $errorArray[] = $key; $errorArray = json_encode($errorArray); - $this->system->setLogalyzerWarningKeywords($errorArray); + $this->system->setLogalyzerWarningPatterns($errorArray); } else { echo "identifier not recognized."; @@ -153,17 +153,17 @@ public function addKey(string $identifier, string $key) { */ public function removeKey(string $identifier, string $key) { if ($identifier == 'warning') { - $warningArray = json_decode($this->system->getLogalyzerWarningKeywords); + $warningArray = json_decode($this->system->getLogalyzerWarningPatterns); if (($index = array_search($key, $warningArray)) !== false) { unset($warningArray[$index]); - $this->system->setLogalyzerWarningKeywords(json_encode($warningArray)); + $this->system->setLogalyzerWarningPatterns(json_encode($warningArray)); } } else if ($identifier == 'error') { - $errorArray = json_decode($this->system->getLogalyzerErrorKeywords); + $errorArray = json_decode($this->system->getLogalyzerPatterns); if (($index = array_search($key, $errorArray)) !== false) { unset($errorArray[$index]); - $this->system->setLogalyzerErrorKeywords(json_encode($errorArray)); + $this->system->setLogalyzerErrorPatterns(json_encode($errorArray)); } } @@ -172,13 +172,22 @@ public function removeKey(string $identifier, string $key) { } } /** - * gets current keywords from system, calculates its hash and saves it into this jobs db - * @return void + * Allows calculating the hash before any operations are done + * @return string */ - function calculateAndSetHash() { - $mergedArray = array_merge($this->errorKeys, $this->warningKeys); + function calculateHash() { + $mergedArray = array_merge($this->errorPatterns, $this->warningPatterns); $mergedJson = json_encode($mergedArray); - $this->job->setLogalyzerHash(hash('sha1', $mergedJson)); + return hash('sha1', $mergedJson); + } + + /** + * Allows for setting the hash after operations are done + * @param $value + * @return void + */ + function setHash($value) { + $this->job->setLogalyzerHash($value); } /** From ef8c2ad9f1832c20777ce74a325056ae78a8c24e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 12:16:22 +0200 Subject: [PATCH 137/644] Implement changes to finalize this feature --- libraries/dba/models/generator.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/dba/models/generator.php b/libraries/dba/models/generator.php index 7a31321746..bf769b53d7 100644 --- a/libraries/dba/models/generator.php +++ b/libraries/dba/models/generator.php @@ -42,8 +42,8 @@ 'created', 'lastEdit', 'isArchived', - 'logalyzerWarnings', - 'logalyzerErrors' + 'logalyzerWarningPatterns', + 'logalyzerErrorPatterns' ]; $CONF['Project'] = [ 'projectId', @@ -97,8 +97,8 @@ 'evaluationId', 'internalId', 'configurationIdentifier', - 'logalyzerWarnings', - 'logalyzerErrors', + 'logalyzerCountWarnings', + 'logalyzerCountErrors', 'logalyzerHash' ]; $CONF['Result'] = [ @@ -207,8 +207,8 @@ 'internalId', 'configurationIdentifier', 'projectUserId', - 'logalyzerWarnings', - 'logalyzerErrors', + 'logalyzerCountWarnings', + 'logalyzerCountErrors', 'logalyzerHash' ]; From 224eb25f5b30f29ece679bd0f2d14c525fd0f0bd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 12:41:28 +0200 Subject: [PATCH 138/644] renamed database entries --- chronos.sql | 4 ++-- libraries/dba/models/generator.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chronos.sql b/chronos.sql index 636c3c89e1..82290b181e 100644 --- a/chronos.sql +++ b/chronos.sql @@ -71,8 +71,8 @@ CREATE TABLE `Job` ( `evaluationId` int(11) NOT NULL, `internalId` int(11) NOT NULL, `configurationIdentifier` varchar(256) COLLATE utf8_unicode_ci NOT NULL, - `logalyzerCountWarnings` int(11), - `logalyzerCountErrors` int(11), + `logalyzerWarningCount` int(11), + `logalyzerErrorCount` int(11), `logalyzerHash` varchar(64) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/libraries/dba/models/generator.php b/libraries/dba/models/generator.php index bf769b53d7..4316ae0385 100644 --- a/libraries/dba/models/generator.php +++ b/libraries/dba/models/generator.php @@ -97,8 +97,8 @@ 'evaluationId', 'internalId', 'configurationIdentifier', - 'logalyzerCountWarnings', - 'logalyzerCountErrors', + 'logalyzerWarningCount', + 'logalyzerErrorCount', 'logalyzerHash' ]; $CONF['Result'] = [ From 22f36975f3252c98db0afd508db88e83e3b4b0a5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 12:51:36 +0200 Subject: [PATCH 139/644] renamed database entries --- chronos.sql | 3 +-- libraries/dba/models/generator.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/chronos.sql b/chronos.sql index 82290b181e..69ece64653 100644 --- a/chronos.sql +++ b/chronos.sql @@ -134,8 +134,7 @@ CREATE TABLE `System` ( `created` datetime NOT NULL, `lastEdit` datetime NOT NULL, `isArchived` int(11) NOT NULL, - `logalyzerWarningPatterns` json, - `logalyzerErrorPatterns` json + `logalyzerPatterns` json ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/libraries/dba/models/generator.php b/libraries/dba/models/generator.php index 4316ae0385..007c9d2322 100644 --- a/libraries/dba/models/generator.php +++ b/libraries/dba/models/generator.php @@ -42,8 +42,7 @@ 'created', 'lastEdit', 'isArchived', - 'logalyzerWarningPatterns', - 'logalyzerErrorPatterns' + 'logalyzerPatterns' ]; $CONF['Project'] = [ 'projectId', From e2b4e035fbdd9e8a59f9519f9f07dba58ffb303b Mon Sep 17 00:00:00 2001 From: Marco Vogt Date: Fri, 19 Jul 2024 12:57:07 +0200 Subject: [PATCH 140/644] Execute generator.php --- libraries/dba/models/Job.class.php | 46 ++++++++++++++----- libraries/dba/models/JobFactory.class.php | 4 +- libraries/dba/models/JobView.class.php | 38 ++++++++++++++- libraries/dba/models/JobViewFactory.class.php | 4 +- libraries/dba/models/System.class.php | 14 +++++- libraries/dba/models/SystemFactory.class.php | 6 +-- 6 files changed, 91 insertions(+), 21 deletions(-) diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 057f01cf63..bc486176e3 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -43,10 +43,11 @@ class Job extends AbstractModel { private $evaluationId; private $internalId; private $configurationIdentifier; - private $logAlert; - private $logSizeWarning = false; + private $logalyzerWarningCount; + private $logalyzerErrorCount; + private $logalyzerHash; - function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier) { + function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $logalyzerWarningCount, $logalyzerErrorCount, $logalyzerHash) { $this->jobId = $jobId; $this->userId = $userId; $this->description = $description; @@ -63,6 +64,9 @@ function __construct($jobId, $userId, $description, $systemId, $environment, $ph $this->evaluationId = $evaluationId; $this->internalId = $internalId; $this->configurationIdentifier = $configurationIdentifier; + $this->logalyzerWarningCount = $logalyzerWarningCount; + $this->logalyzerErrorCount = $logalyzerErrorCount; + $this->logalyzerHash = $logalyzerHash; } function getKeyValueDict() { @@ -83,6 +87,9 @@ function getKeyValueDict() { $dict['evaluationId'] = $this->evaluationId; $dict['internalId'] = $this->internalId; $dict['configurationIdentifier'] = $this->configurationIdentifier; + $dict['logalyzerWarningCount'] = $this->logalyzerWarningCount; + $dict['logalyzerErrorCount'] = $this->logalyzerErrorCount; + $dict['logalyzerHash'] = $this->logalyzerHash; return $dict; } @@ -222,19 +229,31 @@ function getConfigurationIdentifier(){ function setConfigurationIdentifier($configurationIdentifier){ $this->configurationIdentifier = $configurationIdentifier; } - function getLogAlert() { - return $this->logAlert; + + function getLogalyzerWarningCount(){ + return $this->logalyzerWarningCount; } - function setLogAlert($alert) { - // last call of this method overwrites previous value. For now logic in logalyzer.php first checks if its warning and then if its error - $this->logAlert = $alert; + + function setLogalyzerWarningCount($logalyzerWarningCount){ + $this->logalyzerWarningCount = $logalyzerWarningCount; } - function getSizeWarning() { - return $this->logSizeWarning; + + function getLogalyzerErrorCount(){ + return $this->logalyzerErrorCount; } - function setSizeWarning($bool) { - $this->logSizeWarning = $bool; + + function setLogalyzerErrorCount($logalyzerErrorCount){ + $this->logalyzerErrorCount = $logalyzerErrorCount; } + + function getLogalyzerHash(){ + return $this->logalyzerHash; + } + + function setLogalyzerHash($logalyzerHash){ + $this->logalyzerHash = $logalyzerHash; + } + const JOB_ID = "jobId"; const USER_ID = "userId"; const DESCRIPTION = "description"; @@ -251,4 +270,7 @@ function setSizeWarning($bool) { const EVALUATION_ID = "evaluationId"; const INTERNAL_ID = "internalId"; const CONFIGURATION_IDENTIFIER = "configurationIdentifier"; + const LOGALYZER_WARNING_COUNT = "logalyzerWarningCount"; + const LOGALYZER_ERROR_COUNT = "logalyzerErrorCount"; + const LOGALYZER_HASH = "logalyzerHash"; } diff --git a/libraries/dba/models/JobFactory.class.php b/libraries/dba/models/JobFactory.class.php index 7a7e85ebb4..9f190570c4 100644 --- a/libraries/dba/models/JobFactory.class.php +++ b/libraries/dba/models/JobFactory.class.php @@ -47,7 +47,7 @@ function getCacheValidTime() { * @return Job */ function getNullObject() { - $o = new Job(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); + $o = new Job(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); return $o; } @@ -57,7 +57,7 @@ function getNullObject() { * @return Job */ function createObjectFromDict($pk, $dict) { - $o = new Job($dict['jobId'], $dict['userId'], $dict['description'], $dict['systemId'], $dict['environment'], $dict['phases'], $dict['configuration'], $dict['status'], $dict['progress'], $dict['result'], $dict['created'], $dict['started'], $dict['finished'], $dict['evaluationId'], $dict['internalId'], $dict['configurationIdentifier']); + $o = new Job($dict['jobId'], $dict['userId'], $dict['description'], $dict['systemId'], $dict['environment'], $dict['phases'], $dict['configuration'], $dict['status'], $dict['progress'], $dict['result'], $dict['created'], $dict['started'], $dict['finished'], $dict['evaluationId'], $dict['internalId'], $dict['configurationIdentifier'], $dict['logalyzerWarningCount'], $dict['logalyzerErrorCount'], $dict['logalyzerHash']); return $o; } diff --git a/libraries/dba/models/JobView.class.php b/libraries/dba/models/JobView.class.php index c6a9943131..63b6dca7df 100644 --- a/libraries/dba/models/JobView.class.php +++ b/libraries/dba/models/JobView.class.php @@ -44,8 +44,11 @@ class JobView extends AbstractModel { private $internalId; private $configurationIdentifier; private $projectUserId; + private $logalyzerCountWarnings; + private $logalyzerCountErrors; + private $logalyzerHash; - function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $projectUserId) { + function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $projectUserId, $logalyzerCountWarnings, $logalyzerCountErrors, $logalyzerHash) { $this->jobId = $jobId; $this->userId = $userId; $this->description = $description; @@ -63,6 +66,9 @@ function __construct($jobId, $userId, $description, $systemId, $environment, $ph $this->internalId = $internalId; $this->configurationIdentifier = $configurationIdentifier; $this->projectUserId = $projectUserId; + $this->logalyzerCountWarnings = $logalyzerCountWarnings; + $this->logalyzerCountErrors = $logalyzerCountErrors; + $this->logalyzerHash = $logalyzerHash; } function getKeyValueDict() { @@ -84,6 +90,9 @@ function getKeyValueDict() { $dict['internalId'] = $this->internalId; $dict['configurationIdentifier'] = $this->configurationIdentifier; $dict['projectUserId'] = $this->projectUserId; + $dict['logalyzerCountWarnings'] = $this->logalyzerCountWarnings; + $dict['logalyzerCountErrors'] = $this->logalyzerCountErrors; + $dict['logalyzerHash'] = $this->logalyzerHash; return $dict; } @@ -231,6 +240,30 @@ function getProjectUserId(){ function setProjectUserId($projectUserId){ $this->projectUserId = $projectUserId; } + + function getLogalyzerCountWarnings(){ + return $this->logalyzerCountWarnings; + } + + function setLogalyzerCountWarnings($logalyzerCountWarnings){ + $this->logalyzerCountWarnings = $logalyzerCountWarnings; + } + + function getLogalyzerCountErrors(){ + return $this->logalyzerCountErrors; + } + + function setLogalyzerCountErrors($logalyzerCountErrors){ + $this->logalyzerCountErrors = $logalyzerCountErrors; + } + + function getLogalyzerHash(){ + return $this->logalyzerHash; + } + + function setLogalyzerHash($logalyzerHash){ + $this->logalyzerHash = $logalyzerHash; + } const JOB_ID = "jobId"; const USER_ID = "userId"; @@ -249,4 +282,7 @@ function setProjectUserId($projectUserId){ const INTERNAL_ID = "internalId"; const CONFIGURATION_IDENTIFIER = "configurationIdentifier"; const PROJECT_USER_ID = "projectUserId"; + const LOGALYZER_COUNT_WARNINGS = "logalyzerCountWarnings"; + const LOGALYZER_COUNT_ERRORS = "logalyzerCountErrors"; + const LOGALYZER_HASH = "logalyzerHash"; } diff --git a/libraries/dba/models/JobViewFactory.class.php b/libraries/dba/models/JobViewFactory.class.php index 9413ea188f..539f11380a 100644 --- a/libraries/dba/models/JobViewFactory.class.php +++ b/libraries/dba/models/JobViewFactory.class.php @@ -47,7 +47,7 @@ function getCacheValidTime() { * @return JobView */ function getNullObject() { - $o = new JobView(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); + $o = new JobView(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); return $o; } @@ -57,7 +57,7 @@ function getNullObject() { * @return JobView */ function createObjectFromDict($pk, $dict) { - $o = new JobView($dict['jobId'], $dict['userId'], $dict['description'], $dict['systemId'], $dict['environment'], $dict['phases'], $dict['configuration'], $dict['status'], $dict['progress'], $dict['result'], $dict['created'], $dict['started'], $dict['finished'], $dict['evaluationId'], $dict['internalId'], $dict['configurationIdentifier'], $dict['projectUserId']); + $o = new JobView($dict['jobId'], $dict['userId'], $dict['description'], $dict['systemId'], $dict['environment'], $dict['phases'], $dict['configuration'], $dict['status'], $dict['progress'], $dict['result'], $dict['created'], $dict['started'], $dict['finished'], $dict['evaluationId'], $dict['internalId'], $dict['configurationIdentifier'], $dict['projectUserId'], $dict['logalyzerCountWarnings'], $dict['logalyzerCountErrors'], $dict['logalyzerHash']); return $o; } diff --git a/libraries/dba/models/System.class.php b/libraries/dba/models/System.class.php index 0fdf9b67ce..3d60c42e05 100644 --- a/libraries/dba/models/System.class.php +++ b/libraries/dba/models/System.class.php @@ -39,8 +39,9 @@ class System extends AbstractModel { private $created; private $lastEdit; private $isArchived; + private $logalyzerPatterns; - function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived) { + function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns) { $this->systemId = $systemId; $this->name = $name; $this->description = $description; @@ -53,6 +54,7 @@ function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranc $this->created = $created; $this->lastEdit = $lastEdit; $this->isArchived = $isArchived; + $this->logalyzerPatterns = $logalyzerPatterns; } function getKeyValueDict() { @@ -69,6 +71,7 @@ function getKeyValueDict() { $dict['created'] = $this->created; $dict['lastEdit'] = $this->lastEdit; $dict['isArchived'] = $this->isArchived; + $dict['logalyzerPatterns'] = $this->logalyzerPatterns; return $dict; } @@ -176,6 +179,14 @@ function getIsArchived(){ function setIsArchived($isArchived){ $this->isArchived = $isArchived; } + + function getLogalyzerPatterns(){ + return $this->logalyzerPatterns; + } + + function setLogalyzerPatterns($logalyzerPatterns){ + $this->logalyzerPatterns = $logalyzerPatterns; + } const SYSTEM_ID = "systemId"; const NAME = "name"; @@ -189,4 +200,5 @@ function setIsArchived($isArchived){ const CREATED = "created"; const LAST_EDIT = "lastEdit"; const IS_ARCHIVED = "isArchived"; + const LOGALYZER_PATTERNS = "logalyzerPatterns"; } diff --git a/libraries/dba/models/SystemFactory.class.php b/libraries/dba/models/SystemFactory.class.php index e49fe3355a..8d4e47f8cc 100644 --- a/libraries/dba/models/SystemFactory.class.php +++ b/libraries/dba/models/SystemFactory.class.php @@ -32,7 +32,7 @@ function getModelName() { } function getModelTable() { - return "`System`"; + return "System"; } function isCachable() { @@ -47,7 +47,7 @@ function getCacheValidTime() { * @return System */ function getNullObject() { - $o = new System(-1, null, null, null, null, null, null, null, null, null, null, null); + $o = new System(-1, null, null, null, null, null, null, null, null, null, null, null, null); return $o; } @@ -57,7 +57,7 @@ function getNullObject() { * @return System */ function createObjectFromDict($pk, $dict) { - $o = new System($dict['systemId'], $dict['name'], $dict['description'], $dict['userId'], $dict['vcsUrl'], $dict['vcsBranch'], $dict['vcsType'], $dict['vcsUser'], $dict['vcsPassword'], $dict['created'], $dict['lastEdit'], $dict['isArchived']); + $o = new System($dict['systemId'], $dict['name'], $dict['description'], $dict['userId'], $dict['vcsUrl'], $dict['vcsBranch'], $dict['vcsType'], $dict['vcsUser'], $dict['vcsPassword'], $dict['created'], $dict['lastEdit'], $dict['isArchived'], $dict['logalyzerPatterns']); return $o; } From d4f56b94a0942bcd8f39fdf076652ba2b09aa7b1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 13:42:57 +0200 Subject: [PATCH 141/644] implementation changes --- libraries/logalyzer.php | 194 +++++++++++++++++++++------------------- 1 file changed, 104 insertions(+), 90 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 988b6aa16d..dba6a7532b 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -3,25 +3,23 @@ /** * Analyze the log of a Chronos job using predefined keywords */ -class Logalyzer_Library { +class Logalyzer_Library +{ private $job; private $system; private $log; private $warningPatterns; private $errorPatterns; + private $data; /** * @throws Exception */ - public function __construct($job) { + public function __construct($job) + { $this->job = $job; $this->system = new System($this->job->getSystemId()); - - // Grab keyword arrays at creation of this object. Changes during a job run make the result outdated, but consistent - $this->warningPatterns = json_decode($this->system->getLogalyzerWarningPatterns()); - $this->errorPatterns = json_decode($this->system->getLogalyzerErrorPatterns()); - //$this->calculateAndSetHash(); - + $this->assignPatterns(); } /** @@ -30,28 +28,23 @@ public function __construct($job) { * @param bool $regex * @return int */ - public function countLogOccurances(string $keyword, string $target, bool $regex = false) { + public function countLogOccurances(string $keyword, string $target, bool $regex = false) + { if ($regex) { return preg_match_all($keyword, $target); - } - else { + } else { return substr_count($target, $keyword); } } - private function checkHashDifference() { - $errorArray = json_decode($this->system->getLogalyzerErrorPatterns); - $warningArray = json_decode($this->system->getLogalyzerWarningPatterns); - $mergedArray = array_merge($errorArray, $warningArray); - $mergedJson = json_encode($mergedArray); - if($this->job->getLogalyzerHash() == hash('sha1', $mergedJson)) { - return false; - } - else { - return true; - } + private function checkHashDifference($current) + { + // TODO check if returns the right value + return !($this->job->getLogalyzerHash() == $current); } - public function examineEntireLog() { + + public function examineEntireLog() + { $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId() . '.log'; $log = Util::readFileContents($path); if ($log === false) { @@ -60,116 +53,137 @@ public function examineEntireLog() { $this->log = $log; } // Check if there have been changes to the log - if ($this->checkHashDifference()) { - // Count occurrences of all defined keywords. - $warningCount = 0; - $errorCount = 0; - foreach ($this->warningPatterns as $key) { - if(str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { - // $key is regex + $hash = $this->calculateHash(); + + // Count occurrences of all defined keywords. + $warningCount = 0; + $errorCount = 0; + foreach ($this->warningPatterns as $array) { + foreach ($array as $key) { + if ($key === 'regex') { $warningCount += $this->countLogOccurances($key, $this->log, true); - } - else { + } else { $warningCount += $this->countLogOccurances($key, $this->log); } } - foreach ($this->errorPatterns as $key) { - if(str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { - // $key is regex. + } + foreach ($this->errorPatterns as $array) { + foreach ($array as $key) { + if ($key === 'regex') { $errorCount += $this->countLogOccurances($key, $this->log, true); - } - else { + } else { $errorCount += $this->countLogOccurances($key, $this->log); } } - // Log is reexamined using up-to-date keys, save new hash. - $this->job->setLogalyzerCountWarnings($warningCount); - $this->job->setLogalyzerCountErrors($errorCount); - $this->calculateAndSetHash(); } + $this->job->setLogalyzerCountWarnings($warningCount); + $this->job->setLogalyzerCountErrors($errorCount); + $this->setHash($hash); } + public function examineLogLine($logLine) { - if($this->job->getLogalyzerCountWarnings <= 10) { - foreach ($this->warningPatterns as $key) { - if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { - // $key is regex - for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountWarnings(); - } - } else { - for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountWarnings(); - } + // TODO more elegant solution + while ($this->job->getLogalyzerCountWarnings <= 10 && $this->job->getLogalyzerCountErrors <= 10) { + foreach ($this->warningPatterns['regex'] as $key) { + for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountWarnings(); } } - } - if($this->job->getLogalyzerCountErrors <= 10) { - foreach ($this->errorPatterns as $key) { - if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { - // $key is regex. - for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountErrors(); - } - } else { - for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountErrors(); - } + foreach ($this->warningPatterns['string'] as $key) { + for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountWarnings(); + } + } + foreach ($this->errorPatterns['regex'] as $key) { + for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountErrors(); + } + } + foreach ($this->errorPatterns['regex'] as $key) { + for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { + // TODO implement increment + $this->job->incrementLogalyzerCountErrors(); } } } } - + private function assignPatterns(){ + $this->data = json_decode($this->job->getLogalyzerPattern(), true); + $this->warningPatterns = $this->data['warningPattern']; + $this->errorPatterns = $this->data['errorPattern']; + } + private function savePatterns(){ + $this->data['warningPattern'] = $this->warningPatterns; + $this->data['errorPattern'] = $this->errorPatterns; + $this->job->setLogalyzerPattern(json_encode($this->data)); + } /** * @param string $identifier add $key as warning or error? * @param string $key name of new keyword * @return void */ - public function addKey(string $identifier, string $key) { - if ($identifier == 'warning') { - $warningArray = json_decode($this->system->getLogalyzerWarningPatterns); - $warningArray[] = $key; - $warningArray = json_encode($warningArray); - $this->system->setLogalyzerWarningPatterns($warningArray); + public function addKey(string $identifier, string $isRegex, string $key) { + if ($identifier == 'warning') { + if($isRegex) { + $this->warningPatterns['regex'][] = $key; + } + else { + $this->warningPatterns['string'][] = $key; + } } else if ($identifier == 'error') { - $errorArray = json_decode($this->system->getLogalyzerErrorPatterns); - $errorArray[] = $key; - $errorArray = json_encode($errorArray); - $this->system->setLogalyzerWarningPatterns($errorArray); + if($isRegex) { + $this->errorPatterns['regex'][] = $key; + } + else { + $this->errorPatterns['string'][] = $key; + } } else { echo "identifier not recognized."; } + $this->savePatterns(); } + /** - * @param string $identifier remove $key from warning or error + * @param string $identifier is $key a warning or error? + * @param bool $isRegex * @param string $key name of keyword to be deleted * @return void */ - public function removeKey(string $identifier, string $key) { + public function removeKey(string $identifier, bool $isRegex, string $key) { if ($identifier == 'warning') { - $warningArray = json_decode($this->system->getLogalyzerWarningPatterns); - if (($index = array_search($key, $warningArray)) !== false) { - unset($warningArray[$index]); - $this->system->setLogalyzerWarningPatterns(json_encode($warningArray)); + if($isRegex) { + if (($index = array_search($key, $this->warningPatterns['regex'])) !== false) { + unset($this->warningPatterns['regex'][$index]); + } + } + else { + if (($index = array_search($key, $this->warningPatterns['string'])) !== false) { + unset($this->warningPatterns['string'][$index]); + } } } else if ($identifier == 'error') { - $errorArray = json_decode($this->system->getLogalyzerPatterns); - if (($index = array_search($key, $errorArray)) !== false) { - unset($errorArray[$index]); - $this->system->setLogalyzerErrorPatterns(json_encode($errorArray)); + if($isRegex) { + if (($index = array_search($key, $this->errorPatterns['regex'])) !== false) { + unset($this->errorPatterns['regex'][$index]); + } + } + else { + if (($index = array_search($key, $this->errorPatterns['string'])) !== false) { + unset($this->errorPatterns['string'][$index]); + } } - } else { echo "identifier not recognized."; } + $this->savePatterns(); } /** * Allows calculating the hash before any operations are done From b69362644477e59c5cd76e4a19322a117725758b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 14:24:12 +0200 Subject: [PATCH 142/644] backend 'finished' --- libraries/logalyzer.php | 114 +++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 65 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index dba6a7532b..cbb999382a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -1,5 +1,7 @@ job = $job; - $this->system = new System($this->job->getSystemId()); + // TODO get proper system requires testing + $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); $this->assignPatterns(); } @@ -58,22 +60,19 @@ public function examineEntireLog() // Count occurrences of all defined keywords. $warningCount = 0; $errorCount = 0; - foreach ($this->warningPatterns as $array) { - foreach ($array as $key) { - if ($key === 'regex') { - $warningCount += $this->countLogOccurances($key, $this->log, true); - } else { - $warningCount += $this->countLogOccurances($key, $this->log); - } + + while ($warningCount <= 10 && $errorCount <= 10) { + foreach ($this->warningPatterns['regex'] as $key) { + $warningCount += $this->countLogOccurances($key, $this->log, true); } - } - foreach ($this->errorPatterns as $array) { - foreach ($array as $key) { - if ($key === 'regex') { - $errorCount += $this->countLogOccurances($key, $this->log, true); - } else { - $errorCount += $this->countLogOccurances($key, $this->log); - } + foreach ($this->warningPatterns['string'] as $key) { + $warningCount += $this->countLogOccurances($key, $this->log); + } + foreach ($this->errorPatterns['regex'] as $key) { + $errorCount += $this->countLogOccurances($key, $this->log, true); + } + foreach ($this->errorPatterns['string'] as $key) { + $errorCount += $this->countLogOccurances($key, $this->log); } } $this->job->setLogalyzerCountWarnings($warningCount); @@ -102,7 +101,7 @@ public function examineLogLine($logLine) { $this->job->incrementLogalyzerCountErrors(); } } - foreach ($this->errorPatterns['regex'] as $key) { + foreach ($this->errorPatterns['string'] as $key) { for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { // TODO implement increment $this->job->incrementLogalyzerCountErrors(); @@ -111,73 +110,60 @@ public function examineLogLine($logLine) { } } private function assignPatterns(){ - $this->data = json_decode($this->job->getLogalyzerPattern(), true); - $this->warningPatterns = $this->data['warningPattern']; - $this->errorPatterns = $this->data['errorPattern']; + $this->data = json_decode($this->system->getLogalyzerPatterns(), true); + if($this->data != null) { + $this->warningPatterns = $this->data['warningPattern']; + $this->errorPatterns = $this->data['errorPattern']; + } + else { + $this->data['warningPattern'] = ['string' => [], 'regex' => []]; + $this->data['errorPattern'] = ['string' => [], 'regex' => []]; + $this->warningPatterns['string'] = []; + $this->warningPatterns['regex'] = []; + $this->errorPatterns['string'] = []; + $this->errorPatterns['regex'] = []; + } } private function savePatterns(){ $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; - $this->job->setLogalyzerPattern(json_encode($this->data)); + $this->system->setLogalyzerPatterns(json_encode($this->data)); } /** - * @param string $identifier add $key as warning or error? - * @param string $key name of new keyword + * @param string $identifier 'log level' + * @param string $type 'string' or 'regex' + * @param string $key new key * @return void */ - public function addKey(string $identifier, string $isRegex, string $key) { - + public function addKey(string $identifier, string $type, string $key) { + // Avoid changing local array for concurrency? Could save the new $key in a copy and save that copy if ($identifier == 'warning') { - if($isRegex) { - $this->warningPatterns['regex'][] = $key; - } - else { - $this->warningPatterns['string'][] = $key; - } + $this->warningPatterns[$type][] = $key; } - else if ($identifier == 'error') { - if($isRegex) { - $this->errorPatterns['regex'][] = $key; - } - else { - $this->errorPatterns['string'][] = $key; - } + elseif ($identifier == 'error') { + $this->errorPatterns[$type][] = $key; } else { - echo "identifier not recognized."; + echo "Error in identifier or isRegex inside logalyzer."; } $this->savePatterns(); } /** * @param string $identifier is $key a warning or error? - * @param bool $isRegex - * @param string $key name of keyword to be deleted + * @param string $type 'string' or 'regex' + * @param string $key key to delete * @return void */ - public function removeKey(string $identifier, bool $isRegex, string $key) { + public function removeKey(string $identifier, string $type, string $key) { if ($identifier == 'warning') { - if($isRegex) { - if (($index = array_search($key, $this->warningPatterns['regex'])) !== false) { - unset($this->warningPatterns['regex'][$index]); - } - } - else { - if (($index = array_search($key, $this->warningPatterns['string'])) !== false) { - unset($this->warningPatterns['string'][$index]); - } + if (($index = array_search($key, $this->warningPatterns[$type])) !== false) { + unset($this->warningPatterns[$type][$index]); } } else if ($identifier == 'error') { - if($isRegex) { - if (($index = array_search($key, $this->errorPatterns['regex'])) !== false) { - unset($this->errorPatterns['regex'][$index]); - } - } - else { - if (($index = array_search($key, $this->errorPatterns['string'])) !== false) { - unset($this->errorPatterns['string'][$index]); - } + if (($index = array_search($key, $this->errorPatterns[$type])) !== false) { + unset($this->errorPatterns[$type][$index]); } } else { @@ -190,9 +176,7 @@ public function removeKey(string $identifier, bool $isRegex, string $key) { * @return string */ function calculateHash() { - $mergedArray = array_merge($this->errorPatterns, $this->warningPatterns); - $mergedJson = json_encode($mergedArray); - return hash('sha1', $mergedJson); + return hash('sha1', json_encode($this->data)); } /** From 547f10675ebaa4fbce5c68c95bb1919c0d5790e6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 14:24:19 +0200 Subject: [PATCH 143/644] backend 'finished' --- libraries/logalyzer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index cbb999382a..54ac43be42 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -19,7 +19,6 @@ class Logalyzer_Library */ public function __construct($job) { $this->job = $job; - // TODO get proper system requires testing $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); $this->assignPatterns(); } From f91d1671532440b802f29611dd1ee41d3860d66f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 14:25:47 +0200 Subject: [PATCH 144/644] backend 'finished' --- libraries/logalyzer.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 54ac43be42..484c3284d1 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -5,8 +5,7 @@ /** * Analyze the log of a Chronos job using predefined keywords */ -class Logalyzer_Library -{ +class Logalyzer_Library { private $job; private $system; private $log; @@ -29,8 +28,7 @@ public function __construct($job) { * @param bool $regex * @return int */ - public function countLogOccurances(string $keyword, string $target, bool $regex = false) - { + public function countLogOccurances(string $keyword, string $target, bool $regex = false) { if ($regex) { return preg_match_all($keyword, $target); } else { @@ -38,14 +36,12 @@ public function countLogOccurances(string $keyword, string $target, bool $regex } } - private function checkHashDifference($current) - { + private function checkHashDifference($current) { // TODO check if returns the right value return !($this->job->getLogalyzerHash() == $current); } - public function examineEntireLog() - { + public function examineEntireLog() { $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId() . '.log'; $log = Util::readFileContents($path); if ($log === false) { @@ -108,7 +104,7 @@ public function examineLogLine($logLine) { } } } - private function assignPatterns(){ + private function assignPatterns() { $this->data = json_decode($this->system->getLogalyzerPatterns(), true); if($this->data != null) { $this->warningPatterns = $this->data['warningPattern']; @@ -123,7 +119,7 @@ private function assignPatterns(){ $this->errorPatterns['regex'] = []; } } - private function savePatterns(){ + private function savePatterns() { $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; $this->system->setLogalyzerPatterns(json_encode($this->data)); @@ -193,4 +189,4 @@ function setHash($value) { function getHash() { return $this->job->getLogalyzerHash(); } -} \ No newline at end of file +} From 430c0c4e70b55a385150bef0ee3ae6f68ad2cedb Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 14:29:16 +0200 Subject: [PATCH 145/644] backend 'finished' --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 484c3284d1..4cf48326f1 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -36,9 +36,9 @@ public function countLogOccurances(string $keyword, string $target, bool $regex } } - private function checkHashDifference($current) { + private function checkHashDifference() { // TODO check if returns the right value - return !($this->job->getLogalyzerHash() == $current); + return !($this->job->getLogalyzerHash() == hash('sha1', $this->data)); } public function examineEntireLog() { From fb82300a8b36b9a026bc4a5822fd1d2999f5b235 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 14:31:58 +0200 Subject: [PATCH 146/644] backend 'finished' --- views/evaluation/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 0250c0e91c..b54d04fa69 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -210,9 +210,9 @@ function submitData() { getInternalId(); ?> getDescription(); ?> - getLogalyzerCountErrors() > 0) { ?> + getLogalyzerErrorCount() > 0) { ?> - getLogalyzerCountWarnings() > 0) { ?> + getLogalyzerWarningCount() > 0) { ?> From f0628cf1e1d767345758b2519543bc57238170d5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 21:10:09 +0200 Subject: [PATCH 147/644] backend 'finished' --- controllers/admin.php | 64 ++++++++++++++++++++---------- libraries/logalyzer.php | 87 +++++++++++++++++++++++++++++------------ views/admin/system.php | 16 ++++---- 3 files changed, 115 insertions(+), 52 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 40907bed7f..10c62e6db5 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -454,32 +454,53 @@ public function system() { $systemLib = new System($system->getId()); $systemLib->deleteResults($resultId); } else if (!empty($this->post['newWarning'])) { - $key = $this->post['newWarningKeyword']; + $key = $this->post['newWarningPattern']; if ($key != "") { - $systemLib = new System($system->getId()); - // TODO add and delete warning error keywords - //$systemLib->get; + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(substr($key, 0, 1) === '/') + // Is regex. Php version 8 introduces starts_with() + $logalyzer->addKey('warning', 'regex', $key); + else { + $logalyzer->addKey('warning', 'string', $key); + } } } else if (!empty($this->post['newError'])) { - $key = $this->post['newErrorKeyword']; + $key = $this->post['newErrorPattern']; if ($key != "") { - $systemLib = new System($system->getId()); - // TODO add and delete warning error keywords - //$systemLib->get; + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(substr($key, 0, 1) === '/') + $logalyzer->addKey('error', 'regex', $key); + else { + $logalyzer->addKey('error', 'string', $key); + } } - } else if (!empty($this->get['deleteWarningKeyword'])) { - $key = $this->get['deleteWarningKeyword']; + } else if (!empty($this->get['deleteWarningPattern'])) { + $key = $this->post['deleteWarningPattern']; if ($key != "") { - $systemLib = new System($system->getId()); - // TODO add and delete warning error keywords - //$systemLib->get; + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(substr($key, 0, 1) === '/') + $logalyzer->removeKey('warning', 'regex', $key); + else { + $logalyzer->removeKey('warning', 'string', $key); + } } - } else if (!empty($this->get['deleteErrorKeyword'])) { - $key = $this->get['deleteErrorKeyword']; + } else if (!empty($this->get['deleteErrorPattern'])) { + $key = $this->post['deleteErrorPattern']; if ($key != "") { - $systemLib = new System($system->getId()); - // TODO add and delete warning error keywords - //$systemLib->get; + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(substr($key, 0, 1) === '/') + $logalyzer->removeKey('error', 'regex', $key); + else { + $logalyzer->removeKey('error', 'string', $key); + } } } else if (!empty($this->get['logo']) && $this->get['logo'] == 'upload') { // check for error values @@ -527,8 +548,11 @@ public function system() { $this->view->assign('auth', Auth_Library::getInstance()); // TODO implement back end and assign error and warning key arrays to view - $this->view->assign('errorKeys', ['error', 'failed']); - $this->view->assign('warningKeys', ['warning', '!warn']); + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + $this->view->assign('errorKeys', $logalyzer->getPatterns("error")); + $this->view->assign('warningKeys', $logalyzer->getPatterns("warning")); } else { throw new Exception("No id provided!"); } diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4cf48326f1..ba4e5948d1 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -16,12 +16,25 @@ class Logalyzer_Library { /** * @throws Exception */ - public function __construct($job) { + public function __construct($job = null) { + $this->job = $job; + if($this->job != null) { + $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); + $this->loadPatterns(); + } + } + public function getJob() { + return $this->job; + } + public function getSystem() { + return $this->system; + } + public function setSystem($system) { + $this->system = $system; + } + public function setJob($job) { $this->job = $job; - $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); - $this->assignPatterns(); } - /** * @param string $keyword * @param string $target @@ -104,7 +117,24 @@ public function examineLogLine($logLine) { } } } - private function assignPatterns() { + public function getPatterns($identifier) { + $this->data = json_decode($this->system->getLogalyzerPatterns(), true); + if($this->data != null) { + if($identifier === 'warning') { + return $this->data['warningPattern']; + } + elseif($identifier === 'error') { + return $this->data['errorPattern']; + } + else { + return []; + } + } + else { + return []; + } + } + private function loadPatterns() { $this->data = json_decode($this->system->getLogalyzerPatterns(), true); if($this->data != null) { $this->warningPatterns = $this->data['warningPattern']; @@ -132,16 +162,19 @@ private function savePatterns() { */ public function addKey(string $identifier, string $type, string $key) { // Avoid changing local array for concurrency? Could save the new $key in a copy and save that copy - if ($identifier == 'warning') { - $this->warningPatterns[$type][] = $key; - } - elseif ($identifier == 'error') { - $this->errorPatterns[$type][] = $key; + if($this->system == null) { + echo 'System not defined\n'; } else { - echo "Error in identifier or isRegex inside logalyzer."; + if ($identifier == 'warning') { + $this->warningPatterns[$type][] = $key; + } elseif ($identifier == 'error') { + $this->errorPatterns[$type][] = $key; + } else { + echo "Error in identifier or isRegex inside logalyzer."; + } + $this->savePatterns(); } - $this->savePatterns(); } /** @@ -150,21 +183,27 @@ public function addKey(string $identifier, string $type, string $key) { * @param string $key key to delete * @return void */ - public function removeKey(string $identifier, string $type, string $key) { - if ($identifier == 'warning') { - if (($index = array_search($key, $this->warningPatterns[$type])) !== false) { - unset($this->warningPatterns[$type][$index]); - } - } - else if ($identifier == 'error') { - if (($index = array_search($key, $this->errorPatterns[$type])) !== false) { - unset($this->errorPatterns[$type][$index]); - } + public function removeKey(string $identifier, string $type, string $key) + { + if ($this->system == null) { + echo 'System not defined\n'; } else { - echo "identifier not recognized."; + if ($identifier == 'warning') { + if (($index = array_search($key, $this->warningPatterns[$type])) !== false) { + unset($this->warningPatterns[$type][$index]); + } + } + elseif ($identifier == 'error') { + if (($index = array_search($key, $this->errorPatterns[$type])) !== false) { + unset($this->errorPatterns[$type][$index]); + } + } + else { + echo "identifier not recognized."; + } + $this->savePatterns(); } - $this->savePatterns(); } /** * Allows calculating the hash before any operations are done diff --git a/views/admin/system.php b/views/admin/system.php index 7b05e55990..801320b307 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -469,21 +469,21 @@
- +

- +
- - + + Delete @@ -500,22 +500,22 @@
- - + +

- +
- + Delete From f2b6d6f2ae67d208bcc44a3fa947127af5e02bdb Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 21:11:09 +0200 Subject: [PATCH 148/644] updated System.class.php to not require a pattern when instantiating a system object --- libraries/dba/models/System.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/models/System.class.php b/libraries/dba/models/System.class.php index 3d60c42e05..6fb1285b8c 100644 --- a/libraries/dba/models/System.class.php +++ b/libraries/dba/models/System.class.php @@ -54,7 +54,7 @@ function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranc $this->created = $created; $this->lastEdit = $lastEdit; $this->isArchived = $isArchived; - $this->logalyzerPatterns = $logalyzerPatterns; + $this->logalyzerPatterns = ""; } function getKeyValueDict() { From 3ccd1c2dd0097f5494b66890106702f12d25f76c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 21:12:58 +0200 Subject: [PATCH 149/644] updated System.class.php to not require a pattern when instantiating a system object --- libraries/dba/models/System.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/models/System.class.php b/libraries/dba/models/System.class.php index 6fb1285b8c..384576ad36 100644 --- a/libraries/dba/models/System.class.php +++ b/libraries/dba/models/System.class.php @@ -41,7 +41,7 @@ class System extends AbstractModel { private $isArchived; private $logalyzerPatterns; - function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns) { + function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived) { $this->systemId = $systemId; $this->name = $name; $this->description = $description; From f49b031da3ae4d7de2820883cda56b5141d20795 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 21:14:14 +0200 Subject: [PATCH 150/644] updated System.class.php to not require a pattern when instantiating a system object --- libraries/dba/models/System.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/models/System.class.php b/libraries/dba/models/System.class.php index 384576ad36..6056a291bf 100644 --- a/libraries/dba/models/System.class.php +++ b/libraries/dba/models/System.class.php @@ -41,7 +41,7 @@ class System extends AbstractModel { private $isArchived; private $logalyzerPatterns; - function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived) { + function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns=null) { $this->systemId = $systemId; $this->name = $name; $this->description = $description; @@ -54,7 +54,7 @@ function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranc $this->created = $created; $this->lastEdit = $lastEdit; $this->isArchived = $isArchived; - $this->logalyzerPatterns = ""; + $this->logalyzerPatterns = $logalyzerPatterns; } function getKeyValueDict() { From 69f3e97fb08bfe985c72d27879c72376bd50d9cf Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 19 Jul 2024 21:23:57 +0200 Subject: [PATCH 151/644] updated Job.class.php to not require a logalyzer Parameters when instantiating a system object --- libraries/dba/models/Job.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index bc486176e3..8670d3a734 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -47,7 +47,7 @@ class Job extends AbstractModel { private $logalyzerErrorCount; private $logalyzerHash; - function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $logalyzerWarningCount, $logalyzerErrorCount, $logalyzerHash) { + function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $logalyzerWarningCount = 0, $logalyzerErrorCount = 0, $logalyzerHash = '') { $this->jobId = $jobId; $this->userId = $userId; $this->description = $description; From 64c1f233db0557af2d7791916581422a98c9371f Mon Sep 17 00:00:00 2001 From: Marco Vogt Date: Sun, 21 Jul 2024 14:40:33 +0200 Subject: [PATCH 152/644] Add missing backticks in SystemFactory --- libraries/dba/models/SystemFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/models/SystemFactory.class.php b/libraries/dba/models/SystemFactory.class.php index 8d4e47f8cc..e9fd90fe95 100644 --- a/libraries/dba/models/SystemFactory.class.php +++ b/libraries/dba/models/SystemFactory.class.php @@ -32,7 +32,7 @@ function getModelName() { } function getModelTable() { - return "System"; + return "`System`"; } function isCachable() { From f483164b1d5e296266861f45c67d1fd3872bc975 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:17:58 +0200 Subject: [PATCH 153/644] fixes to finalize implementation --- libraries/logalyzer.php | 44 ++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index ba4e5948d1..dc8b0548b8 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -117,21 +117,34 @@ public function examineLogLine($logLine) { } } } + private function createBasicPattern() { + $this->data['warningPattern'] = ['string' => [], 'regex' => []]; + $this->data['errorPattern'] = ['string' => [], 'regex' => []]; + $this->warningPatterns['string'] = []; + $this->warningPatterns['regex'] = []; + $this->errorPatterns['string'] = []; + $this->errorPatterns['regex'] = []; + $this->savePatterns(); + } public function getPatterns($identifier) { - $this->data = json_decode($this->system->getLogalyzerPatterns(), true); - if($this->data != null) { - if($identifier === 'warning') { - return $this->data['warningPattern']; - } - elseif($identifier === 'error') { - return $this->data['errorPattern']; - } - else { - return []; - } + if($this->system->getLogalyzerPatterns() === null) { + // create basic pattern + $this->createBasicPattern(); + return $this->getPatterns($identifier); } else { - return []; + $this->data = json_decode($this->system->getLogalyzerPatterns(), true); + if ($this->data != null) { + if ($identifier === 'warning') { + return $this->data['warningPattern']; + } elseif ($identifier === 'error') { + return $this->data['errorPattern']; + } else { + return []; + } + } else { + return []; + } } } private function loadPatterns() { @@ -141,12 +154,7 @@ private function loadPatterns() { $this->errorPatterns = $this->data['errorPattern']; } else { - $this->data['warningPattern'] = ['string' => [], 'regex' => []]; - $this->data['errorPattern'] = ['string' => [], 'regex' => []]; - $this->warningPatterns['string'] = []; - $this->warningPatterns['regex'] = []; - $this->errorPatterns['string'] = []; - $this->errorPatterns['regex'] = []; + $this->createBasicPattern(); } } private function savePatterns() { From 9e2f74e2a27f9ffd1a62b1d7ffcc6eeb3bf0cc88 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:19:30 +0200 Subject: [PATCH 154/644] fixes to finalize implementation --- controllers/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 10c62e6db5..346a2573ec 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -548,9 +548,9 @@ public function system() { $this->view->assign('auth', Auth_Library::getInstance()); // TODO implement back end and assign error and warning key arrays to view - $system = Factory::getSystemFactory()->get($this->post['id']); + //$system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); + $logalyzer->setSystem($systemLib); $this->view->assign('errorKeys', $logalyzer->getPatterns("error")); $this->view->assign('warningKeys', $logalyzer->getPatterns("warning")); } else { From 24bb3037573a0a3af382ca0fffbbdcba13aa0429 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:23:09 +0200 Subject: [PATCH 155/644] fixes to finalize implementation --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index dc8b0548b8..ffcbaf0964 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -19,7 +19,7 @@ class Logalyzer_Library { public function __construct($job = null) { $this->job = $job; if($this->job != null) { - $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); + $this->system = new System($this->job->getSystemId()); $this->loadPatterns(); } } From d85e7d8f6cc68deedd168d07660e0ba2f7a743e8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:29:44 +0200 Subject: [PATCH 156/644] fixes to finalize implementation --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index ffcbaf0964..dc8b0548b8 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -19,7 +19,7 @@ class Logalyzer_Library { public function __construct($job = null) { $this->job = $job; if($this->job != null) { - $this->system = new System($this->job->getSystemId()); + $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); $this->loadPatterns(); } } From 6e4a97d62a184480a053996bf79c2d8712e93f32 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:33:37 +0200 Subject: [PATCH 157/644] fixes to finalize implementation --- views/admin/system.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 801320b307..8084447b49 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -477,7 +477,8 @@
- +
@@ -490,7 +491,8 @@
- +

@@ -509,7 +511,8 @@
- +
@@ -522,7 +525,8 @@
- +
From 3e8590d3e94df678ed3d662e4a6ca7f84a96bae1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:37:42 +0200 Subject: [PATCH 158/644] fixes to finalize implementation --- controllers/admin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 346a2573ec..a181f7df7a 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -550,7 +550,8 @@ public function system() { // TODO implement back end and assign error and warning key arrays to view //$system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($systemLib); + //$system = Factory::getSystemFactory()->get($this->job->getSystemId()) + $logalyzer->setSystem($system); $this->view->assign('errorKeys', $logalyzer->getPatterns("error")); $this->view->assign('warningKeys', $logalyzer->getPatterns("warning")); } else { From 3333f6af13832c0047a717ac3a1bd3c90ab55bd4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:41:01 +0200 Subject: [PATCH 159/644] fixes to finalize implementation --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 8084447b49..be442a5dfc 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -477,7 +477,7 @@
-
@@ -511,7 +511,7 @@
-
From ac9f483a8ebf99c1e8c2a8097b8f51b601d538f1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:42:09 +0200 Subject: [PATCH 160/644] fixes to finalize implementation --- views/admin/system.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/views/admin/system.php b/views/admin/system.php index be442a5dfc..c7fc815f90 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -478,6 +478,7 @@
@@ -512,6 +513,7 @@
From 2923034cf6bf8a8281eff14f23b94ecd4a07b223 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:43:39 +0200 Subject: [PATCH 161/644] fixes to finalize implementation --- views/admin/system.php | 58 +++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index c7fc815f90..53eb677372 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -477,23 +477,20 @@
- -
-
- - - - - - Delete - - -
+ +
+
+ + + + + + Delete + +
- +
+

@@ -512,23 +509,20 @@
- -
-
- - - - - - Delete - - -
+ +
+
+ + + + + + Delete + +
- +
+
From 68a001644fbd5393719d75213c2848446a3371ba Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:48:57 +0200 Subject: [PATCH 162/644] fixes to finalize implementation --- libraries/logalyzer.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index dc8b0548b8..b9ecebf72e 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -51,7 +51,7 @@ public function countLogOccurances(string $keyword, string $target, bool $regex private function checkHashDifference() { // TODO check if returns the right value - return !($this->job->getLogalyzerHash() == hash('sha1', $this->data)); + return !($this->job->getLogalyzerHash() === hash('sha1', $this->data)); } public function examineEntireLog() { @@ -127,10 +127,16 @@ private function createBasicPattern() { $this->savePatterns(); } public function getPatterns($identifier) { - if($this->system->getLogalyzerPatterns() === null) { + if($this->system->getLogalyzerPatterns() == null) { // create basic pattern $this->createBasicPattern(); - return $this->getPatterns($identifier); + if ($identifier === 'warning') { + return $this->data['warningPattern']; + } elseif ($identifier === 'error') { + return $this->data['errorPattern']; + } else { + return []; + } } else { $this->data = json_decode($this->system->getLogalyzerPatterns(), true); From 1e24a6664aaf6fc0b9dfdde5779a8ad010d5d560 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:50:36 +0200 Subject: [PATCH 163/644] fixes to finalize implementation --- libraries/logalyzer.php | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b9ecebf72e..c43b6bd80f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -117,19 +117,23 @@ public function examineLogLine($logLine) { } } } - private function createBasicPattern() { + private function createBasicPatterns() { $this->data['warningPattern'] = ['string' => [], 'regex' => []]; $this->data['errorPattern'] = ['string' => [], 'regex' => []]; $this->warningPatterns['string'] = []; $this->warningPatterns['regex'] = []; $this->errorPatterns['string'] = []; $this->errorPatterns['regex'] = []; - $this->savePatterns(); + //$this->savePatterns(); } public function getPatterns($identifier) { if($this->system->getLogalyzerPatterns() == null) { // create basic pattern - $this->createBasicPattern(); + $this->createBasicPatterns(); + $this->savePatterns(); + } + $this->data = json_decode($this->system->getLogalyzerPatterns(), true); + if ($this->data != null) { if ($identifier === 'warning') { return $this->data['warningPattern']; } elseif ($identifier === 'error') { @@ -137,20 +141,8 @@ public function getPatterns($identifier) { } else { return []; } - } - else { - $this->data = json_decode($this->system->getLogalyzerPatterns(), true); - if ($this->data != null) { - if ($identifier === 'warning') { - return $this->data['warningPattern']; - } elseif ($identifier === 'error') { - return $this->data['errorPattern']; - } else { - return []; - } - } else { - return []; - } + } else { + return []; } } private function loadPatterns() { @@ -160,7 +152,8 @@ private function loadPatterns() { $this->errorPatterns = $this->data['errorPattern']; } else { - $this->createBasicPattern(); + $this->createBasicPatterns(); + $this->savePatterns(); } } private function savePatterns() { From e3c0f5d2871eaa282e4b98cf821c5b265d3f78a9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:54:20 +0200 Subject: [PATCH 164/644] fixes to finalize implementation --- controllers/admin.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index a181f7df7a..657005c19b 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -547,13 +547,13 @@ public function system() { $this->view->assign('history', Systems_Library::getHistory($system->getId())); $this->view->assign('auth', Auth_Library::getInstance()); - // TODO implement back end and assign error and warning key arrays to view - //$system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); - //$system = Factory::getSystemFactory()->get($this->job->getSystemId()) $logalyzer->setSystem($system); - $this->view->assign('errorKeys', $logalyzer->getPatterns("error")); - $this->view->assign('warningKeys', $logalyzer->getPatterns("warning")); + $errors = $logalyzer->getPatterns("error"); + $warnings = $logalyzer->getPatterns("warning"); + echo $errors; + $this->view->assign('errorKeys', ['error']); + $this->view->assign('warningKeys', ['warning']); } else { throw new Exception("No id provided!"); } From f8dd6f896fd7a4f68038f85691eb7f4b53dbde1b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:55:08 +0200 Subject: [PATCH 165/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 657005c19b..15e0f84498 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -551,7 +551,7 @@ public function system() { $logalyzer->setSystem($system); $errors = $logalyzer->getPatterns("error"); $warnings = $logalyzer->getPatterns("warning"); - echo $errors; + print_r($errors); $this->view->assign('errorKeys', ['error']); $this->view->assign('warningKeys', ['warning']); } else { From c7d1b39d8b041ade6a413ddc9a0ebfc09e47559d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:57:24 +0200 Subject: [PATCH 166/644] fixes to finalize implementation --- views/admin/system.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 53eb677372..486d448dcb 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -477,7 +477,8 @@
- +
@@ -490,7 +491,8 @@
- +

@@ -509,7 +511,8 @@
- +
@@ -522,7 +525,8 @@
- +
From bb3621baaefa7158ebb745dbc42b19051f46e95a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 15:58:24 +0200 Subject: [PATCH 167/644] fixes to finalize implementation --- views/admin/system.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 486d448dcb..0befa4a508 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -477,8 +477,8 @@
- + $array) { + foreach ($array as $key) {?>
@@ -511,8 +511,8 @@
- + $array) { + foreach ($array as $key) {?>
From cb1ee07688a7ad2bff5dfd63c71a57a2f2d534b1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:00:14 +0200 Subject: [PATCH 168/644] fixes to finalize implementation --- controllers/admin.php | 2 +- views/admin/system.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 15e0f84498..8d42405d57 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -551,7 +551,7 @@ public function system() { $logalyzer->setSystem($system); $errors = $logalyzer->getPatterns("error"); $warnings = $logalyzer->getPatterns("warning"); - print_r($errors); + //print_r($errors); $this->view->assign('errorKeys', ['error']); $this->view->assign('warningKeys', ['warning']); } else { diff --git a/views/admin/system.php b/views/admin/system.php index 0befa4a508..1ee42a3ff8 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -478,6 +478,7 @@
$array) { + print_r($array); foreach ($array as $key) {?>
From a74b07f7ae3170b807a1961c68060196faa13297 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:03:10 +0200 Subject: [PATCH 169/644] fixes to finalize implementation --- controllers/admin.php | 2 +- views/admin/system.php | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 8d42405d57..15e0f84498 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -551,7 +551,7 @@ public function system() { $logalyzer->setSystem($system); $errors = $logalyzer->getPatterns("error"); $warnings = $logalyzer->getPatterns("warning"); - //print_r($errors); + print_r($errors); $this->view->assign('errorKeys', ['error']); $this->view->assign('warningKeys', ['warning']); } else { diff --git a/views/admin/system.php b/views/admin/system.php index 1ee42a3ff8..2503a06a29 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -479,20 +479,21 @@ $array) { print_r($array); - foreach ($array as $key) {?> -
-
- - - - - - Delete - - -
-
- +
+
+ + + + + + Delete + + +
+
+

From 4686c402a79bf298409a35ee74ff4e823eef74c7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:09:11 +0200 Subject: [PATCH 170/644] fixes to finalize implementation --- views/admin/system.php | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 2503a06a29..a86eeb3f14 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -477,23 +477,26 @@
- $array) { - print_r($array); - foreach ($array as $key) { - print_r($array); ?> -
-
- - - - - - Delete - - -
-
- $array) { + if (is_array($array)) { + foreach ($array as $key) { + print_r($array); ?> +
+
+ + + + + + Delete + + +
+
+

From 7c7324da68f3d8804b8cc5da5fec3e27984f287b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:13:39 +0200 Subject: [PATCH 171/644] fixes to finalize implementation --- controllers/admin.php | 1 - views/admin/system.php | 27 ++++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 15e0f84498..8ada4cd50d 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -551,7 +551,6 @@ public function system() { $logalyzer->setSystem($system); $errors = $logalyzer->getPatterns("error"); $warnings = $logalyzer->getPatterns("warning"); - print_r($errors); $this->view->assign('errorKeys', ['error']); $this->view->assign('warningKeys', ['warning']); } else { diff --git a/views/admin/system.php b/views/admin/system.php index a86eeb3f14..88aad671c7 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -517,20 +517,21 @@
$array) { - foreach ($array as $key) {?> -
-
- - - - - - Delete - - + echo gettype($array); + foreach ($array as $key) {?> +
+
+ + + + + + Delete + + +
-
-
From c5733109f137a112879dd845a3f064f65288e522 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:14:03 +0200 Subject: [PATCH 172/644] fixes to finalize implementation --- views/admin/system.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/admin/system.php b/views/admin/system.php index 88aad671c7..6aec6bf358 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -518,6 +518,7 @@ $array) { echo gettype($array); + echo $array; foreach ($array as $key) {?>
From e9e8eb4e9f5676b53f38bd34e8e55087d11dd998 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:14:36 +0200 Subject: [PATCH 173/644] fixes to finalize implementation --- controllers/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 8ada4cd50d..52de1e805f 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -551,8 +551,8 @@ public function system() { $logalyzer->setSystem($system); $errors = $logalyzer->getPatterns("error"); $warnings = $logalyzer->getPatterns("warning"); - $this->view->assign('errorKeys', ['error']); - $this->view->assign('warningKeys', ['warning']); + $this->view->assign('errorKeys', $errors); + $this->view->assign('warningKeys', $warnings); } else { throw new Exception("No id provided!"); } From 74407f1c84939d8ca691736997d504b1e5fb5e4d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:15:43 +0200 Subject: [PATCH 174/644] fixes to finalize implementation --- views/admin/system.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 6aec6bf358..9bdc7b0b8d 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -517,8 +517,6 @@
$array) { - echo gettype($array); - echo $array; foreach ($array as $key) {?>
From 1100f217672c854972cf67615b15e7559762b9ce Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:16:19 +0200 Subject: [PATCH 175/644] fixes to finalize implementation --- views/admin/system.php | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 9bdc7b0b8d..ca9a6cfb18 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -477,26 +477,22 @@
- $array) { - if (is_array($array)) { - foreach ($array as $key) { - print_r($array); ?> -
-
- - - - - - Delete - - -
-
- $array) { + foreach ($array as $key) { + print_r($array); ?> +
+
+ + + + + + Delete + + +
+
+

From 9af71b3480703111dd425e056cbc91c90f1f1771 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:19:39 +0200 Subject: [PATCH 176/644] fixes to finalize implementation --- controllers/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin.php b/controllers/admin.php index 52de1e805f..95d1f38363 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -469,6 +469,7 @@ public function system() { } else if (!empty($this->post['newError'])) { $key = $this->post['newErrorPattern']; if ($key != "") { + echo $key; $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); From 337767b63caf9abb43ed046a30489c221162fd0b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:20:30 +0200 Subject: [PATCH 177/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 95d1f38363..41a69d3ec6 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -468,8 +468,8 @@ public function system() { } } else if (!empty($this->post['newError'])) { $key = $this->post['newErrorPattern']; + echo $key; if ($key != "") { - echo $key; $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); From 185aef9f8b589039e759ac9e3b3fb7af59da814e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:22:46 +0200 Subject: [PATCH 178/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 41a69d3ec6..eb4589be5b 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -466,7 +466,7 @@ public function system() { $logalyzer->addKey('warning', 'string', $key); } } - } else if (!empty($this->post['newError'])) { + } else if (!empty($this->post['newErrorPattern'])) { $key = $this->post['newErrorPattern']; echo $key; if ($key != "") { From 9c77266ec804abcb21f41b18a4a32a20c66414e1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:25:11 +0200 Subject: [PATCH 179/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index eb4589be5b..97fde11ecb 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -466,7 +466,7 @@ public function system() { $logalyzer->addKey('warning', 'string', $key); } } - } else if (!empty($this->post['newErrorPattern'])) { + } else if ($this->post['group'] == 'newError') { $key = $this->post['newErrorPattern']; echo $key; if ($key != "") { From 2dba420efc3e081206838dba7b539e525dcce70e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:29:49 +0200 Subject: [PATCH 180/644] fixes to finalize implementation --- controllers/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 97fde11ecb..6641656855 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -466,7 +466,7 @@ public function system() { $logalyzer->addKey('warning', 'string', $key); } } - } else if ($this->post['group'] == 'newError') { + } else if ($this->post['newError']) { $key = $this->post['newErrorPattern']; echo $key; if ($key != "") { @@ -479,7 +479,7 @@ public function system() { $logalyzer->addKey('error', 'string', $key); } } - } else if (!empty($this->get['deleteWarningPattern'])) { + } else if (!empty($this->post['deleteWarningPattern'])) { $key = $this->post['deleteWarningPattern']; if ($key != "") { $system = Factory::getSystemFactory()->get($this->post['id']); From a0b1e8f993a7e2d7b2344393407f431241be9be3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:31:13 +0200 Subject: [PATCH 181/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 6641656855..d693dd2ffe 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -466,7 +466,7 @@ public function system() { $logalyzer->addKey('warning', 'string', $key); } } - } else if ($this->post['newError']) { + } else if ($this->post['newErrorPattern']) { $key = $this->post['newErrorPattern']; echo $key; if ($key != "") { From 52f0bdb548e8437373c213dab03f68ad813c052f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:32:13 +0200 Subject: [PATCH 182/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index d693dd2ffe..75b9dca85b 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -466,7 +466,7 @@ public function system() { $logalyzer->addKey('warning', 'string', $key); } } - } else if ($this->post['newErrorPattern']) { + } else if (!empty($this->post['newErrorPattern'])) { $key = $this->post['newErrorPattern']; echo $key; if ($key != "") { From 1b94e06e5448fb54d85f52561f89a01a84e189b8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:32:47 +0200 Subject: [PATCH 183/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 75b9dca85b..25f7ff9f9c 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -466,7 +466,7 @@ public function system() { $logalyzer->addKey('warning', 'string', $key); } } - } else if (!empty($this->post['newErrorPattern'])) { + } else if (!empty($this->post['newError'])) { $key = $this->post['newErrorPattern']; echo $key; if ($key != "") { From cd0f04e55026feb703c421c3b48ad31b15db316c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:33:36 +0200 Subject: [PATCH 184/644] fixes to finalize implementation --- controllers/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin.php b/controllers/admin.php index 25f7ff9f9c..f6dfcefebc 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -467,6 +467,7 @@ public function system() { } } } else if (!empty($this->post['newError'])) { + echo "WE ARE HERE"; $key = $this->post['newErrorPattern']; echo $key; if ($key != "") { From 83364d45de2bd80802bbf6a2e7f137899f140ab1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:36:46 +0200 Subject: [PATCH 185/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index f6dfcefebc..6a9a1dea10 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -466,7 +466,7 @@ public function system() { $logalyzer->addKey('warning', 'string', $key); } } - } else if (!empty($this->post['newError'])) { + } else if (!empty($this->post['newErrorPattern'])) { echo "WE ARE HERE"; $key = $this->post['newErrorPattern']; echo $key; From 4ce638864190dc82dba620221efed36ad9ff1164 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:38:16 +0200 Subject: [PATCH 186/644] fixes to finalize implementation --- controllers/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin.php b/controllers/admin.php index 6a9a1dea10..a8f89daa45 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -341,6 +341,7 @@ public function system() { } if (!empty($this->post['id'])) { + var_dump($this->post); if ($this->post['group'] == 'general') { $data = $this->post; $system->setName(trim($this->post['name'])); From 68ef938f1a0604771dfa1978c1ba8aad53898557 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:41:09 +0200 Subject: [PATCH 187/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index a8f89daa45..5391c286f1 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -341,7 +341,7 @@ public function system() { } if (!empty($this->post['id'])) { - var_dump($this->post); + var_dump($_POST); if ($this->post['group'] == 'general') { $data = $this->post; $system->setName(trim($this->post['name'])); From bdf5e425f07c08c0880be342ab8205a0aded88c0 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:43:27 +0200 Subject: [PATCH 188/644] fixes to finalize implementation --- controllers/admin.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 5391c286f1..419b4b6632 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -341,7 +341,7 @@ public function system() { } if (!empty($this->post['id'])) { - var_dump($_POST); + var_dump($this->post); if ($this->post['group'] == 'general') { $data = $this->post; $system->setName(trim($this->post['name'])); @@ -392,6 +392,21 @@ public function system() { throw new Exception("Key already used!"); } } + else if ($this->post['group'] == 'newError') { + echo "WE ARE HERE"; + $key = $this->post['newErrorPattern']; + echo $key; + if ($key != "") { + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(substr($key, 0, 1) === '/') + $logalyzer->addKey('error', 'regex', $key); + else { + $logalyzer->addKey('error', 'string', $key); + } + } + } } } else if (!empty($this->get['delete'])) { $settings = Settings_Library::getInstance($system->getId()); From af92a36da1b9b6331884383888554aca8d5aa27c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:45:57 +0200 Subject: [PATCH 189/644] fixes to finalize implementation --- controllers/admin.php | 113 ++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 64 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 419b4b6632..ac0543ad38 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -392,19 +392,55 @@ public function system() { throw new Exception("Key already used!"); } } - else if ($this->post['group'] == 'newError') { - echo "WE ARE HERE"; - $key = $this->post['newErrorPattern']; - echo $key; - if ($key != "") { - $system = Factory::getSystemFactory()->get($this->post['id']); - $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); - if(substr($key, 0, 1) === '/') - $logalyzer->addKey('error', 'regex', $key); - else { - $logalyzer->addKey('error', 'string', $key); - } + } else if ($this->post['group'] == 'newError') { + echo "WE ARE HERE"; + $key = $this->post['newErrorPattern']; + echo $key; + if ($key != "") { + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(substr($key, 0, 1) === '/') + $logalyzer->addKey('error', 'regex', $key); + else { + $logalyzer->addKey('error', 'string', $key); + } + } + } else if (!empty($this->post['newWarning'])) { + $key = $this->post['newWarningPattern']; + if ($key != "") { + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(substr($key, 0, 1) === '/') + // Is regex. Php version 8 introduces starts_with() + $logalyzer->addKey('warning', 'regex', $key); + else { + $logalyzer->addKey('warning', 'string', $key); + } + } + } else if (!empty($this->post['deleteWarningPattern'])) { + $key = $this->post['deleteWarningPattern']; + if ($key != "") { + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(substr($key, 0, 1) === '/') + $logalyzer->removeKey('warning', 'regex', $key); + else { + $logalyzer->removeKey('warning', 'string', $key); + } + } + } else if (!empty($this->get['deleteErrorPattern'])) { + $key = $this->post['deleteErrorPattern']; + if ($key != "") { + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(substr($key, 0, 1) === '/') + $logalyzer->removeKey('error', 'regex', $key); + else { + $logalyzer->removeKey('error', 'string', $key); } } } @@ -469,57 +505,6 @@ public function system() { } $systemLib = new System($system->getId()); $systemLib->deleteResults($resultId); - } else if (!empty($this->post['newWarning'])) { - $key = $this->post['newWarningPattern']; - if ($key != "") { - $system = Factory::getSystemFactory()->get($this->post['id']); - $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); - if(substr($key, 0, 1) === '/') - // Is regex. Php version 8 introduces starts_with() - $logalyzer->addKey('warning', 'regex', $key); - else { - $logalyzer->addKey('warning', 'string', $key); - } - } - } else if (!empty($this->post['newErrorPattern'])) { - echo "WE ARE HERE"; - $key = $this->post['newErrorPattern']; - echo $key; - if ($key != "") { - $system = Factory::getSystemFactory()->get($this->post['id']); - $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); - if(substr($key, 0, 1) === '/') - $logalyzer->addKey('error', 'regex', $key); - else { - $logalyzer->addKey('error', 'string', $key); - } - } - } else if (!empty($this->post['deleteWarningPattern'])) { - $key = $this->post['deleteWarningPattern']; - if ($key != "") { - $system = Factory::getSystemFactory()->get($this->post['id']); - $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); - if(substr($key, 0, 1) === '/') - $logalyzer->removeKey('warning', 'regex', $key); - else { - $logalyzer->removeKey('warning', 'string', $key); - } - } - } else if (!empty($this->get['deleteErrorPattern'])) { - $key = $this->post['deleteErrorPattern']; - if ($key != "") { - $system = Factory::getSystemFactory()->get($this->post['id']); - $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); - if(substr($key, 0, 1) === '/') - $logalyzer->removeKey('error', 'regex', $key); - else { - $logalyzer->removeKey('error', 'string', $key); - } - } } else if (!empty($this->get['logo']) && $this->get['logo'] == 'upload') { // check for error values switch ($_FILES['logoUpload']['error']) { From 83b1ffe5d9feb33322fad14396e50b5a9cd2afcf Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:46:42 +0200 Subject: [PATCH 190/644] fixes to finalize implementation --- controllers/admin.php | 1 - views/admin/system.php | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index ac0543ad38..da8960fb5d 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -393,7 +393,6 @@ public function system() { } } } else if ($this->post['group'] == 'newError') { - echo "WE ARE HERE"; $key = $this->post['newErrorPattern']; echo $key; if ($key != "") { diff --git a/views/admin/system.php b/views/admin/system.php index ca9a6cfb18..04d7b2e653 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -478,8 +478,7 @@
$array) { - foreach ($array as $key) { - print_r($array); ?> + foreach ($array as $key) {?>
From a077a6b348346a11b2ffa6bfe8c4db14eb957429 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 16:48:27 +0200 Subject: [PATCH 191/644] fixes to finalize implementation --- controllers/admin.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index da8960fb5d..834a80a82f 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -399,10 +399,10 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); - if(substr($key, 0, 1) === '/') - $logalyzer->addKey('error', 'regex', $key); - else { + if(preg_match('/^[a-zA-Z0-9]+$/', $key)) $logalyzer->addKey('error', 'string', $key); + else { + $logalyzer->addKey('error', 'regex', $key); } } } else if (!empty($this->post['newWarning'])) { @@ -411,11 +411,11 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); - if(substr($key, 0, 1) === '/') + if(preg_match('/^[a-zA-Z0-9]+$/', $key)) // Is regex. Php version 8 introduces starts_with() - $logalyzer->addKey('warning', 'regex', $key); - else { $logalyzer->addKey('warning', 'string', $key); + else { + $logalyzer->addKey('warning', 'regex', $key); } } } else if (!empty($this->post['deleteWarningPattern'])) { From 2cc67a00c5502521b18441e68b7606e1d1056ede Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:02:08 +0200 Subject: [PATCH 192/644] fixes to finalize implementation --- controllers/admin.php | 3 ++- libraries/logalyzer.php | 17 ++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 834a80a82f..a1535dee9a 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -399,6 +399,7 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); + // $key contains just letters and numbers? if(preg_match('/^[a-zA-Z0-9]+$/', $key)) $logalyzer->addKey('error', 'string', $key); else { @@ -411,8 +412,8 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); + // $key contain just letters and numbers? if(preg_match('/^[a-zA-Z0-9]+$/', $key)) - // Is regex. Php version 8 introduces starts_with() $logalyzer->addKey('warning', 'string', $key); else { $logalyzer->addKey('warning', 'regex', $key); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c43b6bd80f..25acbf875d 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -85,7 +85,8 @@ public function examineEntireLog() { } $this->job->setLogalyzerCountWarnings($warningCount); $this->job->setLogalyzerCountErrors($errorCount); - $this->setHash($hash); + $this->job->setLogalyzerHash($hash); + $this->job = $this->job->save($this->job); } public function examineLogLine($logLine) { @@ -159,7 +160,10 @@ private function loadPatterns() { private function savePatterns() { $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; - $this->system->setLogalyzerPatterns(json_encode($this->data)); + $encoded = json_encode($this->data); + echo 'Saved to DB:' . $encoded; + $this->system->setLogalyzerPatterns($encoded); + $this->system = Factory::getSystemFactory()->save($this->system); } /** * @param string $identifier 'log level' @@ -220,15 +224,6 @@ function calculateHash() { return hash('sha1', json_encode($this->data)); } - /** - * Allows for setting the hash after operations are done - * @param $value - * @return void - */ - function setHash($value) { - $this->job->setLogalyzerHash($value); - } - /** * @return string */ From 2ab58ae222cf3888ecaacafbb9e9e355f63fc5f8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:04:04 +0200 Subject: [PATCH 193/644] fixes to finalize implementation --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 25acbf875d..544c66f08c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -163,7 +163,7 @@ private function savePatterns() { $encoded = json_encode($this->data); echo 'Saved to DB:' . $encoded; $this->system->setLogalyzerPatterns($encoded); - $this->system = Factory::getSystemFactory()->save($this->system); + //$this->system = Factory::getSystemFactory()->save($this->system); } /** * @param string $identifier 'log level' From ab984c014608a82862db3bbfe82af80431e3e034 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:04:19 +0200 Subject: [PATCH 194/644] fixes to finalize implementation --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 544c66f08c..d69710ebdd 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -86,7 +86,7 @@ public function examineEntireLog() { $this->job->setLogalyzerCountWarnings($warningCount); $this->job->setLogalyzerCountErrors($errorCount); $this->job->setLogalyzerHash($hash); - $this->job = $this->job->save($this->job); + //$this->job = $this->job->save($this->job); } public function examineLogLine($logLine) { From dc8040d3738d679d76c120a190960417468b46c0 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:11:49 +0200 Subject: [PATCH 195/644] fixes to finalize implementation --- controllers/admin.php | 3 +-- libraries/logalyzer.php | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index a1535dee9a..c61e71accb 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -341,7 +341,6 @@ public function system() { } if (!empty($this->post['id'])) { - var_dump($this->post); if ($this->post['group'] == 'general') { $data = $this->post; $system->setName(trim($this->post['name'])); @@ -394,7 +393,6 @@ public function system() { } } else if ($this->post['group'] == 'newError') { $key = $this->post['newErrorPattern']; - echo $key; if ($key != "") { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); @@ -412,6 +410,7 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); + $logalyzer->loadPatterns(); // $key contain just letters and numbers? if(preg_match('/^[a-zA-Z0-9]+$/', $key)) $logalyzer->addKey('warning', 'string', $key); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index d69710ebdd..1c5731ef08 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -119,6 +119,7 @@ public function examineLogLine($logLine) { } } private function createBasicPatterns() { + echo 'creating basic pattern.\n'; $this->data['warningPattern'] = ['string' => [], 'regex' => []]; $this->data['errorPattern'] = ['string' => [], 'regex' => []]; $this->warningPatterns['string'] = []; @@ -146,7 +147,7 @@ public function getPatterns($identifier) { return []; } } - private function loadPatterns() { + public function loadPatterns() { $this->data = json_decode($this->system->getLogalyzerPatterns(), true); if($this->data != null) { $this->warningPatterns = $this->data['warningPattern']; From 36ffa5ee7da0110123fe30f21e97a5392dad0c80 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:12:43 +0200 Subject: [PATCH 196/644] fixes to finalize implementation --- controllers/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin.php b/controllers/admin.php index c61e71accb..4d1a715869 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -397,6 +397,7 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); + $logalyzer->loadPatterns(); // $key contains just letters and numbers? if(preg_match('/^[a-zA-Z0-9]+$/', $key)) $logalyzer->addKey('error', 'string', $key); From 47cb8adf18c48ba702f0075c3ebfcff99684889f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:19:04 +0200 Subject: [PATCH 197/644] fixes to finalize implementation --- libraries/logalyzer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 1c5731ef08..48658726ba 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -148,8 +148,7 @@ public function getPatterns($identifier) { } } public function loadPatterns() { - $this->data = json_decode($this->system->getLogalyzerPatterns(), true); - if($this->data != null) { + if ($this->data = json_decode($this->system->getLogalyzerPatterns())) { $this->warningPatterns = $this->data['warningPattern']; $this->errorPatterns = $this->data['errorPattern']; } From 1a72b21986dd8b7f82db3c26d273cf87cdae3901 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:21:11 +0200 Subject: [PATCH 198/644] fixes to finalize implementation --- libraries/logalyzer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 48658726ba..9dfac694d7 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -134,8 +134,9 @@ public function getPatterns($identifier) { $this->createBasicPatterns(); $this->savePatterns(); } - $this->data = json_decode($this->system->getLogalyzerPatterns(), true); - if ($this->data != null) { + $patterns = $this->system->getLogalyzerPatterns(); + if ($patterns != null) { + $this->data = json_decode($patterns, true); if ($identifier === 'warning') { return $this->data['warningPattern']; } elseif ($identifier === 'error') { From a8ed894f6f46d2fb02f043faafcf72811c2cbc7a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:22:49 +0200 Subject: [PATCH 199/644] fixes to finalize implementation --- libraries/logalyzer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 9dfac694d7..9b624dfdad 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -149,7 +149,9 @@ public function getPatterns($identifier) { } } public function loadPatterns() { - if ($this->data = json_decode($this->system->getLogalyzerPatterns())) { + $patterns = $this->system->getLogalyzerPatterns(); + if ($patterns != null) { + $this->data = json_decode($patterns, true); $this->warningPatterns = $this->data['warningPattern']; $this->errorPatterns = $this->data['errorPattern']; } From bee4848c84d2e1502818671e124fb09e64f3845a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:25:12 +0200 Subject: [PATCH 200/644] fixes to finalize implementation --- libraries/logalyzer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 9b624dfdad..eb87e7b7b0 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -119,7 +119,7 @@ public function examineLogLine($logLine) { } } private function createBasicPatterns() { - echo 'creating basic pattern.\n'; + //echo 'creating basic pattern.\n'; $this->data['warningPattern'] = ['string' => [], 'regex' => []]; $this->data['errorPattern'] = ['string' => [], 'regex' => []]; $this->warningPatterns['string'] = []; @@ -130,7 +130,7 @@ private function createBasicPatterns() { } public function getPatterns($identifier) { if($this->system->getLogalyzerPatterns() == null) { - // create basic pattern + echo 'getPatterns creates pattern'; $this->createBasicPatterns(); $this->savePatterns(); } @@ -156,6 +156,7 @@ public function loadPatterns() { $this->errorPatterns = $this->data['errorPattern']; } else { + echo 'loadPatterns creates patterns'; $this->createBasicPatterns(); $this->savePatterns(); } From c5ba8dd9e1d823649f74c6a9da2001c59a1a9266 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:26:47 +0200 Subject: [PATCH 201/644] fixes to finalize implementation --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index eb87e7b7b0..2a2b1b9e60 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -158,7 +158,7 @@ public function loadPatterns() { else { echo 'loadPatterns creates patterns'; $this->createBasicPatterns(); - $this->savePatterns(); + //$this->savePatterns(); } } private function savePatterns() { From ab6ad97f1acddd896f1607d680b177cfa546fd5e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:29:01 +0200 Subject: [PATCH 202/644] fixes to finalize implementation --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 2a2b1b9e60..31701ac7bb 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -130,8 +130,9 @@ private function createBasicPatterns() { } public function getPatterns($identifier) { if($this->system->getLogalyzerPatterns() == null) { - echo 'getPatterns creates pattern'; + echo 'getPatterns creates pattern\n'; $this->createBasicPatterns(); + echo 'getPatterns saves pattern\n'; $this->savePatterns(); } $patterns = $this->system->getLogalyzerPatterns(); From c7ca9f1c2b9626fb814f1c3b5ae12e27c76f7da1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:30:17 +0200 Subject: [PATCH 203/644] fixes to finalize implementation --- libraries/logalyzer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 31701ac7bb..ebbd2a9d5b 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -130,14 +130,15 @@ private function createBasicPatterns() { } public function getPatterns($identifier) { if($this->system->getLogalyzerPatterns() == null) { - echo 'getPatterns creates pattern\n'; + echo "getPatterns creates pattern \n"; $this->createBasicPatterns(); - echo 'getPatterns saves pattern\n'; + echo "getPatterns saves pattern \n"; $this->savePatterns(); } $patterns = $this->system->getLogalyzerPatterns(); if ($patterns != null) { $this->data = json_decode($patterns, true); + echo "loaded pattern: " . $patterns . "\n"; if ($identifier === 'warning') { return $this->data['warningPattern']; } elseif ($identifier === 'error') { From 059513e305dc8c7a64122b4ccd80553ee1356712 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:32:21 +0200 Subject: [PATCH 204/644] fixes to finalize implementation --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index ebbd2a9d5b..04a341e530 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -138,10 +138,11 @@ public function getPatterns($identifier) { $patterns = $this->system->getLogalyzerPatterns(); if ($patterns != null) { $this->data = json_decode($patterns, true); - echo "loaded pattern: " . $patterns . "\n"; if ($identifier === 'warning') { + echo "loaded pattern: " . $this->data['warningPattern'] . "\n"; return $this->data['warningPattern']; } elseif ($identifier === 'error') { + echo "loaded pattern: " . $this->data['errorPattern'] . "\n"; return $this->data['errorPattern']; } else { return []; From 8aa812bf82756601fa4f66afea0968dde0c9161f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:33:32 +0200 Subject: [PATCH 205/644] fixes to finalize implementation --- libraries/logalyzer.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 04a341e530..09bd55831a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -139,10 +139,12 @@ public function getPatterns($identifier) { if ($patterns != null) { $this->data = json_decode($patterns, true); if ($identifier === 'warning') { - echo "loaded pattern: " . $this->data['warningPattern'] . "\n"; + echo "loaded pattern: "; + print_r($this->data['warningPattern']); return $this->data['warningPattern']; } elseif ($identifier === 'error') { - echo "loaded pattern: " . $this->data['errorPattern'] . "\n"; + echo "loaded pattern: "; + print_r($this->data['errorPattern']); return $this->data['errorPattern']; } else { return []; From 4c46564e72532bfb4da85ec70adf37ada8aa3f8d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:41:40 +0200 Subject: [PATCH 206/644] fixes to finalize implementation --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 09bd55831a..0cb2feb703 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -31,6 +31,7 @@ public function getSystem() { } public function setSystem($system) { $this->system = $system; + $this->loadPatterns(); } public function setJob($job) { $this->job = $job; From bbc30f5f92e67184d54c647e4b4cabfcf5b27c76 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:42:01 +0200 Subject: [PATCH 207/644] fixes to finalize implementation --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 0cb2feb703..d18e52bb4d 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -31,6 +31,7 @@ public function getSystem() { } public function setSystem($system) { $this->system = $system; + // Can only grab patterns after a system is defined $this->loadPatterns(); } public function setJob($job) { From 568c0d6482842e365fdfe5121bf149b936a2ff73 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:44:44 +0200 Subject: [PATCH 208/644] fixes to finalize implementation --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index d18e52bb4d..b597e977dd 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -165,7 +165,7 @@ public function loadPatterns() { else { echo 'loadPatterns creates patterns'; $this->createBasicPatterns(); - //$this->savePatterns(); + $this->savePatterns(); } } private function savePatterns() { From f16481a8d36c5f74dd9d580ff7d384838fbe6231 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:46:00 +0200 Subject: [PATCH 209/644] fixes to finalize implementation --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b597e977dd..2f37d11370 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -163,6 +163,7 @@ public function loadPatterns() { $this->errorPatterns = $this->data['errorPattern']; } else { + echo 'loadPatterns got ' . $patterns; echo 'loadPatterns creates patterns'; $this->createBasicPatterns(); $this->savePatterns(); From ced135ae3f038dd47d646209feb1c8c3fd7db6fe Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:49:53 +0200 Subject: [PATCH 210/644] fixes to finalize implementation --- controllers/admin.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 4d1a715869..a99d7db433 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -391,13 +391,12 @@ public function system() { throw new Exception("Key already used!"); } } - } else if ($this->post['group'] == 'newError') { + } else if (!empty($this->post['newError'])) { $key = $this->post['newErrorPattern']; if ($key != "") { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); - $logalyzer->loadPatterns(); // $key contains just letters and numbers? if(preg_match('/^[a-zA-Z0-9]+$/', $key)) $logalyzer->addKey('error', 'string', $key); @@ -411,7 +410,6 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); - $logalyzer->loadPatterns(); // $key contain just letters and numbers? if(preg_match('/^[a-zA-Z0-9]+$/', $key)) $logalyzer->addKey('warning', 'string', $key); From 184c2abca52dfba34018a9789f5ed1bc1e3c4ef4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:50:34 +0200 Subject: [PATCH 211/644] fixes to finalize implementation --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 2f37d11370..26b71a4ed1 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -163,7 +163,7 @@ public function loadPatterns() { $this->errorPatterns = $this->data['errorPattern']; } else { - echo 'loadPatterns got ' . $patterns; + echo 'loadPatterns got ' . gettype($patterns); echo 'loadPatterns creates patterns'; $this->createBasicPatterns(); $this->savePatterns(); From f5833af1519cc5e2fbf0f60def4eb2cf28c05f9e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:58:28 +0200 Subject: [PATCH 212/644] fixes to finalize implementation --- libraries/logalyzer.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 26b71a4ed1..8c4550d6ad 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -141,11 +141,10 @@ public function getPatterns($identifier) { if ($patterns != null) { $this->data = json_decode($patterns, true); if ($identifier === 'warning') { - echo "loaded pattern: "; print_r($this->data['warningPattern']); return $this->data['warningPattern']; } elseif ($identifier === 'error') { - echo "loaded pattern: "; + echo " loaded error pattern(omit warning pattern): "; print_r($this->data['errorPattern']); return $this->data['errorPattern']; } else { @@ -163,8 +162,7 @@ public function loadPatterns() { $this->errorPatterns = $this->data['errorPattern']; } else { - echo 'loadPatterns got ' . gettype($patterns); - echo 'loadPatterns creates patterns'; + echo ' loadPatterns got ' . gettype($patterns); $this->createBasicPatterns(); $this->savePatterns(); } @@ -173,7 +171,7 @@ private function savePatterns() { $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; $encoded = json_encode($this->data); - echo 'Saved to DB:' . $encoded; + echo ' Saved to DB:' . $encoded; $this->system->setLogalyzerPatterns($encoded); //$this->system = Factory::getSystemFactory()->save($this->system); } @@ -189,10 +187,13 @@ public function addKey(string $identifier, string $type, string $key) { echo 'System not defined\n'; } else { + echo 'New key: '; if ($identifier == 'warning') { $this->warningPatterns[$type][] = $key; + print_r($this->warningPatterns); } elseif ($identifier == 'error') { $this->errorPatterns[$type][] = $key; + print_r($this->errorPatterns); } else { echo "Error in identifier or isRegex inside logalyzer."; } From e5c06df3fda1d39faa0e369b228d543596f26c20 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 17:59:45 +0200 Subject: [PATCH 213/644] fixes to finalize implementation --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 8c4550d6ad..1b34581a18 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -141,7 +141,7 @@ public function getPatterns($identifier) { if ($patterns != null) { $this->data = json_decode($patterns, true); if ($identifier === 'warning') { - print_r($this->data['warningPattern']); + //print_r($this->data['warningPattern']); return $this->data['warningPattern']; } elseif ($identifier === 'error') { echo " loaded error pattern(omit warning pattern): "; @@ -162,7 +162,7 @@ public function loadPatterns() { $this->errorPatterns = $this->data['errorPattern']; } else { - echo ' loadPatterns got ' . gettype($patterns); + //echo ' loadPatterns got ' . gettype($patterns); $this->createBasicPatterns(); $this->savePatterns(); } From bb6da06896d6bad8cc9829ea897744b1f1b848dc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:00:37 +0200 Subject: [PATCH 214/644] fixes to finalize implementation --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 1b34581a18..2eab1c5ccf 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -148,9 +148,11 @@ public function getPatterns($identifier) { print_r($this->data['errorPattern']); return $this->data['errorPattern']; } else { + echo "Error in getpatterns 4"; return []; } } else { + echo "Error in getpatterns 5"; return []; } } From 596896e018abccf4f37f0f964517120932b0d1ea Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:02:41 +0200 Subject: [PATCH 215/644] fixes to finalize implementation --- controllers/admin.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controllers/admin.php b/controllers/admin.php index a99d7db433..0cbeb76055 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -394,6 +394,7 @@ public function system() { } else if (!empty($this->post['newError'])) { $key = $this->post['newErrorPattern']; if ($key != "") { + echo 'NEW KEY ' . $key; $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); @@ -407,6 +408,7 @@ public function system() { } else if (!empty($this->post['newWarning'])) { $key = $this->post['newWarningPattern']; if ($key != "") { + echo 'NEW KEY ' . $key; $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); From 9f906a2a5de0b5f9ff815fd87faa8e5a5f3005d9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:03:52 +0200 Subject: [PATCH 216/644] fixes to finalize implementation --- controllers/admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 0cbeb76055..80863ea364 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -391,7 +391,7 @@ public function system() { throw new Exception("Key already used!"); } } - } else if (!empty($this->post['newError'])) { + } else if (!empty($this->post['group'] =='newError')) { $key = $this->post['newErrorPattern']; if ($key != "") { echo 'NEW KEY ' . $key; @@ -405,7 +405,7 @@ public function system() { $logalyzer->addKey('error', 'regex', $key); } } - } else if (!empty($this->post['newWarning'])) { + } else if (!empty($this->post['group'] == 'newWarning')) { $key = $this->post['newWarningPattern']; if ($key != "") { echo 'NEW KEY ' . $key; @@ -419,7 +419,7 @@ public function system() { $logalyzer->addKey('warning', 'regex', $key); } } - } else if (!empty($this->post['deleteWarningPattern'])) { + } else if (!empty($this->post['group'] == 'deleteWarningPattern')) { $key = $this->post['deleteWarningPattern']; if ($key != "") { $system = Factory::getSystemFactory()->get($this->post['id']); @@ -431,7 +431,7 @@ public function system() { $logalyzer->removeKey('warning', 'string', $key); } } - } else if (!empty($this->get['deleteErrorPattern'])) { + } else if (!empty($this->get['group'] == 'deleteErrorPattern')) { $key = $this->post['deleteErrorPattern']; if ($key != "") { $system = Factory::getSystemFactory()->get($this->post['id']); From cfcecb2e3a87dc7c24588ca2c5bca11840f55c4c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:12:27 +0200 Subject: [PATCH 217/644] fixes to finalize implementation --- controllers/admin.php | 4 ++-- libraries/logalyzer.php | 6 +++--- views/admin/system.php | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 80863ea364..89f834a282 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -394,7 +394,7 @@ public function system() { } else if (!empty($this->post['group'] =='newError')) { $key = $this->post['newErrorPattern']; if ($key != "") { - echo 'NEW KEY ' . $key; + //echo 'NEW KEY ' . $key; $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); @@ -408,7 +408,7 @@ public function system() { } else if (!empty($this->post['group'] == 'newWarning')) { $key = $this->post['newWarningPattern']; if ($key != "") { - echo 'NEW KEY ' . $key; + //echo 'NEW KEY ' . $key; $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 2eab1c5ccf..15b51a78ad 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -134,12 +134,12 @@ public function getPatterns($identifier) { if($this->system->getLogalyzerPatterns() == null) { echo "getPatterns creates pattern \n"; $this->createBasicPatterns(); - echo "getPatterns saves pattern \n"; $this->savePatterns(); } $patterns = $this->system->getLogalyzerPatterns(); if ($patterns != null) { $this->data = json_decode($patterns, true); + echo 'retrieved from DB: ' . $patterns; if ($identifier === 'warning') { //print_r($this->data['warningPattern']); return $this->data['warningPattern']; @@ -164,7 +164,7 @@ public function loadPatterns() { $this->errorPatterns = $this->data['errorPattern']; } else { - //echo ' loadPatterns got ' . gettype($patterns); + echo 'on initial load loadPatterns did not receive object from db ' . gettype($patterns); $this->createBasicPatterns(); $this->savePatterns(); } @@ -189,7 +189,7 @@ public function addKey(string $identifier, string $type, string $key) { echo 'System not defined\n'; } else { - echo 'New key: '; + echo 'New key: ' . $key; if ($identifier == 'warning') { $this->warningPatterns[$type][] = $key; print_r($this->warningPatterns); diff --git a/views/admin/system.php b/views/admin/system.php index 04d7b2e653..272ea75ac1 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -468,7 +468,6 @@
-
@@ -517,7 +516,6 @@
- Delete From 5e46e2da22f438c05578a21885db0e48befcc07e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:13:25 +0200 Subject: [PATCH 218/644] fixes to finalize implementation --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 15b51a78ad..6ee8e73625 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -139,12 +139,12 @@ public function getPatterns($identifier) { $patterns = $this->system->getLogalyzerPatterns(); if ($patterns != null) { $this->data = json_decode($patterns, true); - echo 'retrieved from DB: ' . $patterns; + //echo 'retrieved from DB: ' . $patterns; if ($identifier === 'warning') { //print_r($this->data['warningPattern']); return $this->data['warningPattern']; } elseif ($identifier === 'error') { - echo " loaded error pattern(omit warning pattern): "; + //echo " loaded error pattern(omit warning pattern): "; print_r($this->data['errorPattern']); return $this->data['errorPattern']; } else { From ed9bd22589356b6ee0a55a8ced0d6e17f41a65ee Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:29:06 +0200 Subject: [PATCH 219/644] fixes to finalize implementation --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 6ee8e73625..468902c73a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -175,7 +175,7 @@ private function savePatterns() { $encoded = json_encode($this->data); echo ' Saved to DB:' . $encoded; $this->system->setLogalyzerPatterns($encoded); - //$this->system = Factory::getSystemFactory()->save($this->system); + Factory::getSystemFactory()->update($this->system); } /** * @param string $identifier 'log level' From bc7abcdc25a6c1f2e5ab9d2de229a1b1970a617a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:30:30 +0200 Subject: [PATCH 220/644] fixes to finalize implementation --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 468902c73a..3ba83c6573 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -175,7 +175,8 @@ private function savePatterns() { $encoded = json_encode($this->data); echo ' Saved to DB:' . $encoded; $this->system->setLogalyzerPatterns($encoded); - Factory::getSystemFactory()->update($this->system); + $statement = Factory::getSystemFactory()->update($this->system); + echo $statement } /** * @param string $identifier 'log level' From a030528abd3624b9c74b06494d46bf6728878d3a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:30:56 +0200 Subject: [PATCH 221/644] fixes to finalize implementation --- libraries/logalyzer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 3ba83c6573..468902c73a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -175,8 +175,7 @@ private function savePatterns() { $encoded = json_encode($this->data); echo ' Saved to DB:' . $encoded; $this->system->setLogalyzerPatterns($encoded); - $statement = Factory::getSystemFactory()->update($this->system); - echo $statement + Factory::getSystemFactory()->update($this->system); } /** * @param string $identifier 'log level' From d29bd41329a9e9f307a70dbd40f190f1a2a19797 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:41:32 +0200 Subject: [PATCH 222/644] fixes to finalize implementation --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 468902c73a..4c59fef799 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -222,7 +222,9 @@ public function removeKey(string $identifier, string $type, string $key) } elseif ($identifier == 'error') { if (($index = array_search($key, $this->errorPatterns[$type])) !== false) { + echo 'unallocating ' . $key; unset($this->errorPatterns[$type][$index]); + $this->errorPatterns[$type] = array_values($this->errorPatterns[$type]); } } else { From b965940a73a1717423d712d2376e85e09ddbd937 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:44:25 +0200 Subject: [PATCH 223/644] fixes to finalize implementation --- controllers/admin.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 89f834a282..afff9ec800 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -425,11 +425,12 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); - if(substr($key, 0, 1) === '/') - $logalyzer->removeKey('warning', 'regex', $key); - else { + if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { $logalyzer->removeKey('warning', 'string', $key); } + else { + $logalyzer->removeKey('warning', 'regex', $key); + } } } else if (!empty($this->get['group'] == 'deleteErrorPattern')) { $key = $this->post['deleteErrorPattern']; @@ -437,11 +438,12 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); - if(substr($key, 0, 1) === '/') - $logalyzer->removeKey('error', 'regex', $key); - else { + if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { $logalyzer->removeKey('error', 'string', $key); } + else { + $logalyzer->removeKey('error', 'regex', $key); + } } } } else if (!empty($this->get['delete'])) { From 325e7c50e87857c994c92efa5c8758861010dc74 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:45:21 +0200 Subject: [PATCH 224/644] fixes to finalize implementation --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4c59fef799..52ba07a37a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -221,8 +221,9 @@ public function removeKey(string $identifier, string $type, string $key) } } elseif ($identifier == 'error') { + echo 'searing in error array...'; if (($index = array_search($key, $this->errorPatterns[$type])) !== false) { - echo 'unallocating ' . $key; + echo 'key found. unallocating ' . $key; unset($this->errorPatterns[$type][$index]); $this->errorPatterns[$type] = array_values($this->errorPatterns[$type]); } From cb4f844b25efff65c31362056484b59bd2af23ee Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:49:15 +0200 Subject: [PATCH 225/644] fixes to finalize implementation --- controllers/admin.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index afff9ec800..dc93eb1b37 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -446,7 +446,21 @@ public function system() { } } } - } else if (!empty($this->get['delete'])) { + } else if (!empty($this->get['deleteWarningPattern'])) { + echo 'delete request received'; + $key = $this->get['deleteWarningPattern']; + if ($key != "") { + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { + $logalyzer->removeKey('warning', 'string', $key); + } + else { + $logalyzer->removeKey('warning', 'regex', $key); + } + } + }else if (!empty($this->get['delete'])) { $settings = Settings_Library::getInstance($system->getId()); if (!empty($this->get['delete'])) { $key = urldecode($this->get['delete']); From d63edfbf6ba57f707bc2b8d6e752472725849a5e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:51:58 +0200 Subject: [PATCH 226/644] fixes to finalize implementation --- controllers/admin.php | 3 ++- views/admin/system.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index dc93eb1b37..54a3cbd69d 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -433,7 +433,8 @@ public function system() { } } } else if (!empty($this->get['group'] == 'deleteErrorPattern')) { - $key = $this->post['deleteErrorPattern']; + echo 'delete request received'; + $key = $this->get['deleteErrorPattern']; if ($key != "") { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); diff --git a/views/admin/system.php b/views/admin/system.php index 272ea75ac1..81a5176881 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -482,7 +482,7 @@
- + Delete From 5476cc39cf26417894e146717e3443263303281a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:52:47 +0200 Subject: [PATCH 227/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 54a3cbd69d..3d5d23be01 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -432,7 +432,7 @@ public function system() { $logalyzer->removeKey('warning', 'regex', $key); } } - } else if (!empty($this->get['group'] == 'deleteErrorPattern')) { + } else if (!empty($this->get['deleteErrorPattern'])) { echo 'delete request received'; $key = $this->get['deleteErrorPattern']; if ($key != "") { From 9486a8c013e77b87debfb0adfc27798d120fd224 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:53:45 +0200 Subject: [PATCH 228/644] fixes to finalize implementation --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 3d5d23be01..192de86420 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -330,7 +330,7 @@ public function systems() { */ public function system() { $this->view->includeAsset("gitgraph"); - + var_dump($_GET); if (!empty($this->get['id'])) { $system = new System($this->get['id']); $system = $system->getModel(); From d5c852c373cc4d5aeb64c830d593c6057c8651b8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:54:58 +0200 Subject: [PATCH 229/644] fixes to finalize implementation --- controllers/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin.php b/controllers/admin.php index 192de86420..25f6a15f2a 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -331,6 +331,7 @@ public function systems() { public function system() { $this->view->includeAsset("gitgraph"); var_dump($_GET); + echo $this->get['id']; if (!empty($this->get['id'])) { $system = new System($this->get['id']); $system = $system->getModel(); From 38c7e2ca762fa1f4539a316062ccef1335ae07ee Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:55:52 +0200 Subject: [PATCH 230/644] fixes to finalize implementation --- controllers/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin.php b/controllers/admin.php index 25f6a15f2a..a9f3d763f2 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -332,6 +332,7 @@ public function system() { $this->view->includeAsset("gitgraph"); var_dump($_GET); echo $this->get['id']; + echo $this->get['deleteErrorPattern']; if (!empty($this->get['id'])) { $system = new System($this->get['id']); $system = $system->getModel(); From 8865c9338ced2fd341f67fe0d26c7bc98c4a5859 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:57:34 +0200 Subject: [PATCH 231/644] fixes to finalize implementation --- controllers/admin.php | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index a9f3d763f2..a4879a2448 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -330,9 +330,6 @@ public function systems() { */ public function system() { $this->view->includeAsset("gitgraph"); - var_dump($_GET); - echo $this->get['id']; - echo $this->get['deleteErrorPattern']; if (!empty($this->get['id'])) { $system = new System($this->get['id']); $system = $system->getModel(); @@ -421,8 +418,8 @@ public function system() { $logalyzer->addKey('warning', 'regex', $key); } } - } else if (!empty($this->post['group'] == 'deleteWarningPattern')) { - $key = $this->post['deleteWarningPattern']; + } else if (!empty($this->get['deleteWarningPattern'])) { + $key = $this->get['deleteWarningPattern']; if ($key != "") { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); @@ -449,20 +446,6 @@ public function system() { } } } - } else if (!empty($this->get['deleteWarningPattern'])) { - echo 'delete request received'; - $key = $this->get['deleteWarningPattern']; - if ($key != "") { - $system = Factory::getSystemFactory()->get($this->post['id']); - $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); - if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { - $logalyzer->removeKey('warning', 'string', $key); - } - else { - $logalyzer->removeKey('warning', 'regex', $key); - } - } }else if (!empty($this->get['delete'])) { $settings = Settings_Library::getInstance($system->getId()); if (!empty($this->get['delete'])) { From 8d09ca4fc953e50b67e192d466c0ed76de52c2d8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 18:57:43 +0200 Subject: [PATCH 232/644] fixes to finalize implementation --- controllers/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin.php b/controllers/admin.php index a4879a2448..e45235c3f0 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -419,6 +419,7 @@ public function system() { } } } else if (!empty($this->get['deleteWarningPattern'])) { + echo 'delete request received'; $key = $this->get['deleteWarningPattern']; if ($key != "") { $system = Factory::getSystemFactory()->get($this->post['id']); From 9f2b600db610e97904d755227513502d40a08a95 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 19:00:15 +0200 Subject: [PATCH 233/644] fixes to finalize implementation --- controllers/admin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index e45235c3f0..4ccdb5a4b4 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -338,7 +338,8 @@ public function system() { if ($system->getUserId() != $auth->getUserID() && !$auth->isAdmin()) { throw new Exception("Not enough privileges to view this system!"); } - + echo $this->get['deleteErrorPattern']; + echo $this->get['id']; if (!empty($this->post['id'])) { if ($this->post['group'] == 'general') { $data = $this->post; @@ -447,7 +448,8 @@ public function system() { } } } - }else if (!empty($this->get['delete'])) { + } + else if (!empty($this->get['delete'])) { $settings = Settings_Library::getInstance($system->getId()); if (!empty($this->get['delete'])) { $key = urldecode($this->get['delete']); From fdcc53362f53f9c014b17a27727a207ba4bbecb0 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 19:02:06 +0200 Subject: [PATCH 234/644] fixes to finalize implementation --- controllers/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/admin.php b/controllers/admin.php index 4ccdb5a4b4..cea3e8f929 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -340,6 +340,7 @@ public function system() { } echo $this->get['deleteErrorPattern']; echo $this->get['id']; + var_dump($this->post['group']); if (!empty($this->post['id'])) { if ($this->post['group'] == 'general') { $data = $this->post; From a8b1a69817240f148c655f209983ba6749e362af Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 19:06:09 +0200 Subject: [PATCH 235/644] fixes to finalize implementation --- controllers/admin.php | 58 +++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index cea3e8f929..ae12be1ba9 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -339,7 +339,7 @@ public function system() { throw new Exception("Not enough privileges to view this system!"); } echo $this->get['deleteErrorPattern']; - echo $this->get['id']; + echo $this->post['id']; var_dump($this->post['group']); if (!empty($this->post['id'])) { if ($this->post['group'] == 'general') { @@ -420,37 +420,37 @@ public function system() { $logalyzer->addKey('warning', 'regex', $key); } } - } else if (!empty($this->get['deleteWarningPattern'])) { - echo 'delete request received'; - $key = $this->get['deleteWarningPattern']; - if ($key != "") { - $system = Factory::getSystemFactory()->get($this->post['id']); - $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); - if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { - $logalyzer->removeKey('warning', 'string', $key); - } - else { - $logalyzer->removeKey('warning', 'regex', $key); - } + } + } + else if (!empty($this->get['deleteWarningPattern'])) { + echo 'delete request received'; + $key = $this->get['deleteWarningPattern']; + if ($key != "") { + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { + $logalyzer->removeKey('warning', 'string', $key); } - } else if (!empty($this->get['deleteErrorPattern'])) { - echo 'delete request received'; - $key = $this->get['deleteErrorPattern']; - if ($key != "") { - $system = Factory::getSystemFactory()->get($this->post['id']); - $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); - if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { - $logalyzer->removeKey('error', 'string', $key); - } - else { - $logalyzer->removeKey('error', 'regex', $key); - } + else { + $logalyzer->removeKey('warning', 'regex', $key); } } - } - else if (!empty($this->get['delete'])) { + } else if (!empty($this->get['deleteErrorPattern'])) { + echo 'delete request received'; + $key = $this->get['deleteErrorPattern']; + if ($key != "") { + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystem($system); + if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { + $logalyzer->removeKey('error', 'string', $key); + } + else { + $logalyzer->removeKey('error', 'regex', $key); + } + } + } else if (!empty($this->get['delete'])) { $settings = Settings_Library::getInstance($system->getId()); if (!empty($this->get['delete'])) { $key = urldecode($this->get['delete']); From 35e0ddc494e7ee19e3d7888d61a8df32a7438cf8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 19:07:59 +0200 Subject: [PATCH 236/644] fixes to finalize implementation --- controllers/admin.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index ae12be1ba9..613fbc8860 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -338,9 +338,6 @@ public function system() { if ($system->getUserId() != $auth->getUserID() && !$auth->isAdmin()) { throw new Exception("Not enough privileges to view this system!"); } - echo $this->get['deleteErrorPattern']; - echo $this->post['id']; - var_dump($this->post['group']); if (!empty($this->post['id'])) { if ($this->post['group'] == 'general') { $data = $this->post; @@ -426,7 +423,7 @@ public function system() { echo 'delete request received'; $key = $this->get['deleteWarningPattern']; if ($key != "") { - $system = Factory::getSystemFactory()->get($this->post['id']); + $system = Factory::getSystemFactory()->get($this->get['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { @@ -440,7 +437,7 @@ public function system() { echo 'delete request received'; $key = $this->get['deleteErrorPattern']; if ($key != "") { - $system = Factory::getSystemFactory()->get($this->post['id']); + $system = Factory::getSystemFactory()->get($this->get['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystem($system); if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { From d4b8a92d167781d8fb115cf3c2dde85198cd70c2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 19:22:25 +0200 Subject: [PATCH 237/644] added new magic number in constants.php --- constants.php | 1 + 1 file changed, 1 insertion(+) diff --git a/constants.php b/constants.php index e95c487aff..6b882c11ef 100644 --- a/constants.php +++ b/constants.php @@ -1,2 +1,3 @@ Date: Sun, 21 Jul 2024 19:25:13 +0200 Subject: [PATCH 238/644] implementing features --- controllers/admin.php | 12 ++++-------- libraries/logalyzer.php | 25 ++++++++----------------- views/admin/system.php | 2 +- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 613fbc8860..5c98b3b8ae 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -392,10 +392,9 @@ public function system() { } else if (!empty($this->post['group'] =='newError')) { $key = $this->post['newErrorPattern']; if ($key != "") { - //echo 'NEW KEY ' . $key; $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); + $logalyzer->setSystemAndLoadPattern($system); // $key contains just letters and numbers? if(preg_match('/^[a-zA-Z0-9]+$/', $key)) $logalyzer->addKey('error', 'string', $key); @@ -406,10 +405,9 @@ public function system() { } else if (!empty($this->post['group'] == 'newWarning')) { $key = $this->post['newWarningPattern']; if ($key != "") { - //echo 'NEW KEY ' . $key; $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); + $logalyzer->setSystemAndLoadPattern($system); // $key contain just letters and numbers? if(preg_match('/^[a-zA-Z0-9]+$/', $key)) $logalyzer->addKey('warning', 'string', $key); @@ -420,12 +418,11 @@ public function system() { } } else if (!empty($this->get['deleteWarningPattern'])) { - echo 'delete request received'; $key = $this->get['deleteWarningPattern']; if ($key != "") { $system = Factory::getSystemFactory()->get($this->get['id']); $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); + $logalyzer->setSystemAndLoadPattern($system); if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { $logalyzer->removeKey('warning', 'string', $key); } @@ -434,12 +431,11 @@ public function system() { } } } else if (!empty($this->get['deleteErrorPattern'])) { - echo 'delete request received'; $key = $this->get['deleteErrorPattern']; if ($key != "") { $system = Factory::getSystemFactory()->get($this->get['id']); $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystem($system); + $logalyzer->setSystemAndLoadPattern($system); if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { $logalyzer->removeKey('error', 'string', $key); } diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 52ba07a37a..9c801af217 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -29,9 +29,8 @@ public function getJob() { public function getSystem() { return $this->system; } - public function setSystem($system) { + public function setSystemAndLoadPattern($system) { $this->system = $system; - // Can only grab patterns after a system is defined $this->loadPatterns(); } public function setJob($job) { @@ -70,8 +69,9 @@ public function examineEntireLog() { // Count occurrences of all defined keywords. $warningCount = 0; $errorCount = 0; - - while ($warningCount <= 10 && $errorCount <= 10) { + $LOG_ERRORS_MAX = 10; + // TODO change to constant when available + while ($warningCount <= $LOG_ERRORS_MAX && $errorCount <= $LOG_ERRORS_MAX) { foreach ($this->warningPatterns['regex'] as $key) { $warningCount += $this->countLogOccurances($key, $this->log, true); } @@ -88,7 +88,7 @@ public function examineEntireLog() { $this->job->setLogalyzerCountWarnings($warningCount); $this->job->setLogalyzerCountErrors($errorCount); $this->job->setLogalyzerHash($hash); - //$this->job = $this->job->save($this->job); + Factory::getJobFactory()->update($this->job); } public function examineLogLine($logLine) { @@ -121,14 +121,12 @@ public function examineLogLine($logLine) { } } private function createBasicPatterns() { - //echo 'creating basic pattern.\n'; $this->data['warningPattern'] = ['string' => [], 'regex' => []]; $this->data['errorPattern'] = ['string' => [], 'regex' => []]; $this->warningPatterns['string'] = []; $this->warningPatterns['regex'] = []; $this->errorPatterns['string'] = []; $this->errorPatterns['regex'] = []; - //$this->savePatterns(); } public function getPatterns($identifier) { if($this->system->getLogalyzerPatterns() == null) { @@ -139,20 +137,17 @@ public function getPatterns($identifier) { $patterns = $this->system->getLogalyzerPatterns(); if ($patterns != null) { $this->data = json_decode($patterns, true); - //echo 'retrieved from DB: ' . $patterns; if ($identifier === 'warning') { - //print_r($this->data['warningPattern']); return $this->data['warningPattern']; } elseif ($identifier === 'error') { - //echo " loaded error pattern(omit warning pattern): "; print_r($this->data['errorPattern']); return $this->data['errorPattern']; } else { - echo "Error in getpatterns 4"; + echo "Error in getpatterns"; return []; } } else { - echo "Error in getpatterns 5"; + echo "Error in getpatterns"; return []; } } @@ -164,7 +159,7 @@ public function loadPatterns() { $this->errorPatterns = $this->data['errorPattern']; } else { - echo 'on initial load loadPatterns did not receive object from db ' . gettype($patterns); + // Initial load of patterns returned null $this->createBasicPatterns(); $this->savePatterns(); } @@ -173,7 +168,6 @@ private function savePatterns() { $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; $encoded = json_encode($this->data); - echo ' Saved to DB:' . $encoded; $this->system->setLogalyzerPatterns($encoded); Factory::getSystemFactory()->update($this->system); } @@ -184,7 +178,6 @@ private function savePatterns() { * @return void */ public function addKey(string $identifier, string $type, string $key) { - // Avoid changing local array for concurrency? Could save the new $key in a copy and save that copy if($this->system == null) { echo 'System not defined\n'; } @@ -221,9 +214,7 @@ public function removeKey(string $identifier, string $type, string $key) } } elseif ($identifier == 'error') { - echo 'searing in error array...'; if (($index = array_search($key, $this->errorPatterns[$type])) !== false) { - echo 'key found. unallocating ' . $key; unset($this->errorPatterns[$type][$index]); $this->errorPatterns[$type] = array_values($this->errorPatterns[$type]); } diff --git a/views/admin/system.php b/views/admin/system.php index 81a5176881..b1fe31e1dd 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -459,7 +459,7 @@

Log Analysis

-

Regex Expression: Enter a Regex expression by starting with /. For example /[error|fail|crash] or /[^success]

+

Regex Expression: Any expression consisting of more than just letters and numbers is treated as regex.

From 75cb0c966f3b7d8991cc6ee3e9ceba8269203324 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 19:28:02 +0200 Subject: [PATCH 239/644] implementing features --- controllers/evaluation.php | 4 ++-- views/evaluation/detail.php | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 5dbf611456..b0070838ca 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -159,8 +159,8 @@ public function detail() { $isFinished = false; } else { $resultsAvailable = true; - $logUtil = new Logalyzer_Library($subJob); - $logUtil->examineLogAndSetAlert(); + //$logalyzer = new Logalyzer_Library($subJob); + //$logalyzer-> } } if (sizeof($jobs) == 0) { diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index b54d04fa69..20abf46e63 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -216,11 +216,6 @@ function submitData() { - - - getStatus() == Define::JOB_STATUS_SCHEDULED) { ?> scheduled From 29a91d357744171de7f6c87f3fc63709b53bba8a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 19:36:59 +0200 Subject: [PATCH 240/644] implementing features --- controllers/job.php | 6 ++++++ libraries/logalyzer.php | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 4dd7d74921..8901edc427 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -143,6 +143,12 @@ public function detail() { $this->view->assign('evaluation', $evaluation); $this->view->assign('experiment', Factory::getExperimentFactory()->get($evaluation->getExperimentId())); + $warnings = $job->getLogalyzerWarningCount(); + $errors = $job->getLogalyzerWarningCount(); + //if($warnings <=) + $this->view->assign('logWarnings', $warnings); + $this->view->assign('logErrors', $errors); + $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); } else { diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 9c801af217..7ef5cea5e3 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -92,8 +92,9 @@ public function examineEntireLog() { } public function examineLogLine($logLine) { - // TODO more elegant solution - while ($this->job->getLogalyzerCountWarnings <= 10 && $this->job->getLogalyzerCountErrors <= 10) { + $LOG_ERRORS_MAX = 10; + // TODO change to constant when available + while ($this->job->getLogalyzerCountWarnings <= $LOG_ERRORS_MAX && $this->job->getLogalyzerCountErrors <= $LOG_ERRORS_MAX) { foreach ($this->warningPatterns['regex'] as $key) { for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { // TODO implement increment From c1ad682e2b206928fd8be8cdafabd04832e6e68c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 19:39:37 +0200 Subject: [PATCH 241/644] implementing features --- views/job/detail.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index c00bab3654..5cd4020574 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -225,14 +225,10 @@ function updateProgress() {
- = 0) { ?> - Errors: - + Errors: = 0) { echo($data['logErrors']); } ?>
- = 0) { ?> - Warnings: - + Warnings: = 0) { echo($data['logWarnings']);} ?>
From a92d296c449e3ea27c9d15debae4641e3c21c423 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 19:40:12 +0200 Subject: [PATCH 242/644] implementing features --- controllers/job.php | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/job.php b/controllers/job.php index 8901edc427..68ae7157c2 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -145,7 +145,6 @@ public function detail() { $warnings = $job->getLogalyzerWarningCount(); $errors = $job->getLogalyzerWarningCount(); - //if($warnings <=) $this->view->assign('logWarnings', $warnings); $this->view->assign('logErrors', $errors); From b6b4b5953746937742b992106fa96599d3cb20f7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:00:04 +0200 Subject: [PATCH 243/644] implementing features --- controllers/job.php | 9 ++++++++- views/job/detail.php | 11 ++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 68ae7157c2..96156e2d84 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -150,10 +150,17 @@ public function detail() { $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); + if (!empty($this->get['recount'])) { + echo 'button pressed'; + $logalyzer = new Logalyzer_Library($job); + $logalyzer->examineEntireLog(); + } } else { throw new Exception("No job with id: " . $this->get['id']); } - } else { + + } + else { throw new Exception("No job id provided!"); } } diff --git a/views/job/detail.php b/views/job/detail.php index 5cd4020574..f7fbcf4d97 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -118,7 +118,6 @@ function updateProgress() { }, 2000); $('#log').scrollTop($('#log')[0].scrollHeight); }); - "); $this->includeInlineCSS(" @@ -225,10 +224,16 @@ function updateProgress() {
- Errors: = 0) { echo($data['logErrors']); } ?> + Errors: = 0) { echo($data['logErrors']); } ?> +
+
+ Warnings: = 0) { echo($data['logWarnings']);} ?>
- Warnings: = 0) { echo($data['logWarnings']);} ?> +
+ + +
From 8de00b2fc6fc2c7d3309357a014a589fa97766ea Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:00:40 +0200 Subject: [PATCH 244/644] implementing features --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index f7fbcf4d97..487cef3053 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -213,7 +213,7 @@ function updateProgress() {
-
+
From cd3232e8f4bbe060a601f5d3ecb9fa0df87a0a47 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:32:55 +0200 Subject: [PATCH 256/644] implementing features --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index be5314887f..fc32142b9f 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -231,8 +231,8 @@ function updateProgress() {
- - + +
From f1238cfd0cb6c26a5c2786c0bda5daba431ee599 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:34:35 +0200 Subject: [PATCH 257/644] implementing features --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index fc32142b9f..09e7a59e8d 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -230,7 +230,7 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarnings']);} ?>
-
+
From 9002cf0a925345377076f41d00c3bbcaf0d2574c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:40:28 +0200 Subject: [PATCH 258/644] implementing features --- views/job/detail.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/job/detail.php b/views/job/detail.php index 09e7a59e8d..afdcdf7ffe 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -233,6 +233,7 @@ function updateProgress() {
+ Recount
From 2a0e3c8f106b9dbdc35bf0694e92b9d3eba22f4c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:40:52 +0200 Subject: [PATCH 259/644] implementing features --- views/job/detail.php | 1 - 1 file changed, 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index afdcdf7ffe..e1cdd3689c 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -232,7 +232,6 @@ function updateProgress() { From 00f6a02bec5eb8f73dea9fc380e750f28ff9de19 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:43:16 +0200 Subject: [PATCH 260/644] implementing features --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index e1cdd3689c..09e7a59e8d 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -232,7 +232,7 @@ function updateProgress() {
- Recount +
From ceeec7e9eeaba27a7ca2d65adf307ba8fe723da8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:47:27 +0200 Subject: [PATCH 261/644] implementing features --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 09e7a59e8d..2f14959149 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -230,9 +230,9 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarnings']);} ?>
-
+ - +
From ddca12950706ffbd007418ba6b9540a292859ed6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:48:35 +0200 Subject: [PATCH 262/644] implementing features --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 2f14959149..0e706765ba 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -231,7 +231,7 @@ function updateProgress() {
- +
From ec4ea3bfdaf373244132802589b36c9de26769c5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:50:44 +0200 Subject: [PATCH 263/644] implementing features --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 0e706765ba..40183d8d39 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -129,7 +129,7 @@ function updateProgress() { "); ?>
-
+

Job details From 8ac500aea19443116bd32aa76ab624ea9172608b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:54:42 +0200 Subject: [PATCH 264/644] implementing features --- views/job/detail.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 40183d8d39..74856e28f5 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -129,7 +129,7 @@ function updateProgress() { "); ?>
- +

Job details @@ -205,7 +205,7 @@ function updateProgress() {

- +
@@ -230,9 +230,9 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarnings']);} ?>
-
+ - +
@@ -318,5 +318,4 @@ function updateProgress() {
-
From 9a43e248c66b232f7bde2649a7d5487177e6aa45 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:55:28 +0200 Subject: [PATCH 265/644] implementing features --- views/job/detail.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 74856e28f5..92edeed3b6 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -205,7 +205,7 @@ function updateProgress() {
- +
@@ -318,4 +318,5 @@ function updateProgress() {
+
From 1ff9139f44f79e3ff88e3e086b7135b9b398f8c2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 20:57:41 +0200 Subject: [PATCH 266/644] implementing features --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 92edeed3b6..aac07bea0d 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -129,7 +129,7 @@ function updateProgress() { "); ?>
-
+

Job details @@ -230,7 +230,7 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarnings']);} ?>

- + From 9ea7d11e6212165a1d751be697d3006afe55ff27 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 21:10:18 +0200 Subject: [PATCH 267/644] implementing features --- views/job/detail.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index aac07bea0d..3c7069dc23 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -60,7 +60,18 @@ function submitData() { } }); } + function logalyzer_recount() { + $.ajax({ + url : '/api/ui/job/id=' + $('#id').val(), + data : { + id : $('#id').val(), + recount : $('true'), + }, + type : 'POST', + dataType: 'json' + }); + } function abortJob() { $.ajax({ url : '/api/ui/job/id=' + $('#id').val(), @@ -230,10 +241,7 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarnings']);} ?>
-
- - -
+
From 94770e15b28866aca24c6a2bf4879bdc18974c1f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 21:11:31 +0200 Subject: [PATCH 268/644] implementing features --- controllers/job.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/job.php b/controllers/job.php index 9798c68f87..1546672eb5 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -151,6 +151,7 @@ public function detail() { $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); if (!empty($this->post['recount'])) { + echo 'recount triggered'; $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); } From 5e552d12eec08d1ca06d6a1329ed0953f210d3fd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 21:13:42 +0200 Subject: [PATCH 269/644] implementing features --- controllers/job.php | 2 +- views/job/detail.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 1546672eb5..b439c16371 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -150,7 +150,7 @@ public function detail() { $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); - if (!empty($this->post['recount'])) { + if (!empty($this->get['recount'])) { echo 'recount triggered'; $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); diff --git a/views/job/detail.php b/views/job/detail.php index 3c7069dc23..b3defd6cf5 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -67,7 +67,7 @@ function logalyzer_recount() { id : $('#id').val(), recount : $('true'), }, - type : 'POST', + type : 'GET', dataType: 'json' }); From 71a669faa9a0e509cb82ee41b8ed8bee54375a2c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 21:19:02 +0200 Subject: [PATCH 270/644] implementing features --- views/job/detail.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index b3defd6cf5..834645130c 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -60,18 +60,7 @@ function submitData() { } }); } - function logalyzer_recount() { - $.ajax({ - url : '/api/ui/job/id=' + $('#id').val(), - data : { - id : $('#id').val(), - recount : $('true'), - }, - type : 'GET', - dataType: 'json' - }); - } function abortJob() { $.ajax({ url : '/api/ui/job/id=' + $('#id').val(), @@ -241,7 +230,10 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarnings']);} ?>
- +
+ + +
From e64be66a8f7628d137cedc319978a742dd831dbd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 21:20:56 +0200 Subject: [PATCH 271/644] implementing features --- controllers/job.php | 2 +- views/job/detail.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index b439c16371..1546672eb5 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -150,7 +150,7 @@ public function detail() { $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); - if (!empty($this->get['recount'])) { + if (!empty($this->post['recount'])) { echo 'recount triggered'; $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); diff --git a/views/job/detail.php b/views/job/detail.php index 834645130c..e89005dbe8 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -231,8 +231,7 @@ function updateProgress() {
- - +
From 73e8ff09ed8b3e0a9e19ef8aee7be8ba3cf10a8a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 21 Jul 2024 21:21:37 +0200 Subject: [PATCH 272/644] implementing features --- controllers/job.php | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/job.php b/controllers/job.php index 1546672eb5..9798c68f87 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -151,7 +151,6 @@ public function detail() { $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); if (!empty($this->post['recount'])) { - echo 'recount triggered'; $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); } From 863e8812d82643fe5c52145ad5614e0762aadc1c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:12:03 +0200 Subject: [PATCH 273/644] implementing features --- controllers/evaluation.php | 8 ++++++-- views/evaluation/detail.php | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index b0070838ca..054f759ed6 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -159,15 +159,19 @@ public function detail() { $isFinished = false; } else { $resultsAvailable = true; - //$logalyzer = new Logalyzer_Library($subJob); - //$logalyzer-> } } if (sizeof($jobs) == 0) { $isFinished = false; } + $system = Factory::getSystemFactory()->get($experiment->getSystemId()); + $systemHash = hash('sha1', $system->getLogalyzerPatterns()); + $this->view->assign('systemHash', $systemHash); $this->view->assign('isFinished', $isFinished); $this->view->assign('resultsAvailable', $resultsAvailable); + if (!empty($this->post['recount'])) { + echo 'we are here'; + } } else { throw new Exception("No evaluation with id: " . $this->get['id']); } diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 20abf46e63..461f965d64 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -232,7 +232,13 @@ function submitData() { getStatus() == Define::JOB_STATUS_FINISHED) { ?> - + + getLogalyzerHash() != $data['systemHash']) { ?> +
+ +
+ + From b883c6c355ce433916a522299c41c2ccd0855cd1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:13:33 +0200 Subject: [PATCH 274/644] implementing features --- views/evaluation/detail.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 461f965d64..c89ba4ad8f 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -234,9 +234,11 @@ function submitData() { getLogalyzerHash() != $data['systemHash']) { ?> -
- -
+ hashdifference +
+ +
+
From 6c3218c7f4338904c4a18b6fd1184bbbb8f8414c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:15:45 +0200 Subject: [PATCH 275/644] implementing features --- views/evaluation/detail.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index c89ba4ad8f..57c41c325b 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -231,17 +231,16 @@ function submitData() { getStatus() == Define::JOB_STATUS_FINISHED) { ?> - - - getLogalyzerHash() != $data['systemHash']) { ?> - hashdifference -
- -
-
- - + + getLogalyzerHash() != $data['systemHash']) { ?> + hashdifference +
+ +
+
+ + From 0a22328ddc0384b28e94a9d58ff23d46579baaae Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:19:14 +0200 Subject: [PATCH 276/644] implementing features --- controllers/evaluation.php | 4 +++- views/evaluation/detail.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 054f759ed6..326caa13e9 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -170,7 +170,9 @@ public function detail() { $this->view->assign('isFinished', $isFinished); $this->view->assign('resultsAvailable', $resultsAvailable); if (!empty($this->post['recount'])) { - echo 'we are here'; + echo 'jobID=' . $this->post['jobId']; + $logalyzer = new Logalyzer_Library($this->post['jobId']); + $logalyzer->examineEntireLog(); } } else { throw new Exception("No evaluation with id: " . $this->get['id']); diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 57c41c325b..2cf708f553 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -236,6 +236,7 @@ function submitData() { getLogalyzerHash() != $data['systemHash']) { ?> hashdifference
+
From 0503ee937d281d2fa95a7f7bd9a7db4b76a4892c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:21:34 +0200 Subject: [PATCH 277/644] implementing features --- controllers/evaluation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 326caa13e9..f3ad81019d 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -170,8 +170,8 @@ public function detail() { $this->view->assign('isFinished', $isFinished); $this->view->assign('resultsAvailable', $resultsAvailable); if (!empty($this->post['recount'])) { - echo 'jobID=' . $this->post['jobId']; - $logalyzer = new Logalyzer_Library($this->post['jobId']); + $job = Factory::getJobFactory()->get($this->post['jobId']); + $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); } } else { From 8b072ea7cc0ab3b9d673595091a1b37c06c79207 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:23:56 +0200 Subject: [PATCH 278/644] implementing features --- views/evaluation/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 2cf708f553..32fab6bf30 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -234,10 +234,10 @@ function submitData() { getLogalyzerHash() != $data['systemHash']) { ?> - hashdifference + getLogalyzerHash() . " and " . $data['systemHash']?>
- +
From 90ec0c55e3f54742ac8207270dfa589f2b204d39 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:27:14 +0200 Subject: [PATCH 279/644] implementing features --- controllers/evaluation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index f3ad81019d..6d924ec743 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -165,6 +165,7 @@ public function detail() { $isFinished = false; } $system = Factory::getSystemFactory()->get($experiment->getSystemId()); + print_r($system->getLogalyzerPatterns()); $systemHash = hash('sha1', $system->getLogalyzerPatterns()); $this->view->assign('systemHash', $systemHash); $this->view->assign('isFinished', $isFinished); From a08efab5e9a45f25fa6984f65f86da12b878f5e1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:31:17 +0200 Subject: [PATCH 280/644] implementing features --- controllers/evaluation.php | 2 ++ libraries/logalyzer.php | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 6d924ec743..e46935f324 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -173,6 +173,8 @@ public function detail() { if (!empty($this->post['recount'])) { $job = Factory::getJobFactory()->get($this->post['jobId']); $logalyzer = new Logalyzer_Library($job); + $decoded = $logalyzer->getPatterns('all'); + print_r(json_encode($decoded)); $logalyzer->examineEntireLog(); } } else { diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 873d2f224e..8c6a772e58 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -149,7 +149,9 @@ public function getPatterns($identifier) { $patterns = $this->system->getLogalyzerPatterns(); if ($patterns != null) { $this->data = json_decode($patterns, true); - if ($identifier === 'warning') { + if ($identifier === 'all') { + return $this->data; + }elseif ($identifier === 'warning') { return $this->data['warningPattern']; } elseif ($identifier === 'error') { return $this->data['errorPattern']; From f26a10dfad30d022e2354f91bee11c4ab55a7cc3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:32:43 +0200 Subject: [PATCH 281/644] implementing features --- controllers/evaluation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index e46935f324..63ef112193 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -165,7 +165,7 @@ public function detail() { $isFinished = false; } $system = Factory::getSystemFactory()->get($experiment->getSystemId()); - print_r($system->getLogalyzerPatterns()); + print_r(hash('sha1', $system->getLogalyzerPatterns())); $systemHash = hash('sha1', $system->getLogalyzerPatterns()); $this->view->assign('systemHash', $systemHash); $this->view->assign('isFinished', $isFinished); @@ -174,7 +174,7 @@ public function detail() { $job = Factory::getJobFactory()->get($this->post['jobId']); $logalyzer = new Logalyzer_Library($job); $decoded = $logalyzer->getPatterns('all'); - print_r(json_encode($decoded)); + print_r(hash('sha1', json_encode($decoded))); $logalyzer->examineEntireLog(); } } else { From 67cdd6cf2aee4b2534864127760a5d2a92b84fad Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:34:11 +0200 Subject: [PATCH 282/644] implementing features --- controllers/evaluation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 63ef112193..d95a6d8bfb 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -165,7 +165,7 @@ public function detail() { $isFinished = false; } $system = Factory::getSystemFactory()->get($experiment->getSystemId()); - print_r(hash('sha1', $system->getLogalyzerPatterns())); + print_r(hash('sha1', json_decode($system->getLogalyzerPatterns()))); $systemHash = hash('sha1', $system->getLogalyzerPatterns()); $this->view->assign('systemHash', $systemHash); $this->view->assign('isFinished', $isFinished); @@ -174,7 +174,7 @@ public function detail() { $job = Factory::getJobFactory()->get($this->post['jobId']); $logalyzer = new Logalyzer_Library($job); $decoded = $logalyzer->getPatterns('all'); - print_r(hash('sha1', json_encode($decoded))); + print_r(hash('sha1', $decoded)); $logalyzer->examineEntireLog(); } } else { From 08a1574de6a0905ba9c13469c9a29b4b6d560e10 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:36:14 +0200 Subject: [PATCH 283/644] implementing features --- controllers/evaluation.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index d95a6d8bfb..e836e893ca 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -165,7 +165,9 @@ public function detail() { $isFinished = false; } $system = Factory::getSystemFactory()->get($experiment->getSystemId()); - print_r(hash('sha1', json_decode($system->getLogalyzerPatterns()))); + print_r($system->getLogalyzerPatterns()); + echo ' equals a hash of: '; + print_r(hash('sha1', $system->getLogalyzerPatterns())); $systemHash = hash('sha1', $system->getLogalyzerPatterns()); $this->view->assign('systemHash', $systemHash); $this->view->assign('isFinished', $isFinished); @@ -174,6 +176,8 @@ public function detail() { $job = Factory::getJobFactory()->get($this->post['jobId']); $logalyzer = new Logalyzer_Library($job); $decoded = $logalyzer->getPatterns('all'); + print_r($decoded); + echo ' equals a hash of: '; print_r(hash('sha1', $decoded)); $logalyzer->examineEntireLog(); } From 9ffaf79bd43bd754aece89441ca3e57dc243e2e8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:37:52 +0200 Subject: [PATCH 284/644] implementing features --- controllers/evaluation.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index e836e893ca..95b5e4d2f8 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -176,9 +176,10 @@ public function detail() { $job = Factory::getJobFactory()->get($this->post['jobId']); $logalyzer = new Logalyzer_Library($job); $decoded = $logalyzer->getPatterns('all'); - print_r($decoded); + print_r(json_encode($decoded)); + $encoded = json_encode($decoded); echo ' equals a hash of: '; - print_r(hash('sha1', $decoded)); + print_r(hash('sha1', $encoded)); $logalyzer->examineEntireLog(); } } else { From 0e4c9bae6f3a2ecb09d1f2b9a667431191a89399 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:46:42 +0200 Subject: [PATCH 285/644] implementing features --- controllers/evaluation.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 95b5e4d2f8..d1cea99bde 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -166,9 +166,10 @@ public function detail() { } $system = Factory::getSystemFactory()->get($experiment->getSystemId()); print_r($system->getLogalyzerPatterns()); + $systemHash = json_encode(json_decode($system->getLogalyzerPatterns()), true); echo ' equals a hash of: '; print_r(hash('sha1', $system->getLogalyzerPatterns())); - $systemHash = hash('sha1', $system->getLogalyzerPatterns()); + $systemHash = hash('sha1', $systemHash); $this->view->assign('systemHash', $systemHash); $this->view->assign('isFinished', $isFinished); $this->view->assign('resultsAvailable', $resultsAvailable); From 8fb237aad22f2348e5fa328125b7b3ad93eb8bb7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:49:52 +0200 Subject: [PATCH 286/644] implementing features --- controllers/evaluation.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index d1cea99bde..88d10cc026 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -164,23 +164,21 @@ public function detail() { if (sizeof($jobs) == 0) { $isFinished = false; } + $system = Factory::getSystemFactory()->get($experiment->getSystemId()); - print_r($system->getLogalyzerPatterns()); + // Shenanigans to normalize whitespaces and newlines $systemHash = json_encode(json_decode($system->getLogalyzerPatterns()), true); - echo ' equals a hash of: '; - print_r(hash('sha1', $system->getLogalyzerPatterns())); $systemHash = hash('sha1', $systemHash); $this->view->assign('systemHash', $systemHash); + $this->view->assign('isFinished', $isFinished); $this->view->assign('resultsAvailable', $resultsAvailable); + + // Button press to reexamine entire log + // Button only shows up if the job examined using an outdated pattern (or none) if (!empty($this->post['recount'])) { $job = Factory::getJobFactory()->get($this->post['jobId']); $logalyzer = new Logalyzer_Library($job); - $decoded = $logalyzer->getPatterns('all'); - print_r(json_encode($decoded)); - $encoded = json_encode($decoded); - echo ' equals a hash of: '; - print_r(hash('sha1', $encoded)); $logalyzer->examineEntireLog(); } } else { From 9b13fea3fef3bd5d7105b8520833cf91adfd56ae Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:50:23 +0200 Subject: [PATCH 287/644] implementing features --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 32fab6bf30..ef85ab215c 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -234,7 +234,7 @@ function submitData() { getLogalyzerHash() != $data['systemHash']) { ?> - getLogalyzerHash() . " and " . $data['systemHash']?> +
From da54b4e23eeac26cde9e6454d3b0a5c4733c4616 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:52:06 +0200 Subject: [PATCH 288/644] implementing features --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index ef85ab215c..938492e171 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -237,7 +237,7 @@ function submitData() { - + From 069b4df1204c5d4ce0de507acd963d80d5142c16 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 14:52:51 +0200 Subject: [PATCH 289/644] implementing features --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 938492e171..21806281c3 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -237,7 +237,7 @@ function submitData() {
- +
From 7d1b5bf51bcf2ffc3ec6afd31cb53608cde46147 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:01:30 +0200 Subject: [PATCH 290/644] implementing features --- controllers/evaluation.php | 26 +++++++++++++++++++------- views/evaluation/detail.php | 6 +++++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 88d10cc026..11d18c2ed9 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -151,6 +151,13 @@ public function detail() { $this->view->assign('subjobs', $jobs); $sys = new System($evaluation->getSystemId()); $this->view->assign('supportsShowResults', $sys->supportsFullResults()); + $system = Factory::getSystemFactory()->get($experiment->getSystemId()); + // Shenanigans to normalize whitespaces and newlines + $systemHash = json_encode(json_decode($system->getLogalyzerPatterns()), true); + $systemHash = hash('sha1', $systemHash); + $this->view->assign('systemHash', $systemHash); + $usedOutdatedPattern = false; + // check if all jobs have finished $isFinished = true; $resultsAvailable = false; @@ -160,17 +167,16 @@ public function detail() { } else { $resultsAvailable = true; } + if($subJob->getLogalyzerHash() != $systemHash) { + $usedOutdatedPattern = true; + } } if (sizeof($jobs) == 0) { $isFinished = false; } - - $system = Factory::getSystemFactory()->get($experiment->getSystemId()); - // Shenanigans to normalize whitespaces and newlines - $systemHash = json_encode(json_decode($system->getLogalyzerPatterns()), true); - $systemHash = hash('sha1', $systemHash); - $this->view->assign('systemHash', $systemHash); - + if ($usedOutdatedPattern) { + $this->view->assign('usedOutdatedPattern', true); + } $this->view->assign('isFinished', $isFinished); $this->view->assign('resultsAvailable', $resultsAvailable); @@ -181,6 +187,12 @@ public function detail() { $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); } + if (!empty($this->post['recountAll'])) { + foreach ($jobs as $subJob) { + $logalyzer = new Logalyzer_Library($subJob); + $logalyzer->examineEntireLog(); + } + } } else { throw new Exception("No evaluation with id: " . $this->get['id']); } diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 21806281c3..c819fb029d 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -190,7 +190,11 @@ function submitData() {
-

Jobs

+

Jobs +
+ +
+

From 9d9bc656a8136103c7912d4f4123830a9db83638 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:03:58 +0200 Subject: [PATCH 291/644] implementing features --- views/evaluation/detail.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index c819fb029d..745fe165a6 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -190,11 +190,10 @@ function submitData() {
-

Jobs -
- - -

+

Jobs

+
+ +
From 5704e0047437dbf89218dddd04a44cf2f07c2bb1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:05:22 +0200 Subject: [PATCH 292/644] implementing features --- views/evaluation/detail.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 745fe165a6..c3ab52fcb1 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -191,9 +191,11 @@ function submitData() {

Jobs

-
- - + +
+ + +
From 89d94963034c341fde93f1587517e570fbaeee21 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:06:02 +0200 Subject: [PATCH 293/644] implementing features --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index c3ab52fcb1..7fa42e56f8 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -191,7 +191,7 @@ function submitData() {

Jobs

- +
From 00ab30b3e51f4593a3dbfaa58b225a3715d07609 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:07:49 +0200 Subject: [PATCH 294/644] implementing features --- views/evaluation/detail.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 7fa42e56f8..87ce183ba6 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -221,6 +221,7 @@ function submitData() { +
+ @@ -237,7 +238,8 @@ function submitData() { getStatus() == Define::JOB_STATUS_FINISHED) { ?> - + +
getStatus() == Define::JOB_STATUS_SCHEDULED) { ?> scheduled From 84b96d5bd634e1db3db69a958399313c39606b13 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:10:28 +0200 Subject: [PATCH 295/644] implementing features --- views/evaluation/detail.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 87ce183ba6..deca8f3e0c 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -207,6 +207,7 @@ function submitData() { Status
getLogalyzerHash() != $data['systemHash']) { ?> From 3202b072829ef9c700322466ac9595fd50e04495 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:15:19 +0200 Subject: [PATCH 296/644] implementing features --- views/evaluation/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index deca8f3e0c..9836579018 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -192,7 +192,7 @@ function submitData() {

Jobs

-
+
@@ -243,7 +243,7 @@ function submitData() {
getLogalyzerHash() != $data['systemHash']) { ?> -
+
From 4f2d9e428445e052afa6d4be2cd13717a7c949a3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:16:44 +0200 Subject: [PATCH 297/644] implementing features --- views/evaluation/detail.php | 1 - 1 file changed, 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 9836579018..21f061da19 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -254,7 +254,6 @@ function submitData() {
-
From 11458358e29f58ed9bfed622fb33961b36f84908 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:22:06 +0200 Subject: [PATCH 298/644] implementing features --- controllers/evaluation.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 11d18c2ed9..8a2f3e0135 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -191,6 +191,8 @@ public function detail() { foreach ($jobs as $subJob) { $logalyzer = new Logalyzer_Library($subJob); $logalyzer->examineEntireLog(); + header('Location: ' . $_SERVER['PHP_SELF']); + exit; } } } else { From 9c341f5f255ff5fe5f0ffc0ed620fc8c4ace6801 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:22:16 +0200 Subject: [PATCH 299/644] implementing features --- controllers/evaluation.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 8a2f3e0135..cfd32b15d8 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -186,6 +186,8 @@ public function detail() { $job = Factory::getJobFactory()->get($this->post['jobId']); $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); + header('Location: ' . $_SERVER['PHP_SELF']); + exit; } if (!empty($this->post['recountAll'])) { foreach ($jobs as $subJob) { From 716105e0380586292a72111abffe8cbca336c08c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 15:23:04 +0200 Subject: [PATCH 300/644] implementing features --- controllers/evaluation.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index cfd32b15d8..11d18c2ed9 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -186,15 +186,11 @@ public function detail() { $job = Factory::getJobFactory()->get($this->post['jobId']); $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); - header('Location: ' . $_SERVER['PHP_SELF']); - exit; } if (!empty($this->post['recountAll'])) { foreach ($jobs as $subJob) { $logalyzer = new Logalyzer_Library($subJob); $logalyzer->examineEntireLog(); - header('Location: ' . $_SERVER['PHP_SELF']); - exit; } } } else { From 219d612c77594faf1f74de0209409e98b70cfc37 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 16:08:07 +0200 Subject: [PATCH 301/644] implementing features --- libraries/dba/AbstractModelFactory.class.php | 12 ++++++++++ libraries/logalyzer.php | 23 ++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 862d0ec191..a4f224bdb9 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -775,5 +775,17 @@ public function getDB($test = false) { die("Fatal Error! Database connection failed. Message: " . $e->getMessage()); } } + public function incrementJobError($identifier, $jobId) { + $query = ""; + if ($identifier == 'error') { + $query = "UPDATE Job SET logalyzerErrorCount=logalyzerErrorCount+1 WHERE jobId=?"; + } + elseif ($identifier == 'warning') { + $query = "UPDATE Job SET logalyzerWarningCount=logalyzerWarningCount+1 WHERE jobId=?"; + } else { echo 'No identifier'; } + $dbh = self::getDB(); + $stmt = $dbh->prepare($query); + $stmt->execute([$jobId]); + } } diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 8c6a772e58..fd99158bee 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -51,8 +51,7 @@ public function countLogOccurances(string $keyword, string $target, bool $regex } private function checkHashDifference() { - // TODO check if returns the right value - return !($this->job->getLogalyzerHash() === hash('sha1', $this->data)); + return !($this->job->getLogalyzerHash() === hash('sha1', json_encode('sha1', $this->data))); } public function examineEntireLog() { @@ -108,27 +107,23 @@ public function examineLogLine($logLine) { // TODO change to constant when available while ($this->job->getLogalyzerCountWarnings <= $LOG_ERRORS_MAX && $this->job->getLogalyzerCountErrors <= $LOG_ERRORS_MAX) { foreach ($this->warningPatterns['regex'] as $key) { - for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountWarnings(); + if ($this->countLogOccurances($key, $logLine, true) > 0) { + $this->job->incrementJobError('warning', $this->job->getId()); } } foreach ($this->warningPatterns['string'] as $key) { - for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountWarnings(); + if ($this->countLogOccurances($key, $logLine) > 0) { + $this->job->incrementJobError('warning', $this->job->getId()); } } foreach ($this->errorPatterns['regex'] as $key) { - for ($i = 0; $i < $this->countLogOccurances($key, $logLine, true); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountErrors(); + if ($this->countLogOccurances($key, $logLine, true) > 0) { + $this->job->incrementJobError('error', $this->job->getId()); } } foreach ($this->errorPatterns['string'] as $key) { - for ($i = 0; $i < $this->countLogOccurances($key, $logLine); $i++) { - // TODO implement increment - $this->job->incrementLogalyzerCountErrors(); + if ($this->countLogOccurances($key, $logLine) > 0) { + $this->job->incrementJobError('error', $this->job->getId()); } } } From facf5841c3cbe219e31f168bef9f8ababb50e8f7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 16:09:09 +0200 Subject: [PATCH 302/644] implementing features --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index fd99158bee..4977f9dcaa 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -21,6 +21,7 @@ public function __construct($job = null) { if($this->job != null) { $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); $this->loadPatterns(); + $this->job->incrementJobError('warning', $this->job->getId()); } } public function getJob() { From bcd66675b9f51d793ecbb43ae8bf425b319b3f57 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 16:13:24 +0200 Subject: [PATCH 303/644] implementing features --- libraries/logalyzer.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4977f9dcaa..4d818067c2 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -21,7 +21,7 @@ public function __construct($job = null) { if($this->job != null) { $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); $this->loadPatterns(); - $this->job->incrementJobError('warning', $this->job->getId()); + Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); } } public function getJob() { @@ -109,22 +109,22 @@ public function examineLogLine($logLine) { while ($this->job->getLogalyzerCountWarnings <= $LOG_ERRORS_MAX && $this->job->getLogalyzerCountErrors <= $LOG_ERRORS_MAX) { foreach ($this->warningPatterns['regex'] as $key) { if ($this->countLogOccurances($key, $logLine, true) > 0) { - $this->job->incrementJobError('warning', $this->job->getId()); + Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); } } foreach ($this->warningPatterns['string'] as $key) { if ($this->countLogOccurances($key, $logLine) > 0) { - $this->job->incrementJobError('warning', $this->job->getId()); + Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); } } foreach ($this->errorPatterns['regex'] as $key) { if ($this->countLogOccurances($key, $logLine, true) > 0) { - $this->job->incrementJobError('error', $this->job->getId()); + Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); } } foreach ($this->errorPatterns['string'] as $key) { if ($this->countLogOccurances($key, $logLine) > 0) { - $this->job->incrementJobError('error', $this->job->getId()); + Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); } } } From 7a06b77428531871c70cd92fc7b6181bb769b7b4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 16:14:46 +0200 Subject: [PATCH 304/644] implementing features --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4d818067c2..c01a650561 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -21,7 +21,6 @@ public function __construct($job = null) { if($this->job != null) { $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); $this->loadPatterns(); - Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); } } public function getJob() { @@ -101,6 +100,7 @@ public function examineEntireLog() { $this->job->setLogalyzerErrorCount($errorCount); $this->job->setLogalyzerHash($hash); Factory::getJobFactory()->update($this->job); + Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); } public function examineLogLine($logLine) { From 405ba3f70e0fb4672d4ca56af2a04f8f1ff890d5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 16:15:25 +0200 Subject: [PATCH 305/644] implementing features --- libraries/logalyzer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c01a650561..3ef81bfb73 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -100,7 +100,6 @@ public function examineEntireLog() { $this->job->setLogalyzerErrorCount($errorCount); $this->job->setLogalyzerHash($hash); Factory::getJobFactory()->update($this->job); - Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); } public function examineLogLine($logLine) { From a4abf2f6366be4955b2cbb23f7c7f6860193f53e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 16:20:14 +0200 Subject: [PATCH 306/644] implementing features --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 21f061da19..11167cd531 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -193,7 +193,7 @@ function submitData() {

Jobs

- +
From d835b945d26f148d5d6c150e2c90398aa97e66a5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 22 Jul 2024 16:31:54 +0200 Subject: [PATCH 307/644] implementing features --- libraries/logalyzer.php | 45 +++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 3ef81bfb73..b1e2c91943 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -3,7 +3,9 @@ use DBA\Factory; /** - * Analyze the log of a Chronos job using predefined keywords + * Analyze the log of a Chronos job + * Keywords can be customized in the 'Systems' UI + * Results are shown inside a job's detail page */ class Logalyzer_Library { private $job; @@ -54,6 +56,10 @@ private function checkHashDifference() { return !($this->job->getLogalyzerHash() === hash('sha1', json_encode('sha1', $this->data))); } + /** + * Load and read the entire logfile counting the occurances of the pattern words and saving the result in the database + * @return void + */ public function examineEntireLog() { $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId() . '.log'; $log = Util::readFileContents($path); @@ -102,6 +108,12 @@ public function examineEntireLog() { Factory::getJobFactory()->update($this->job); } + /** + * Reads a single logLine and increments error/warnings counters if a pattern word is present inside. + * Number or occurances does not matter for now. One error logLine is considered one potential error event. + * @param $logLine + * @return void + */ public function examineLogLine($logLine) { $LOG_ERRORS_MAX = 10; // TODO change to constant when available @@ -128,6 +140,11 @@ public function examineLogLine($logLine) { } } } + + /** + * Creates empty pattern objects + * @return void + */ private function createBasicPatterns() { $this->data['warningPattern'] = ['string' => [], 'regex' => []]; $this->data['errorPattern'] = ['string' => [], 'regex' => []]; @@ -136,6 +153,13 @@ private function createBasicPatterns() { $this->errorPatterns['string'] = []; $this->errorPatterns['regex'] = []; } + + /** + * Returns the arrays containing pattern + * $identifier can be 'all', 'warning' or 'error' + * @param $identifier + * @return array|mixed + */ public function getPatterns($identifier) { if($this->system->getLogalyzerPatterns() == null) { $this->createBasicPatterns(); @@ -159,6 +183,12 @@ public function getPatterns($identifier) { return []; } } + + /** + * Fetches the json object containing the systems pattern from the database. + * Decodes the json object and populates local variables or creates an empty pattern if database returns null object + * @return void + */ public function loadPatterns() { $patterns = $this->system->getLogalyzerPatterns(); if ($patterns != null) { @@ -172,6 +202,12 @@ public function loadPatterns() { $this->savePatterns(); } } + + /** + * Saves a modified pattern to the systems database table + * Is called when patterns changed + * @return void + */ private function savePatterns() { $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; @@ -237,11 +273,4 @@ public function removeKey(string $identifier, string $type, string $key) function calculateHash() { return hash('sha1', json_encode($this->data)); } - - /** - * @return string - */ - function getHash() { - return $this->job->getLogalyzerHash(); - } } From d8246a564c58397de2d99f51ae66f3dc2d57fa64 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 12:46:36 +0200 Subject: [PATCH 308/644] implementing features --- controllers/evaluation.php | 29 +++++++++++++++-------------- controllers/job.php | 8 ++++---- views/evaluation/detail.php | 4 ++-- views/job/detail.php | 6 +++--- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 11d18c2ed9..088c158030 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -152,6 +152,21 @@ public function detail() { $sys = new System($evaluation->getSystemId()); $this->view->assign('supportsShowResults', $sys->supportsFullResults()); $system = Factory::getSystemFactory()->get($experiment->getSystemId()); + + // Button press to reexamine entire log + // Button only shows up if the job examined using an outdated pattern (or none) + if (!empty($this->post['recheck'])) { + $job = Factory::getJobFactory()->get($this->post['jobId']); + $logalyzer = new Logalyzer_Library($job); + $logalyzer->examineEntireLog(); + } + if (!empty($this->post['recheckAll'])) { + foreach ($jobs as $subJob) { + $logalyzer = new Logalyzer_Library($subJob); + $logalyzer->examineEntireLog(); + } + } + // Shenanigans to normalize whitespaces and newlines $systemHash = json_encode(json_decode($system->getLogalyzerPatterns()), true); $systemHash = hash('sha1', $systemHash); @@ -179,20 +194,6 @@ public function detail() { } $this->view->assign('isFinished', $isFinished); $this->view->assign('resultsAvailable', $resultsAvailable); - - // Button press to reexamine entire log - // Button only shows up if the job examined using an outdated pattern (or none) - if (!empty($this->post['recount'])) { - $job = Factory::getJobFactory()->get($this->post['jobId']); - $logalyzer = new Logalyzer_Library($job); - $logalyzer->examineEntireLog(); - } - if (!empty($this->post['recountAll'])) { - foreach ($jobs as $subJob) { - $logalyzer = new Logalyzer_Library($subJob); - $logalyzer->examineEntireLog(); - } - } } else { throw new Exception("No evaluation with id: " . $this->get['id']); } diff --git a/controllers/job.php b/controllers/job.php index 9798c68f87..5a4bb3d7ac 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -143,6 +143,10 @@ public function detail() { $this->view->assign('evaluation', $evaluation); $this->view->assign('experiment', Factory::getExperimentFactory()->get($evaluation->getExperimentId())); + if (!empty($this->post['recount'])) { + $logalyzer = new Logalyzer_Library($job); + $logalyzer->examineEntireLog(); + } $warnings = $job->getLogalyzerWarningCount(); $errors = $job->getLogalyzerErrorCount(); $this->view->assign('logWarnings', $warnings); @@ -150,10 +154,6 @@ public function detail() { $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); - if (!empty($this->post['recount'])) { - $logalyzer = new Logalyzer_Library($job); - $logalyzer->examineEntireLog(); - } } else { throw new Exception("No job with id: " . $this->get['id']); } diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 11167cd531..0a8ec8ab39 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -193,7 +193,7 @@ function submitData() {

Jobs

- +
@@ -245,7 +245,7 @@ function submitData() {
- +
diff --git a/views/job/detail.php b/views/job/detail.php index e89005dbe8..15d38b3748 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -224,14 +224,14 @@ function updateProgress() {
- Errors: = 0) { echo($data['logErrors']); } ?> + Errors: = 0) { echo($data['logErrorCount']); } ?>
- Warnings: = 0) { echo($data['logWarnings']);} ?> + Warnings: = 0) { echo($data['logWarningCount']);} ?>
- +
From f9c36602faef6b23060b63c3927591ff8b6b4f4b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 12:55:42 +0200 Subject: [PATCH 309/644] implementing features --- controllers/job.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 5a4bb3d7ac..47453b2d69 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -143,14 +143,14 @@ public function detail() { $this->view->assign('evaluation', $evaluation); $this->view->assign('experiment', Factory::getExperimentFactory()->get($evaluation->getExperimentId())); - if (!empty($this->post['recount'])) { + if (!empty($this->post['recheck'])) { $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); } $warnings = $job->getLogalyzerWarningCount(); $errors = $job->getLogalyzerErrorCount(); - $this->view->assign('logWarnings', $warnings); - $this->view->assign('logErrors', $errors); + $this->view->assign('logWarningCount', $warnings); + $this->view->assign('logErrorCount', $errors); $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); From beea55a2be84492c17c1f673215ccc251a4e6f54 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:06:58 +0200 Subject: [PATCH 310/644] implementing features --- views/admin/system.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/admin/system.php b/views/admin/system.php index 13f7ce179e..1755429ecd 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,6 +470,7 @@
+
From 0d54fd8afbd326934e7f5a1cda332c2b197c1e62 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:08:20 +0200 Subject: [PATCH 311/644] implementing features --- views/admin/system.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 1755429ecd..54872d933c 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,7 +470,9 @@
- + + +
From 645dd7fc985e5d3319a5e9e24ed0d21d946b3f9f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:10:24 +0200 Subject: [PATCH 312/644] implementing features --- views/admin/system.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 54872d933c..9445a3bed1 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,9 +470,7 @@
- - - +
From 1a4aae67b6b5390cd67cbcfaccc49ab8f78a5421 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:12:22 +0200 Subject: [PATCH 313/644] implementing features --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 9445a3bed1..8ecf9ff9c0 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,7 +470,7 @@
- +
From 07ad21a15632d004ed955992e19460a484532fe1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:13:15 +0200 Subject: [PATCH 314/644] implementing features --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 8ecf9ff9c0..3fa975fb4f 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,7 +470,7 @@
- +
From 808f4b1208ad4199f944b33494785fed7e0e0dcf Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:13:34 +0200 Subject: [PATCH 315/644] implementing features --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 3fa975fb4f..e3e9e17b56 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,7 +470,7 @@
- +
From 6cb7d334c195c55839bd64d064199216a48eecbd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:13:58 +0200 Subject: [PATCH 316/644] implementing features --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index e3e9e17b56..616424166e 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,7 +470,7 @@
- +
From 6ff76d16e729a34139157cee87ef6fec5435800c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:14:19 +0200 Subject: [PATCH 317/644] implementing features --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 616424166e..40d119893e 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,7 +470,7 @@
- +
From 752cc681480db2a6a6e6d8093ead77d675c7b156 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:15:36 +0200 Subject: [PATCH 318/644] implementing features --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 40d119893e..b5eac871de 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,7 +470,7 @@
- +
From 089360851d2cd1ffa12fa25ea4582770fba1fd03 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:16:19 +0200 Subject: [PATCH 319/644] implementing features --- views/admin/system.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index b5eac871de..dcd19bc956 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,7 +470,8 @@
- + + Regex
From bcfbff743f12e65b30c99a48c37ea75ead89b022 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:17:08 +0200 Subject: [PATCH 320/644] implementing features --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index dcd19bc956..c398b3e73b 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,8 +470,8 @@
- - Regex + + Regex
From c6058b04ed8c1ce572752812817b2d806434e5c8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:17:44 +0200 Subject: [PATCH 321/644] implementing features --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index c398b3e73b..81bdefe946 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -471,7 +471,7 @@ - Regex + Regex
From 79998a1369079aacb520a9b02c2c560a62330d87 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:18:11 +0200 Subject: [PATCH 322/644] implementing features --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 81bdefe946..fdb3f9167d 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,8 +470,8 @@
- - Regex + + Regex
From 56f66d7903c1ae71400af3a51ef187a037bc6fb4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:18:33 +0200 Subject: [PATCH 323/644] implementing features --- views/admin/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index fdb3f9167d..3c86afa2af 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -471,7 +471,7 @@ - Regex + Regex
From a15d13118c88e8ddea7421260ee388c73df0ada6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:20:14 +0200 Subject: [PATCH 324/644] implementing features --- views/admin/system.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/views/admin/system.php b/views/admin/system.php index 3c86afa2af..4a64f551b8 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,7 +470,7 @@
- + Regex
@@ -506,6 +506,8 @@ + + Regex
From d278ca3e95b7903dffbcd32a12c14e0b83ec0490 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:20:54 +0200 Subject: [PATCH 325/644] implementing features --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 4a64f551b8..4456b07ff0 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -506,8 +506,8 @@ - - Regex + + Regex
From 088b9f72584ef8765c50fcf58bc7d814c11527a5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:21:18 +0200 Subject: [PATCH 326/644] implementing features --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 4456b07ff0..f28a14f7fc 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -506,8 +506,8 @@ - - Regex + + Regex
From 4d942cca918f39d854cabd9c31ef601fb29ac9ab Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:22:46 +0200 Subject: [PATCH 327/644] implementing features --- views/admin/system.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index f28a14f7fc..6cc1c520f8 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -470,10 +470,10 @@
- - Regex
+ + Regex
@@ -506,10 +506,10 @@ - - Regex
+ + Regex
From 6e667e628e83c0c773825ddf5777832737db5d14 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:23:56 +0200 Subject: [PATCH 328/644] implementing features --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 6cc1c520f8..83f5133735 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -469,11 +469,11 @@
+ + Regex
- - Regex
From cbb675b7a2ed4c9eff798455bda68459c942fba4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:24:55 +0200 Subject: [PATCH 329/644] implementing features --- views/admin/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 83f5133735..a726967363 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -469,11 +469,11 @@
- - Regex
+ + Regex
From 7ad9194ec14314ab4476695db5e1df6e8d892cfc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:33:37 +0200 Subject: [PATCH 330/644] implementing features --- controllers/admin.php | 26 ++++++++------------------ libraries/logalyzer.php | 21 +++++++++++++-------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 507a7b24b5..81e9c82723 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -396,10 +396,10 @@ public function system() { $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); // $key contains just letters and numbers? - if(preg_match('/^[a-zA-Z0-9]+$/', $key)) - $logalyzer->addKey('error', 'string', $key); - else { + if(!empty($this->post['regexError'])&&$this->post['regexError']=='on') { $logalyzer->addKey('error', 'regex', $key); + } else { + $logalyzer->addKey('error', 'string', $key); } } } else if (!empty($this->post['group'] == 'newWarning')) { @@ -409,10 +409,10 @@ public function system() { $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); // $key contain just letters and numbers? - if(preg_match('/^[a-zA-Z0-9]+$/', $key)) - $logalyzer->addKey('warning', 'string', $key); - else { + if(!empty($this->post['regexWarning'])&&$this->post['regexWarning']=='on') { $logalyzer->addKey('warning', 'regex', $key); + } else { + $logalyzer->addKey('warning', 'string', $key); } } } @@ -423,12 +423,7 @@ public function system() { $system = Factory::getSystemFactory()->get($this->get['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); - if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { - $logalyzer->removeKey('warning', 'string', $key); - } - else { - $logalyzer->removeKey('warning', 'regex', $key); - } + $logalyzer->removeKey('warning', $key); } } else if (!empty($this->get['deleteErrorPattern'])) { $key = $this->get['deleteErrorPattern']; @@ -436,12 +431,7 @@ public function system() { $system = Factory::getSystemFactory()->get($this->get['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); - if(preg_match('/^[a-zA-Z0-9]+$/', $key)) { - $logalyzer->removeKey('error', 'string', $key); - } - else { - $logalyzer->removeKey('error', 'regex', $key); - } + $logalyzer->removeKey('error', $key); } } else if (!empty($this->get['delete'])) { $settings = Settings_Library::getInstance($system->getId()); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b1e2c91943..5886dbaf60 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -239,25 +239,30 @@ public function addKey(string $identifier, string $type, string $key) { /** * @param string $identifier is $key a warning or error? - * @param string $type 'string' or 'regex' * @param string $key key to delete * @return void */ - public function removeKey(string $identifier, string $type, string $key) - { + public function removeKey(string $identifier, string $key) { if ($this->system == null) { echo 'System not defined\n'; } else { if ($identifier == 'warning') { - if (($index = array_search($key, $this->warningPatterns[$type])) !== false) { - unset($this->warningPatterns[$type][$index]); + if (($index = array_search($key, $this->warningPatterns['string'])) !== false) { + unset($this->warningPatterns['string'][$index]); + } + if (($index = array_search($key, $this->warningPatterns['regex'])) !== false) { + unset($this->warningPatterns['string'][$index]); } } elseif ($identifier == 'error') { - if (($index = array_search($key, $this->errorPatterns[$type])) !== false) { - unset($this->errorPatterns[$type][$index]); - $this->errorPatterns[$type] = array_values($this->errorPatterns[$type]); + if (($index = array_search($key, $this->errorPatterns['string'])) !== false) { + unset($this->errorPatterns['string'][$index]); + $this->errorPatterns['string'] = array_values($this->errorPatterns['string']); + } + if (($index = array_search($key, $this->errorPatterns['regex'])) !== false) { + unset($this->errorPatterns['regex'][$index]); + $this->errorPatterns['regex'] = array_values($this->errorPatterns['regex']); } } else { From 7f534292383b223bea6f3482ae8adab07f15bc42 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:37:27 +0200 Subject: [PATCH 331/644] implementing features --- libraries/logalyzer.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 5886dbaf60..929b888743 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -227,9 +227,14 @@ public function addKey(string $identifier, string $type, string $key) { } else { if ($identifier == 'warning') { - $this->warningPatterns[$type][] = $key; + // Check if $key is already in the array + if (!(array_search($key, $this->warningPatterns[$type]))) { + $this->warningPatterns[$type][] = $key; + } } elseif ($identifier == 'error') { - $this->errorPatterns[$type][] = $key; + if (!(array_search($key, $this->errorPatterns[$type]))) { + $this->errorPatterns[$type][] = $key; + } } else { echo "Error in identifier or isRegex inside logalyzer."; } From 96ad0c2892f4672438d9dd6d7c343f7c19a472d3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:44:17 +0200 Subject: [PATCH 332/644] implementing features --- libraries/logalyzer.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 929b888743..b30cc0da0f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -13,6 +13,7 @@ class Logalyzer_Library { private $log; private $warningPatterns; private $errorPatterns; + private $mustContainPatterns; private $data; /** @@ -148,10 +149,13 @@ public function examineLogLine($logLine) { private function createBasicPatterns() { $this->data['warningPattern'] = ['string' => [], 'regex' => []]; $this->data['errorPattern'] = ['string' => [], 'regex' => []]; + $this->data['mustContainPattern'] = ['string' => [], 'regex' => []]; $this->warningPatterns['string'] = []; $this->warningPatterns['regex'] = []; $this->errorPatterns['string'] = []; $this->errorPatterns['regex'] = []; + $this->mustContainPatterns['string'] = []; + $this->mustContainPatterns['regex'] = []; } /** @@ -174,6 +178,8 @@ public function getPatterns($identifier) { return $this->data['warningPattern']; } elseif ($identifier === 'error') { return $this->data['errorPattern']; + } elseif ($identifier === 'mustContainPattern') { + return $this->data['mustContainPattern']; } else { echo "Error in getpatterns"; return []; @@ -195,6 +201,7 @@ public function loadPatterns() { $this->data = json_decode($patterns, true); $this->warningPatterns = $this->data['warningPattern']; $this->errorPatterns = $this->data['errorPattern']; + $this->mustContainPatterns = $this->data['mustContainPattern']; } else { // Initial load of patterns returned null @@ -211,6 +218,7 @@ public function loadPatterns() { private function savePatterns() { $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; + $this->data['mustContainPattern'] = $this->mustContainPatterns; $encoded = json_encode($this->data); $this->system->setLogalyzerPatterns($encoded); Factory::getSystemFactory()->update($this->system); @@ -235,6 +243,10 @@ public function addKey(string $identifier, string $type, string $key) { if (!(array_search($key, $this->errorPatterns[$type]))) { $this->errorPatterns[$type][] = $key; } + } elseif ($identifier == 'mustContain') { + if (!(array_search($key, $this->mustContainPatterns[$type]))) { + $this->mustContainPatterns[$type][] = $key; + } } else { echo "Error in identifier or isRegex inside logalyzer."; } @@ -270,6 +282,16 @@ public function removeKey(string $identifier, string $key) { $this->errorPatterns['regex'] = array_values($this->errorPatterns['regex']); } } + elseif ($identifier == 'mustContain') { + if (($index = array_search($key, $this->mustContainPatterns['string'])) !== false) { + unset($this->mustContainPatterns['string'][$index]); + $this->mustContainPatterns['string'] = array_values($this->mustContainPatterns['string']); + } + if (($index = array_search($key, $this->mustContainPatterns['regex'])) !== false) { + unset($this->mustContainPatterns['regex'][$index]); + $this->mustContainPatterns['regex'] = array_values($this->mustContainPatterns['regex']); + } + } else { echo "identifier not recognized."; } From 8001e4b5f8585b3e393506f9a92189c8bd198753 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:46:44 +0200 Subject: [PATCH 333/644] implementing features --- libraries/logalyzer.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b30cc0da0f..12f39caf0e 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -218,7 +218,17 @@ public function loadPatterns() { private function savePatterns() { $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; - $this->data['mustContainPattern'] = $this->mustContainPatterns; + + // Can be reduced to only + // $this->data['mustContainPattern'] = $this->mustContainPatterns; + if(isset($this->data['mustContainPattern'])) { + $this->data['mustContainPattern'] = $this->mustContainPatterns; + } + else { + $this->data['mustContainPattern'] = ['string' => [], 'regex' => []]; + $this->mustContainPatterns['string'] = []; + $this->mustContainPatterns['regex'] = []; + } $encoded = json_encode($this->data); $this->system->setLogalyzerPatterns($encoded); Factory::getSystemFactory()->update($this->system); From b96781699a60b52adc41ef214d658070185adf13 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:47:29 +0200 Subject: [PATCH 334/644] implementing features --- libraries/logalyzer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 12f39caf0e..2d82315fdb 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -218,17 +218,17 @@ public function loadPatterns() { private function savePatterns() { $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; - + $this->data['mustContainPattern'] = $this->mustContainPatterns; // Can be reduced to only // $this->data['mustContainPattern'] = $this->mustContainPatterns; - if(isset($this->data['mustContainPattern'])) { + /*if(isset($this->data['mustContainPattern'])) { $this->data['mustContainPattern'] = $this->mustContainPatterns; } else { $this->data['mustContainPattern'] = ['string' => [], 'regex' => []]; $this->mustContainPatterns['string'] = []; $this->mustContainPatterns['regex'] = []; - } + }*/ $encoded = json_encode($this->data); $this->system->setLogalyzerPatterns($encoded); Factory::getSystemFactory()->update($this->system); From 457cc67784361ea97d346bb36d22f64990b4dd4d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:54:51 +0200 Subject: [PATCH 335/644] implementing features --- libraries/logalyzer.php | 37 +++++++++++++++++++++---------------- views/admin/system.php | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 2d82315fdb..9d7292c9e7 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -13,7 +13,7 @@ class Logalyzer_Library { private $log; private $warningPatterns; private $errorPatterns; - private $mustContainPatterns; + private $mandatoryPatterns; private $data; /** @@ -149,13 +149,13 @@ public function examineLogLine($logLine) { private function createBasicPatterns() { $this->data['warningPattern'] = ['string' => [], 'regex' => []]; $this->data['errorPattern'] = ['string' => [], 'regex' => []]; - $this->data['mustContainPattern'] = ['string' => [], 'regex' => []]; + $this->data['mandatoryPattern'] = ['string' => [], 'regex' => []]; $this->warningPatterns['string'] = []; $this->warningPatterns['regex'] = []; $this->errorPatterns['string'] = []; $this->errorPatterns['regex'] = []; - $this->mustContainPatterns['string'] = []; - $this->mustContainPatterns['regex'] = []; + $this->mandatoryPatterns['string'] = []; + $this->mandatoryPatterns['regex'] = []; } /** @@ -178,8 +178,8 @@ public function getPatterns($identifier) { return $this->data['warningPattern']; } elseif ($identifier === 'error') { return $this->data['errorPattern']; - } elseif ($identifier === 'mustContainPattern') { - return $this->data['mustContainPattern']; + } elseif ($identifier === 'mandatoryPattern') { + return $this->data['mandatoryPattern']; } else { echo "Error in getpatterns"; return []; @@ -201,7 +201,7 @@ public function loadPatterns() { $this->data = json_decode($patterns, true); $this->warningPatterns = $this->data['warningPattern']; $this->errorPatterns = $this->data['errorPattern']; - $this->mustContainPatterns = $this->data['mustContainPattern']; + $this->mandatoryPatterns = $this->data['mandatoryPattern']; } else { // Initial load of patterns returned null @@ -218,7 +218,12 @@ public function loadPatterns() { private function savePatterns() { $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; - $this->data['mustContainPattern'] = $this->mustContainPatterns; + + $this->data['mandatoryPattern'] = ['string' => [], 'regex' => []]; + $this->mandatoryPatterns['string'] = []; + $this->mandatoryPatterns['regex'] = []; + + $this->data['mandatoryPattern'] = $this->mandatoryPatterns; // Can be reduced to only // $this->data['mustContainPattern'] = $this->mustContainPatterns; /*if(isset($this->data['mustContainPattern'])) { @@ -254,8 +259,8 @@ public function addKey(string $identifier, string $type, string $key) { $this->errorPatterns[$type][] = $key; } } elseif ($identifier == 'mustContain') { - if (!(array_search($key, $this->mustContainPatterns[$type]))) { - $this->mustContainPatterns[$type][] = $key; + if (!(array_search($key, $this->mandatoryPatterns[$type]))) { + $this->mandatoryPatterns[$type][] = $key; } } else { echo "Error in identifier or isRegex inside logalyzer."; @@ -293,13 +298,13 @@ public function removeKey(string $identifier, string $key) { } } elseif ($identifier == 'mustContain') { - if (($index = array_search($key, $this->mustContainPatterns['string'])) !== false) { - unset($this->mustContainPatterns['string'][$index]); - $this->mustContainPatterns['string'] = array_values($this->mustContainPatterns['string']); + if (($index = array_search($key, $this->mandatoryPatterns['string'])) !== false) { + unset($this->mandatoryPatterns['string'][$index]); + $this->mandatoryPatterns['string'] = array_values($this->mandatoryPatterns['string']); } - if (($index = array_search($key, $this->mustContainPatterns['regex'])) !== false) { - unset($this->mustContainPatterns['regex'][$index]); - $this->mustContainPatterns['regex'] = array_values($this->mustContainPatterns['regex']); + if (($index = array_search($key, $this->mandatoryPatterns['regex'])) !== false) { + unset($this->mandatoryPatterns['regex'][$index]); + $this->mandatoryPatterns['regex'] = array_values($this->mandatoryPatterns['regex']); } } else { diff --git a/views/admin/system.php b/views/admin/system.php index a726967363..95de70a7f1 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -530,6 +530,41 @@
+
+
+
+
+

Mandatory Pattern

+
+
+ + +
+ + + Regex + +
+
+
+ + $array) { + foreach ($array as $key) {?> +
+
+ + + + + + Delete + + +
+
+ +
From 81579b5e4c5930047ba10e97eedfece4f208052a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 13:55:39 +0200 Subject: [PATCH 336/644] implementing features --- libraries/logalyzer.php | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 9d7292c9e7..e677bba34a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -218,22 +218,8 @@ public function loadPatterns() { private function savePatterns() { $this->data['warningPattern'] = $this->warningPatterns; $this->data['errorPattern'] = $this->errorPatterns; - - $this->data['mandatoryPattern'] = ['string' => [], 'regex' => []]; - $this->mandatoryPatterns['string'] = []; - $this->mandatoryPatterns['regex'] = []; - $this->data['mandatoryPattern'] = $this->mandatoryPatterns; - // Can be reduced to only - // $this->data['mustContainPattern'] = $this->mustContainPatterns; - /*if(isset($this->data['mustContainPattern'])) { - $this->data['mustContainPattern'] = $this->mustContainPatterns; - } - else { - $this->data['mustContainPattern'] = ['string' => [], 'regex' => []]; - $this->mustContainPatterns['string'] = []; - $this->mustContainPatterns['regex'] = []; - }*/ + $encoded = json_encode($this->data); $this->system->setLogalyzerPatterns($encoded); Factory::getSystemFactory()->update($this->system); From d7ce005c1db3b37e78c2a0c79666165e49a46da1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 14:01:50 +0200 Subject: [PATCH 337/644] implementing features --- controllers/admin.php | 31 ++++++++++++++++++++++++++----- libraries/logalyzer.php | 2 +- views/admin/system.php | 10 +++++----- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 81e9c82723..46db8f92dc 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -395,7 +395,6 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); - // $key contains just letters and numbers? if(!empty($this->post['regexError'])&&$this->post['regexError']=='on') { $logalyzer->addKey('error', 'regex', $key); } else { @@ -408,13 +407,24 @@ public function system() { $system = Factory::getSystemFactory()->get($this->post['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); - // $key contain just letters and numbers? if(!empty($this->post['regexWarning'])&&$this->post['regexWarning']=='on') { $logalyzer->addKey('warning', 'regex', $key); } else { $logalyzer->addKey('warning', 'string', $key); } } + } else if (!empty($this->post['group'] == 'newMandatory')) { + $key = $this->post['newMandatoryPattern']; + if ($key != "") { + $system = Factory::getSystemFactory()->get($this->post['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystemAndLoadPattern($system); + if(!empty($this->post['regexMandatory'])&&$this->post['regexMandatory']=='on') { + $logalyzer->addKey('mandatory', 'regex', $key); + } else { + $logalyzer->addKey('mandatory', 'string', $key); + } + } } } else if (!empty($this->get['deleteWarningPattern'])) { @@ -433,7 +443,16 @@ public function system() { $logalyzer->setSystemAndLoadPattern($system); $logalyzer->removeKey('error', $key); } - } else if (!empty($this->get['delete'])) { + } else if (!empty($this->get['deleteMandatoryPattern'])) { + $key = $this->get['deleteMandatoryPattern']; + if ($key != "") { + $system = Factory::getSystemFactory()->get($this->get['id']); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystemAndLoadPattern($system); + $logalyzer->removeKey('mandatory', $key); + } + } + else if (!empty($this->get['delete'])) { $settings = Settings_Library::getInstance($system->getId()); if (!empty($this->get['delete'])) { $key = urldecode($this->get['delete']); @@ -543,8 +562,10 @@ public function system() { $logalyzer->setSystemAndLoadPattern($system); $errors = $logalyzer->getPatterns("error"); $warnings = $logalyzer->getPatterns("warning"); - $this->view->assign('errorKeys', $errors); - $this->view->assign('warningKeys', $warnings); + $mandatory = $logalyzer->getPatterns("warning"); + $this->view->assign('errorPatterns', $errors); + $this->view->assign('warningPatterns', $warnings); + $this->view->assign('mandatoryPatterns', $mandatory); } else { throw new Exception("No id provided!"); } diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e677bba34a..53f5f24fc1 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -283,7 +283,7 @@ public function removeKey(string $identifier, string $key) { $this->errorPatterns['regex'] = array_values($this->errorPatterns['regex']); } } - elseif ($identifier == 'mustContain') { + elseif ($identifier == 'mandatory') { if (($index = array_search($key, $this->mandatoryPatterns['string'])) !== false) { unset($this->mandatoryPatterns['string'][$index]); $this->mandatoryPatterns['string'] = array_values($this->mandatoryPatterns['string']); diff --git a/views/admin/system.php b/views/admin/system.php index 95de70a7f1..1b27da5a2e 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -460,7 +460,7 @@

Log Analysis

Regex Expression: Any expression consisting of more than just letters and numbers is treated as regex.

-

Keywords are case sensitive

+

Patterns are case sensitive

@@ -479,7 +479,7 @@
- $array) { + $array) { foreach ($array as $key) {?>
@@ -515,7 +515,7 @@
- $array) { + $array) { foreach ($array as $key) {?>
@@ -534,7 +534,7 @@
-

Mandatory Pattern

+

Mandatory Patterns


@@ -548,7 +548,7 @@
- $array) { + $array) { foreach ($array as $key) {?>
From c328fb69de2b7b92fc6ca7122c9fd9e8c5aab75a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 14:02:17 +0200 Subject: [PATCH 338/644] implementing features --- controllers/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin.php b/controllers/admin.php index 46db8f92dc..4c0932ac54 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -562,7 +562,7 @@ public function system() { $logalyzer->setSystemAndLoadPattern($system); $errors = $logalyzer->getPatterns("error"); $warnings = $logalyzer->getPatterns("warning"); - $mandatory = $logalyzer->getPatterns("warning"); + $mandatory = $logalyzer->getPatterns("mandatory"); $this->view->assign('errorPatterns', $errors); $this->view->assign('warningPatterns', $warnings); $this->view->assign('mandatoryPatterns', $mandatory); From 3132d3792cf7de58a037311405151cf87cdf5080 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 14:03:38 +0200 Subject: [PATCH 339/644] implementing features --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 53f5f24fc1..dea95d4d42 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -244,7 +244,7 @@ public function addKey(string $identifier, string $type, string $key) { if (!(array_search($key, $this->errorPatterns[$type]))) { $this->errorPatterns[$type][] = $key; } - } elseif ($identifier == 'mustContain') { + } elseif ($identifier == 'mandatory') { if (!(array_search($key, $this->mandatoryPatterns[$type]))) { $this->mandatoryPatterns[$type][] = $key; } From 4521621b4ed87a16328fa8be2fd6843bdba90831 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 14:05:59 +0200 Subject: [PATCH 340/644] implementing features --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index dea95d4d42..cceac80ec9 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -160,7 +160,7 @@ private function createBasicPatterns() { /** * Returns the arrays containing pattern - * $identifier can be 'all', 'warning' or 'error' + * $identifier can be 'all', 'warning' or 'error' or 'mandatory * @param $identifier * @return array|mixed */ @@ -178,7 +178,7 @@ public function getPatterns($identifier) { return $this->data['warningPattern']; } elseif ($identifier === 'error') { return $this->data['errorPattern']; - } elseif ($identifier === 'mandatoryPattern') { + } elseif ($identifier === 'mandatory') { return $this->data['mandatoryPattern']; } else { echo "Error in getpatterns"; From 841288017fd2097f3330c0268749365ce1aef339 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 14:10:35 +0200 Subject: [PATCH 341/644] implementing features --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index cceac80ec9..3e93728c79 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -246,6 +246,8 @@ public function addKey(string $identifier, string $type, string $key) { } } elseif ($identifier == 'mandatory') { if (!(array_search($key, $this->mandatoryPatterns[$type]))) { + echo 'key: ' . $key . ' is not in: '; + print_r($this->mandatoryPatterns[$type]); $this->mandatoryPatterns[$type][] = $key; } } else { From 8275a59c09446ffd9a8d484316efbab438e88a39 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 14:14:19 +0200 Subject: [PATCH 342/644] implementing features --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 3e93728c79..b229c8ff5f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -245,9 +245,11 @@ public function addKey(string $identifier, string $type, string $key) { $this->errorPatterns[$type][] = $key; } } elseif ($identifier == 'mandatory') { + $output = array_search($key, $this->mandatoryPatterns[$type]); if (!(array_search($key, $this->mandatoryPatterns[$type]))) { echo 'key: ' . $key . ' is not in: '; print_r($this->mandatoryPatterns[$type]); + echo ' output is : ' . $output; $this->mandatoryPatterns[$type][] = $key; } } else { From cd1a49a6c8df51db7cc690feea95f1bec3f9f01a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 14:16:15 +0200 Subject: [PATCH 343/644] implementing features --- libraries/logalyzer.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b229c8ff5f..8732ab762c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -237,19 +237,17 @@ public function addKey(string $identifier, string $type, string $key) { else { if ($identifier == 'warning') { // Check if $key is already in the array - if (!(array_search($key, $this->warningPatterns[$type]))) { + if ((array_search($key, $this->warningPatterns[$type]))===false) { $this->warningPatterns[$type][] = $key; } } elseif ($identifier == 'error') { - if (!(array_search($key, $this->errorPatterns[$type]))) { + if ((array_search($key, $this->errorPatterns[$type]))===false) { $this->errorPatterns[$type][] = $key; } } elseif ($identifier == 'mandatory') { $output = array_search($key, $this->mandatoryPatterns[$type]); - if (!(array_search($key, $this->mandatoryPatterns[$type]))) { - echo 'key: ' . $key . ' is not in: '; + if ((array_search($key, $this->mandatoryPatterns[$type]))===false) { print_r($this->mandatoryPatterns[$type]); - echo ' output is : ' . $output; $this->mandatoryPatterns[$type][] = $key; } } else { From 68c3f4ff95fd2f807e929b9eb44b556913983fd6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 14:18:15 +0200 Subject: [PATCH 344/644] implementing features --- libraries/logalyzer.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 8732ab762c..b783000bae 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -236,18 +236,15 @@ public function addKey(string $identifier, string $type, string $key) { } else { if ($identifier == 'warning') { - // Check if $key is already in the array - if ((array_search($key, $this->warningPatterns[$type]))===false) { + if (!in_array($key, $this->warningPatterns[$type])) { $this->warningPatterns[$type][] = $key; } } elseif ($identifier == 'error') { - if ((array_search($key, $this->errorPatterns[$type]))===false) { + if (!in_array($key, $this->errorPatterns[$type])) { $this->errorPatterns[$type][] = $key; } } elseif ($identifier == 'mandatory') { - $output = array_search($key, $this->mandatoryPatterns[$type]); - if ((array_search($key, $this->mandatoryPatterns[$type]))===false) { - print_r($this->mandatoryPatterns[$type]); + if (!in_array($key, $this->mandatoryPatterns[$type])) { $this->mandatoryPatterns[$type][] = $key; } } else { From d8d5496d349d15d912cd2c2a4c4cd00f02967f6a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 15:26:19 +0200 Subject: [PATCH 345/644] DB update new column --- chronos.sql | 6 +++++- libraries/dba/models/Job.class.php | 14 +++++++++++++- libraries/dba/models/JobFactory.class.php | 4 ++-- libraries/dba/models/System.class.php | 2 +- libraries/dba/models/generator.php | 3 ++- libraries/logalyzer.php | 11 +++++++++++ 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/chronos.sql b/chronos.sql index 69ece64653..9fdde33ad9 100644 --- a/chronos.sql +++ b/chronos.sql @@ -73,7 +73,8 @@ CREATE TABLE `Job` ( `configurationIdentifier` varchar(256) COLLATE utf8_unicode_ci NOT NULL, `logalyzerWarningCount` int(11), `logalyzerErrorCount` int(11), - `logalyzerHash` varchar(64) + `logalyzerHash` varchar(64), + `logalyzerContainsMandatoryPattern` bool ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -282,6 +283,9 @@ ALTER TABLE `System` ALTER TABLE `User` MODIFY `userId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; +ALTER TABLE `User` + ADD `logalyzerContainsMandatoryPattern` boolean default false AFTER `logalyzerHash`; + CREATE OR REPLACE VIEW ExperimentView AS SELECT Experiment.*,ProjectUser.userId as projectUserId FROM Experiment INNER JOIN Project ON Project.projectId=Experiment.projectId INNER JOIN ProjectUser ON ProjectUser.projectId=Project.projectId; diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 8670d3a734..39c4e02499 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -46,8 +46,9 @@ class Job extends AbstractModel { private $logalyzerWarningCount; private $logalyzerErrorCount; private $logalyzerHash; + private $logalyzerContainsMandatoryPattern; - function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $logalyzerWarningCount = 0, $logalyzerErrorCount = 0, $logalyzerHash = '') { + function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $logalyzerWarningCount, $logalyzerErrorCount, $logalyzerHash, $logalyzerContainsMandatoryPattern) { $this->jobId = $jobId; $this->userId = $userId; $this->description = $description; @@ -67,6 +68,7 @@ function __construct($jobId, $userId, $description, $systemId, $environment, $ph $this->logalyzerWarningCount = $logalyzerWarningCount; $this->logalyzerErrorCount = $logalyzerErrorCount; $this->logalyzerHash = $logalyzerHash; + $this->logalyzerContainsMandatoryPattern = $logalyzerContainsMandatoryPattern; } function getKeyValueDict() { @@ -90,6 +92,7 @@ function getKeyValueDict() { $dict['logalyzerWarningCount'] = $this->logalyzerWarningCount; $dict['logalyzerErrorCount'] = $this->logalyzerErrorCount; $dict['logalyzerHash'] = $this->logalyzerHash; + $dict['logalyzerContainsMandatoryPattern'] = $this->logalyzerContainsMandatoryPattern; return $dict; } @@ -253,6 +256,14 @@ function getLogalyzerHash(){ function setLogalyzerHash($logalyzerHash){ $this->logalyzerHash = $logalyzerHash; } + + function getLogalyzerContainsMandatoryPattern(){ + return $this->logalyzerContainsMandatoryPattern; + } + + function setLogalyzerContainsMandatoryPattern($logalyzerContainsMandatoryPattern){ + $this->logalyzerContainsMandatoryPattern = $logalyzerContainsMandatoryPattern; + } const JOB_ID = "jobId"; const USER_ID = "userId"; @@ -273,4 +284,5 @@ function setLogalyzerHash($logalyzerHash){ const LOGALYZER_WARNING_COUNT = "logalyzerWarningCount"; const LOGALYZER_ERROR_COUNT = "logalyzerErrorCount"; const LOGALYZER_HASH = "logalyzerHash"; + const LOGALYZER_CONTAINS_MANDATORY_PATTERN = "logalyzerContainsMandatoryPattern"; } diff --git a/libraries/dba/models/JobFactory.class.php b/libraries/dba/models/JobFactory.class.php index 9f190570c4..bc66ba7d6c 100644 --- a/libraries/dba/models/JobFactory.class.php +++ b/libraries/dba/models/JobFactory.class.php @@ -47,7 +47,7 @@ function getCacheValidTime() { * @return Job */ function getNullObject() { - $o = new Job(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); + $o = new Job(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); return $o; } @@ -57,7 +57,7 @@ function getNullObject() { * @return Job */ function createObjectFromDict($pk, $dict) { - $o = new Job($dict['jobId'], $dict['userId'], $dict['description'], $dict['systemId'], $dict['environment'], $dict['phases'], $dict['configuration'], $dict['status'], $dict['progress'], $dict['result'], $dict['created'], $dict['started'], $dict['finished'], $dict['evaluationId'], $dict['internalId'], $dict['configurationIdentifier'], $dict['logalyzerWarningCount'], $dict['logalyzerErrorCount'], $dict['logalyzerHash']); + $o = new Job($dict['jobId'], $dict['userId'], $dict['description'], $dict['systemId'], $dict['environment'], $dict['phases'], $dict['configuration'], $dict['status'], $dict['progress'], $dict['result'], $dict['created'], $dict['started'], $dict['finished'], $dict['evaluationId'], $dict['internalId'], $dict['configurationIdentifier'], $dict['logalyzerWarningCount'], $dict['logalyzerErrorCount'], $dict['logalyzerHash'], $dict['logalyzerContainsMandatoryPattern']); return $o; } diff --git a/libraries/dba/models/System.class.php b/libraries/dba/models/System.class.php index 6056a291bf..3d60c42e05 100644 --- a/libraries/dba/models/System.class.php +++ b/libraries/dba/models/System.class.php @@ -41,7 +41,7 @@ class System extends AbstractModel { private $isArchived; private $logalyzerPatterns; - function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns=null) { + function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns) { $this->systemId = $systemId; $this->name = $name; $this->description = $description; diff --git a/libraries/dba/models/generator.php b/libraries/dba/models/generator.php index 007c9d2322..fde1bd1798 100644 --- a/libraries/dba/models/generator.php +++ b/libraries/dba/models/generator.php @@ -98,7 +98,8 @@ 'configurationIdentifier', 'logalyzerWarningCount', 'logalyzerErrorCount', - 'logalyzerHash' + 'logalyzerHash', + 'logalyzerContainsMandatoryPattern' ]; $CONF['Result'] = [ 'resultId', diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b783000bae..c4eef56607 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -102,6 +102,17 @@ public function examineEntireLog() { break; } } + $mandatoryPresent = false; + foreach ($this->mandatoryPatterns['regex'] as $key) { + if($this->countLogOccurances($key, $this->log, true) > 0) { + $mandatoryPresent = true; + } + } + foreach ($this->mandatoryPatterns['string'] as $key) { + if($this->countLogOccurances($key, $this->log) > 0) { + $mandatoryPresent = true; + } + } $this->job->setLogalyzerWarningCount($warningCount); $this->job->setLogalyzerErrorCount($errorCount); From 2907a3fcc2868496e546bca268cc8867a391cf71 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 15:39:59 +0200 Subject: [PATCH 346/644] DB update new column --- chronos.sql | 2 +- libraries/dba/models/System.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chronos.sql b/chronos.sql index 9fdde33ad9..cd2d2a42e1 100644 --- a/chronos.sql +++ b/chronos.sql @@ -283,7 +283,7 @@ ALTER TABLE `System` ALTER TABLE `User` MODIFY `userId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -ALTER TABLE `User` +ALTER TABLE `Job` ADD `logalyzerContainsMandatoryPattern` boolean default false AFTER `logalyzerHash`; CREATE OR REPLACE VIEW ExperimentView AS diff --git a/libraries/dba/models/System.class.php b/libraries/dba/models/System.class.php index 3d60c42e05..7db3dc6039 100644 --- a/libraries/dba/models/System.class.php +++ b/libraries/dba/models/System.class.php @@ -41,7 +41,7 @@ class System extends AbstractModel { private $isArchived; private $logalyzerPatterns; - function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns) { + function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns=false) { $this->systemId = $systemId; $this->name = $name; $this->description = $description; From e727bc652e95c59c09770c4d8c13bc1638d5d6d4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 15:41:58 +0200 Subject: [PATCH 347/644] DB update new column --- libraries/dba/models/System.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/models/System.class.php b/libraries/dba/models/System.class.php index 7db3dc6039..3d60c42e05 100644 --- a/libraries/dba/models/System.class.php +++ b/libraries/dba/models/System.class.php @@ -41,7 +41,7 @@ class System extends AbstractModel { private $isArchived; private $logalyzerPatterns; - function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns=false) { + function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns) { $this->systemId = $systemId; $this->name = $name; $this->description = $description; From 0a4a4fbb07b1dfd8395604be1804f137b6ab0286 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 15:42:36 +0200 Subject: [PATCH 348/644] DB update new column --- libraries/dba/models/System.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/models/System.class.php b/libraries/dba/models/System.class.php index 3d60c42e05..7db3dc6039 100644 --- a/libraries/dba/models/System.class.php +++ b/libraries/dba/models/System.class.php @@ -41,7 +41,7 @@ class System extends AbstractModel { private $isArchived; private $logalyzerPatterns; - function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns) { + function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns=false) { $this->systemId = $systemId; $this->name = $name; $this->description = $description; From d460e218b5e11ebe98a8a3f6d31c1355f1fce7fa Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 19:25:45 +0200 Subject: [PATCH 349/644] reverted a query --- chronos.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/chronos.sql b/chronos.sql index cd2d2a42e1..d7a23b4a41 100644 --- a/chronos.sql +++ b/chronos.sql @@ -283,9 +283,6 @@ ALTER TABLE `System` ALTER TABLE `User` MODIFY `userId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -ALTER TABLE `Job` - ADD `logalyzerContainsMandatoryPattern` boolean default false AFTER `logalyzerHash`; - CREATE OR REPLACE VIEW ExperimentView AS SELECT Experiment.*,ProjectUser.userId as projectUserId FROM Experiment INNER JOIN Project ON Project.projectId=Experiment.projectId INNER JOIN ProjectUser ON ProjectUser.projectId=Project.projectId; From 51735667bd218fa9af0b48e3af953940d262607f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 19:33:00 +0200 Subject: [PATCH 350/644] reverted a query --- libraries/logalyzer.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c4eef56607..569aa1e28e 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -71,7 +71,7 @@ public function examineEntireLog() { } // Check if there have been changes to the log $hash = $this->calculateHash(); - + $mandatoryPatternPresent = 0; // Count occurrences of all defined keywords. $warningCount = 0; $errorCount = 0; @@ -102,18 +102,17 @@ public function examineEntireLog() { break; } } - $mandatoryPresent = false; foreach ($this->mandatoryPatterns['regex'] as $key) { if($this->countLogOccurances($key, $this->log, true) > 0) { - $mandatoryPresent = true; + $mandatoryPatternPresent = 1; } } foreach ($this->mandatoryPatterns['string'] as $key) { if($this->countLogOccurances($key, $this->log) > 0) { - $mandatoryPresent = true; + $mandatoryPatternPresent = 1; } } - + $this->job->setLogalyzerContainsMandatoryPattern($mandatoryPatternPresent); $this->job->setLogalyzerWarningCount($warningCount); $this->job->setLogalyzerErrorCount($errorCount); $this->job->setLogalyzerHash($hash); @@ -128,6 +127,7 @@ public function examineEntireLog() { */ public function examineLogLine($logLine) { $LOG_ERRORS_MAX = 10; + $mandatoryPatternPresent = 0; // TODO change to constant when available while ($this->job->getLogalyzerCountWarnings <= $LOG_ERRORS_MAX && $this->job->getLogalyzerCountErrors <= $LOG_ERRORS_MAX) { foreach ($this->warningPatterns['regex'] as $key) { @@ -150,6 +150,20 @@ public function examineLogLine($logLine) { Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); } } + foreach ($this->mandatoryPatterns['regex'] as $key) { + if($this->countLogOccurances($key, $this->log, true) > 0) { + $mandatoryPatternPresent = true; + } + } + foreach ($this->mandatoryPatterns['string'] as $key) { + if($this->countLogOccurances($key, $this->log) > 0) { + $mandatoryPatternPresent = true; + } + } + if($mandatoryPatternPresent) { + $this->job->setLogalyzerContainsMandatoryPattern(1); + Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); + } } } From 49874ba57874fae97be179cab8fcc402b1c58466 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 19:44:35 +0200 Subject: [PATCH 351/644] reverted a query --- controllers/evaluation.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 088c158030..f5dcb88412 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -130,7 +130,21 @@ public function detail() { $evaluation->setIsStarred(0); Factory::getEvaluationFactory()->update($evaluation); } - + // Button press to reexamine entire log + // Button only shows up if the job examined using an outdated pattern (or none) + if (!empty($this->post['recheck'])) { + $job = Factory::getJobFactory()->get($this->post['jobId']); + $logalyzer = new Logalyzer_Library($job); + $logalyzer->examineEntireLog(); + } + if (!empty($this->post['recheckAll'])) { + $qF = new QueryFilter(Job::EVALUATION_ID, $evaluation->getId(), "="); + $jobs = Factory::getJobFactory()->filter([Factory::FILTER => $qF]); + foreach ($jobs as $subJob) { + $logalyzer = new Logalyzer_Library($subJob); + $logalyzer->examineEntireLog(); + } + } $experiment = Factory::getExperimentFactory()->get($evaluation->getExperimentId()); // Check if the user has enough privileges to access this evaluation @@ -153,20 +167,6 @@ public function detail() { $this->view->assign('supportsShowResults', $sys->supportsFullResults()); $system = Factory::getSystemFactory()->get($experiment->getSystemId()); - // Button press to reexamine entire log - // Button only shows up if the job examined using an outdated pattern (or none) - if (!empty($this->post['recheck'])) { - $job = Factory::getJobFactory()->get($this->post['jobId']); - $logalyzer = new Logalyzer_Library($job); - $logalyzer->examineEntireLog(); - } - if (!empty($this->post['recheckAll'])) { - foreach ($jobs as $subJob) { - $logalyzer = new Logalyzer_Library($subJob); - $logalyzer->examineEntireLog(); - } - } - // Shenanigans to normalize whitespaces and newlines $systemHash = json_encode(json_decode($system->getLogalyzerPatterns()), true); $systemHash = hash('sha1', $systemHash); From 64e53d5d7d91007580f1c3aaac0a31e0dbdc525c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 19:45:21 +0200 Subject: [PATCH 352/644] reverted a query --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 15d38b3748..5ce2274743 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -129,7 +129,7 @@ function updateProgress() { "); ?>
-
+

Job details @@ -230,7 +230,7 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarningCount']);} ?>

- +
From 7bf6246df65d4b5b627ff007fb8ddec5359e5e56 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 19:46:15 +0200 Subject: [PATCH 353/644] reverted a query --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 5ce2274743..3ff175bf96 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -231,7 +231,7 @@ function updateProgress() {
- +
From 46bfbf59d3331a6eac8f4ccfeafd2abc464997f3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 19:47:35 +0200 Subject: [PATCH 354/644] reverted a query --- views/job/detail.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 3ff175bf96..0a45cf492f 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -223,6 +223,13 @@ function updateProgress() {
+
+
+ +
+
+
+
Errors: = 0) { echo($data['logErrorCount']); } ?>
@@ -234,12 +241,7 @@ function updateProgress() {
-
-
- -
-
-
+
From bf3685e49eb7fa81f20b713ca814d953716b2626 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 19:48:26 +0200 Subject: [PATCH 355/644] reverted a query --- views/job/detail.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 0a45cf492f..e2427561c3 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -213,7 +213,7 @@ function updateProgress() {
-
+
+
From abc8d0691c5882789cd8d694479ded896f268672 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 19:50:19 +0200 Subject: [PATCH 358/644] reverted a query --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 2434ef5afe..7968b12960 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -231,7 +231,7 @@ function updateProgress() {

-
+
From 1a72b68d85bd62cb64a9ce17caf6a632d07a29dd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 19:50:36 +0200 Subject: [PATCH 359/644] reverted a query --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 7968b12960..2434ef5afe 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -231,7 +231,7 @@ function updateProgress() {

-
+
From f16669828465f95c07ea77fb8c21db5f3180f221 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 19:59:12 +0200 Subject: [PATCH 360/644] reverted a query --- views/job/detail.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/views/job/detail.php b/views/job/detail.php index 2434ef5afe..998ee7ca25 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -241,6 +241,17 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarningCount']);} ?>
+ = 0) { ?> + + = 0) {?> + +
From a923b8014526c86540508e5673e62bc08dbf4d54 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 20:00:48 +0200 Subject: [PATCH 361/644] reverted a query --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 998ee7ca25..9e7caf3e51 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -242,12 +242,12 @@ function updateProgress() {
= 0) { ?> - - = 0) { ?> -
- × -

Log contains Errors

-
- = 0) {?> -
- × -

Log contains Warnings

-
- + + +
From e4a6565f0b5df3a3e1dd9ceaf677e2176820c13d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 21:22:45 +0200 Subject: [PATCH 363/644] added most support for dynamic show/hide of logalyzer banners --- views/job/detail.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 796840fc07..429afaba82 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -273,15 +273,15 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarningCount']);} ?>
- From 3913bd5a0fb94c155c961cae1efe8360d99da0be Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 21:26:57 +0200 Subject: [PATCH 365/644] added most support for dynamic show/hide of logalyzer banners --- api/ui/job.php | 1 + views/job/detail.php | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/ui/job.php b/api/ui/job.php index ba1d72e284..a38f30755c 100644 --- a/api/ui/job.php +++ b/api/ui/job.php @@ -38,6 +38,7 @@ public function patch() { $job->setProgress($this->request['progress']); } if(isset($this->request['getLogalyzerResponse'])) { + echo "working"; $warning = $job->getLogalyzerWarningCount(); $error = $job->getLogalyzerErrorCount(); $mandatory = $job->getLogalyzerContainsMandatoryPattern(); diff --git a/views/job/detail.php b/views/job/detail.php index b0ea6671e9..fcecce37e8 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -138,9 +138,8 @@ function updateProgress() { } $(document).ready(function(){ - getLogalyzerResponses(); updateAll(); - + getLogalyzerResponses(); setInterval(function() { if($('#autoupdateLog').prop('checked')) { updateAll(); @@ -273,7 +272,7 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarningCount']);} ?>
- +
From 4254ed64afd24c7f9ee8ff6ffe438be9866b390e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 21:28:47 +0200 Subject: [PATCH 366/644] added most support for dynamic show/hide of logalyzer banners --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index fcecce37e8..d1c33d7b19 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -110,7 +110,7 @@ function getLogalyzerResponses() { else { $('#logMandatoryBanner').hide(); } - setTimeout(checkJobStatus, 5000); + // setTimeout(checkJobStatus, 5000); }, error: function() { console.error('Error checking job status.'); @@ -139,8 +139,8 @@ function updateProgress() { $(document).ready(function(){ updateAll(); - getLogalyzerResponses(); setInterval(function() { + getLogalyzerResponses(); if($('#autoupdateLog').prop('checked')) { updateAll(); } else { From 8f5354c0e83311b389db7a4b41994b1cc95aa639 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 21:39:01 +0200 Subject: [PATCH 367/644] reverted changes --- controllers/job.php | 4 +++- views/job/detail.php | 46 +++++++++----------------------------------- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 47453b2d69..14c5c4f689 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -151,7 +151,9 @@ public function detail() { $errors = $job->getLogalyzerErrorCount(); $this->view->assign('logWarningCount', $warnings); $this->view->assign('logErrorCount', $errors); - + if($job->getStatus()==Define::JOB_STATUS_FINISHED && $job->getLogalyzerContainsMandatoryPattern()==0) { + $this->view->assign('logContainsMandatory', 0); + } $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); } else { diff --git a/views/job/detail.php b/views/job/detail.php index d1c33d7b19..59c3cbd644 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -88,36 +88,6 @@ function rescheduleJob() { }); } - function getLogalyzerResponses() { - $.ajax({ - url: '/api/ui/job/id=' + $('#id').val(), - data : { getLogalyzerResponses: 'getLogalyzerResponses' }, - type: 'PATCH', - success: function(response) { - if (response.error > 0) { - $('#logErrorBanner').show(); - } - elseif (response.warning > 0) { - $('#logWarningBanner').show(); - } - else { - $('#logErrorBanner').hide(); - $('#logWarningBanner').hide(); - } - if (response.mandatory == 0) { - $('#logMandatoryBanner').show(); - } - else { - $('#logMandatoryBanner').hide(); - } - // setTimeout(checkJobStatus, 5000); - }, - error: function() { - console.error('Error checking job status.'); - } - }); - } - function updateAll() { var id = $('#id').val(); var ansi_up = new AnsiUp; @@ -140,7 +110,6 @@ function updateProgress() { $(document).ready(function(){ updateAll(); setInterval(function() { - getLogalyzerResponses(); if($('#autoupdateLog').prop('checked')) { updateAll(); } else { @@ -272,24 +241,27 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarningCount']);} ?>
- -
From b86803ef895d7155295a0ce7b77a5735d80a8eba Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 21:45:45 +0200 Subject: [PATCH 368/644] reverted changes --- controllers/job.php | 8 ++++++++ views/job/detail.php | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/controllers/job.php b/controllers/job.php index 14c5c4f689..312f189cbb 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -154,6 +154,14 @@ public function detail() { if($job->getStatus()==Define::JOB_STATUS_FINISHED && $job->getLogalyzerContainsMandatoryPattern()==0) { $this->view->assign('logContainsMandatory', 0); } + $system = Factory::getSystemFactory()->get($job->getSystemId()); + + // Shenanigans to normalize whitespaces and newlines + $systemHash = json_encode(json_decode($system->getLogalyzerPatterns()), true); + $systemHash = hash('sha1', $systemHash); + if($job->getLogalyzerHash() != $systemHash) { + $this->view->assign('usedOutdatedPattern', true); + } $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); } else { diff --git a/views/job/detail.php b/views/job/detail.php index 59c3cbd644..ffd1bac32b 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -241,6 +241,12 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarningCount']);} ?>
+ +
+ × +

Log contains Errors

+
+ = 0) { ?>
× From 4bc60f41108db8a4fdaaae1b676ba02df5319ec8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 21:47:34 +0200 Subject: [PATCH 369/644] reverted changes --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index ffd1bac32b..da9690ef6d 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -244,7 +244,7 @@ function updateProgress() {
× -

Log contains Errors

+

Outdated pattern used, use 'Recheck'

= 0) { ?> From d692f26dc9765d8755119f24a085c42512f692c1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 22:46:37 +0200 Subject: [PATCH 370/644] reverted some changes added a check if no mandatory pattern is defined --- libraries/logalyzer.php | 20 +++++++++++++------- views/evaluation/detail.php | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 569aa1e28e..fe818f4361 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -102,14 +102,20 @@ public function examineEntireLog() { break; } } - foreach ($this->mandatoryPatterns['regex'] as $key) { - if($this->countLogOccurances($key, $this->log, true) > 0) { - $mandatoryPatternPresent = 1; - } + // If no mandatory pattern is defined + if (count($this->mandatoryPatterns['string'])==0 && count($this->mandatoryPatterns['regex']) == 0) { + $mandatoryPatternPresent = 1; } - foreach ($this->mandatoryPatterns['string'] as $key) { - if($this->countLogOccurances($key, $this->log) > 0) { - $mandatoryPatternPresent = 1; + else { + foreach ($this->mandatoryPatterns['regex'] as $key) { + if ($this->countLogOccurances($key, $this->log, true) > 0) { + $mandatoryPatternPresent = 1; + } + } + foreach ($this->mandatoryPatterns['string'] as $key) { + if ($this->countLogOccurances($key, $this->log) > 0) { + $mandatoryPatternPresent = 1; + } } } $this->job->setLogalyzerContainsMandatoryPattern($mandatoryPatternPresent); diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 2c627287aa..2bb740dd77 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -67,6 +67,11 @@ function getLogalyzerResponses(evalId) { data : { action: 'getLogalyzerResponses' }, type: 'GET', success: function(response) { + if (response.jobsToHighlight) { + $('#jobCompleteMessage').show(); + } else { + setTimeout(checkJobStatus, 5000); + } }, error: function() { console.error('Error checking job status.'); @@ -226,15 +231,17 @@ function getLogalyzerResponses(evalId) { getInternalId(); ?> getDescription(); ?> - - - - - getStatus()==Define::JOB_STATUS_FINISHED) { ?> - + getLogalyzerErrorCount() > 0) { ?> + + getLogalyzerWarningCount() > 0) { ?> + + + getStatus() == Define::JOB_STATUS_FINISHED && $job->getLogalyzerContainsMandatoryPattern() == 0) { ?> + + getStatus() == Define::JOB_STATUS_SCHEDULED) { ?> scheduled From 3d290bd23363b574574c92c58c5ba1890aecb201 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 22:58:48 +0200 Subject: [PATCH 371/644] improved handling of mandatory keywords --- libraries/logalyzer.php | 55 ++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index fe818f4361..219756b0c8 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,44 +132,43 @@ public function examineEntireLog() { * @return void */ public function examineLogLine($logLine) { - $LOG_ERRORS_MAX = 10; - $mandatoryPatternPresent = 0; - // TODO change to constant when available - while ($this->job->getLogalyzerCountWarnings <= $LOG_ERRORS_MAX && $this->job->getLogalyzerCountErrors <= $LOG_ERRORS_MAX) { - foreach ($this->warningPatterns['regex'] as $key) { - if ($this->countLogOccurances($key, $logLine, true) > 0) { - Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); - } + foreach ($this->warningPatterns['regex'] as $key) { + if ($this->countLogOccurances($key, $logLine, true) > 0) { + Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); } - foreach ($this->warningPatterns['string'] as $key) { - if ($this->countLogOccurances($key, $logLine) > 0) { - Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); - } + } + foreach ($this->warningPatterns['string'] as $key) { + if ($this->countLogOccurances($key, $logLine) > 0) { + Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); } - foreach ($this->errorPatterns['regex'] as $key) { - if ($this->countLogOccurances($key, $logLine, true) > 0) { - Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); - } + } + foreach ($this->errorPatterns['regex'] as $key) { + if ($this->countLogOccurances($key, $logLine, true) > 0) { + Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); } - foreach ($this->errorPatterns['string'] as $key) { - if ($this->countLogOccurances($key, $logLine) > 0) { - Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); - } + } + foreach ($this->errorPatterns['string'] as $key) { + if ($this->countLogOccurances($key, $logLine) > 0) { + Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); } + } + // If no mandatory pattern is defined + if (count($this->mandatoryPatterns['string'])==0 && count($this->mandatoryPatterns['regex']) == 0) { + $this->job->setLogalyzerContainsMandatoryPattern(1); + } else { + $mandatoryPatternPresent = 0; foreach ($this->mandatoryPatterns['regex'] as $key) { - if($this->countLogOccurances($key, $this->log, true) > 0) { - $mandatoryPatternPresent = true; + if ($this->countLogOccurances($key, $this->log, true) > 0) { + $this->job->setLogalyzerContainsMandatoryPattern(1); + Factory::getJobFactory()->update($this->job); } } foreach ($this->mandatoryPatterns['string'] as $key) { - if($this->countLogOccurances($key, $this->log) > 0) { - $mandatoryPatternPresent = true; + if ($this->countLogOccurances($key, $this->log) > 0) { + $this->job->setLogalyzerContainsMandatoryPattern(1); + Factory::getJobFactory()->update($this->job); } } - if($mandatoryPatternPresent) { - $this->job->setLogalyzerContainsMandatoryPattern(1); - Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); - } } } From d0407e8567c9f8e1a731e4a0eabaa9e2503b7c2a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 23:15:35 +0200 Subject: [PATCH 372/644] improved visuals when no log check occured previously --- views/job/detail.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/job/detail.php b/views/job/detail.php index da9690ef6d..12e34fb153 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -238,6 +238,7 @@ function updateProgress() {
Errors: = 0) { echo($data['logErrorCount']); } ?> +
Warnings: = 0) { echo($data['logWarningCount']);} ?>
From 01321cdff2e002f5cc734203ad7eb4d9264ec12e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 23:17:40 +0200 Subject: [PATCH 373/644] improved visuals when no log check occured previously --- views/job/detail.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/job/detail.php b/views/job/detail.php index 12e34fb153..71146bd690 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -242,6 +242,7 @@ function updateProgress() { Warnings: = 0) { echo($data['logWarningCount']);} ?>
+
× From 4a393a4cbe51316eabba94ca56fd0dae5e761510 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 23:32:50 +0200 Subject: [PATCH 374/644] improved visuals when no log check occured previously --- libraries/dba/models/Job.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 39c4e02499..30e95a9d74 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -48,7 +48,7 @@ class Job extends AbstractModel { private $logalyzerHash; private $logalyzerContainsMandatoryPattern; - function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $logalyzerWarningCount, $logalyzerErrorCount, $logalyzerHash, $logalyzerContainsMandatoryPattern) { + function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $logalyzerWarningCount=null, $logalyzerErrorCount=null, $logalyzerHash=null, $logalyzerContainsMandatoryPattern=null) { $this->jobId = $jobId; $this->userId = $userId; $this->description = $description; From 9be78d82f2e00883ddbbf6d36bb832728839da5c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 23:43:33 +0200 Subject: [PATCH 375/644] improved visuals when no log check occured previously --- api/ui/job.php | 2 +- libraries/logalyzer.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/api/ui/job.php b/api/ui/job.php index a38f30755c..a0841b11ab 100644 --- a/api/ui/job.php +++ b/api/ui/job.php @@ -38,7 +38,7 @@ public function patch() { $job->setProgress($this->request['progress']); } if(isset($this->request['getLogalyzerResponse'])) { - echo "working"; + //echo "working"; $warning = $job->getLogalyzerWarningCount(); $error = $job->getLogalyzerErrorCount(); $mandatory = $job->getLogalyzerContainsMandatoryPattern(); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 219756b0c8..e98459c24b 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,6 +132,7 @@ public function examineEntireLog() { * @return void */ public function examineLogLine($logLine) { + $hash = $this->calculateHash(); foreach ($this->warningPatterns['regex'] as $key) { if ($this->countLogOccurances($key, $logLine, true) > 0) { Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); @@ -149,6 +150,7 @@ public function examineLogLine($logLine) { } foreach ($this->errorPatterns['string'] as $key) { if ($this->countLogOccurances($key, $logLine) > 0) { + echo "error increment"; Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); } } @@ -170,6 +172,10 @@ public function examineLogLine($logLine) { } } } + if($this->job->getLogalyzerHash == null) { + $this->job->setLogalyzerHash($hash); + Factory::getJobFactory()->update($this->job); + } } /** From 55c3cda30d2f7cd390cd4f74721f786710515bbc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 23:45:04 +0200 Subject: [PATCH 376/644] debugging for stress test and processing log lines --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e98459c24b..9c0b952732 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -149,8 +149,9 @@ public function examineLogLine($logLine) { } } foreach ($this->errorPatterns['string'] as $key) { + echo "checking for error key: " . $key . "\n"; if ($this->countLogOccurances($key, $logLine) > 0) { - echo "error increment"; + echo "error increment\n"; Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); } } From 72b2b6efd92c6de312bef77ea79c80b58b37f624 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 23:47:04 +0200 Subject: [PATCH 377/644] debugging for stress test and processing log lines --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 9c0b952732..5bc3352bb1 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,6 +132,8 @@ public function examineEntireLog() { * @return void */ public function examineLogLine($logLine) { + echo "Type: " . gettype($logLine) . "\n"; + echo "Line: " . $logLine . "\n"; $hash = $this->calculateHash(); foreach ($this->warningPatterns['regex'] as $key) { if ($this->countLogOccurances($key, $logLine, true) > 0) { From 54f47092918b3c681db02dc6b34715bb5849ba06 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 23:50:13 +0200 Subject: [PATCH 378/644] debugging for stress test and processing log lines --- api/v1/job.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/v1/job.php b/api/v1/job.php index 61f5dc638a..15bfb6be62 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -298,7 +298,9 @@ private function appendLog($id) { mkdir(UPLOADED_DATA_PATH . 'log'); } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); + echo "Creating Logalyzer.. \n"; $logalyzer = new Logalyzer_Library($job); $logalyzer->examineLogLine($this->request['log']); + echo "Logalyzer is done.. \n"; } } From ef9d040d899e0e25e11f1289e2a55a1af6b21935 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 23 Jul 2024 23:55:12 +0200 Subject: [PATCH 379/644] debugging for stress test and processing log lines --- api/v1/job.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/v1/job.php b/api/v1/job.php index 15bfb6be62..35e5e8eea2 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -145,6 +145,10 @@ public function post() { $this->appendLog($this->get['id']); break; case 'upload': + echo "Creating Logalyzer.. \n"; + $logalyzer = new Logalyzer_Library($job); + $logalyzer->examineLogLine($this->request['log']); + echo "Logalyzer is done.. \n"; $this->upload($job); break; default: From ce04879a89ab762beded3902e263b674e7f65ab4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 24 Jul 2024 00:01:46 +0200 Subject: [PATCH 380/644] debugging for stress test and processing log lines --- api/v1/job.php | 6 ++---- libraries/logalyzer.php | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index 35e5e8eea2..4923ef5d56 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -133,6 +133,7 @@ public function post() { } switch (strtolower($this->get['action'])) { case(strtolower('getUploadTarget')): + echo "gettingUploadTarget.."; if (Settings_Library::getInstance(0)->get('ftp', 'useFtpUploadForLocalClients')->getValue() && Ip_Library::cidrMatch($_SERVER['REMOTE_ADDR'], Settings_Library::getInstance(0)->get('ftp', 'localNetworkCIDR')->getValue())) { // Client is in the local subnet, use FTP Upload $this->add($this->getFtpUploadTarget($this->get['id'])); @@ -142,13 +143,10 @@ public function post() { } break; case(strtolower('appendLog')): + echo "appending.."; $this->appendLog($this->get['id']); break; case 'upload': - echo "Creating Logalyzer.. \n"; - $logalyzer = new Logalyzer_Library($job); - $logalyzer->examineLogLine($this->request['log']); - echo "Logalyzer is done.. \n"; $this->upload($job); break; default: diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 5bc3352bb1..609457d453 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -62,6 +62,7 @@ private function checkHashDifference() { * @return void */ public function examineEntireLog() { + echo "TEST"; $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId() . '.log'; $log = Util::readFileContents($path); if ($log === false) { From b905e1c5715c4077c7459566809f95b2f71390e1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 24 Jul 2024 00:05:48 +0200 Subject: [PATCH 381/644] debugging for stress test and processing log lines --- api/v1/job.php | 4 ---- libraries/logalyzer.php | 1 - 2 files changed, 5 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index 4923ef5d56..61f5dc638a 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -133,7 +133,6 @@ public function post() { } switch (strtolower($this->get['action'])) { case(strtolower('getUploadTarget')): - echo "gettingUploadTarget.."; if (Settings_Library::getInstance(0)->get('ftp', 'useFtpUploadForLocalClients')->getValue() && Ip_Library::cidrMatch($_SERVER['REMOTE_ADDR'], Settings_Library::getInstance(0)->get('ftp', 'localNetworkCIDR')->getValue())) { // Client is in the local subnet, use FTP Upload $this->add($this->getFtpUploadTarget($this->get['id'])); @@ -143,7 +142,6 @@ public function post() { } break; case(strtolower('appendLog')): - echo "appending.."; $this->appendLog($this->get['id']); break; case 'upload': @@ -300,9 +298,7 @@ private function appendLog($id) { mkdir(UPLOADED_DATA_PATH . 'log'); } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); - echo "Creating Logalyzer.. \n"; $logalyzer = new Logalyzer_Library($job); $logalyzer->examineLogLine($this->request['log']); - echo "Logalyzer is done.. \n"; } } diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 609457d453..5bc3352bb1 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -62,7 +62,6 @@ private function checkHashDifference() { * @return void */ public function examineEntireLog() { - echo "TEST"; $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId() . '.log'; $log = Util::readFileContents($path); if ($log === false) { From 032156975503afc54d22f7493e5155b9c4d1dcdd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 24 Jul 2024 00:30:25 +0200 Subject: [PATCH 382/644] debugging for stress test and processing log lines --- api/v1/job.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/job.php b/api/v1/job.php index 61f5dc638a..1ffc817c85 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -163,7 +163,7 @@ public function patch() { if (empty($this->get['id'])) { throw new Exception('No id provided'); } - + echo "Test: do logLine uploads request to this endpoint?"; $auth = Auth_Library::getInstance(); $job = Factory::getJobFactory()->get($this->get['id']); $evaluation = Factory::getEvaluationFactory()->get($job->getEvaluationId()); From fabfe4f98efc00e9812bfcaa880438f197a9619f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Thu, 25 Jul 2024 10:35:01 +0200 Subject: [PATCH 383/644] Anpassung Datenmodell. Add Column to Job: `logalyzerResults` json Remove Column of Job: 'logalyzerCountError' 'logalyzerCountWarning' 'logalyzerContainsMandatory' --- chronos.sql | 5 +---- libraries/dba/models/generator.php | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/chronos.sql b/chronos.sql index d7a23b4a41..cef93e2af3 100644 --- a/chronos.sql +++ b/chronos.sql @@ -71,10 +71,7 @@ CREATE TABLE `Job` ( `evaluationId` int(11) NOT NULL, `internalId` int(11) NOT NULL, `configurationIdentifier` varchar(256) COLLATE utf8_unicode_ci NOT NULL, - `logalyzerWarningCount` int(11), - `logalyzerErrorCount` int(11), - `logalyzerHash` varchar(64), - `logalyzerContainsMandatoryPattern` bool + `logalyzerResults` json ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/libraries/dba/models/generator.php b/libraries/dba/models/generator.php index fde1bd1798..6bf14f018d 100644 --- a/libraries/dba/models/generator.php +++ b/libraries/dba/models/generator.php @@ -96,10 +96,7 @@ 'evaluationId', 'internalId', 'configurationIdentifier', - 'logalyzerWarningCount', - 'logalyzerErrorCount', - 'logalyzerHash', - 'logalyzerContainsMandatoryPattern' + 'logalyzerResults' ]; $CONF['Result'] = [ 'resultId', From 0e416be665608f90e03b336af410480a3ec63239 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Thu, 25 Jul 2024 10:52:52 +0200 Subject: [PATCH 384/644] Anpassung Datenmodell. Add Column to Job: `logalyzerResults` json Remove Column of Job: 'logalyzerCountError' 'logalyzerCountWarning' 'logalyzerContainsMandatory' --- libraries/dba/models/generator.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/dba/models/generator.php b/libraries/dba/models/generator.php index 6bf14f018d..839836ddb4 100644 --- a/libraries/dba/models/generator.php +++ b/libraries/dba/models/generator.php @@ -204,9 +204,7 @@ 'internalId', 'configurationIdentifier', 'projectUserId', - 'logalyzerCountWarnings', - 'logalyzerCountErrors', - 'logalyzerHash' + 'logalyzerResults' ]; foreach ($CONF as $NAME => $COLUMNS) { From 330540e093fb7da84393fa5d5f5bdb19a7e280f2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 01:53:28 +0200 Subject: [PATCH 385/644] Changed all backend to support new json structures. Frontend must be patched aswell --- libraries/dba/AbstractModelFactory.class.php | 58 +++- libraries/logalyzer.php | 273 +++++-------------- 2 files changed, 122 insertions(+), 209 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index a4f224bdb9..c65c824035 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -775,17 +775,53 @@ public function getDB($test = false) { die("Fatal Error! Database connection failed. Message: " . $e->getMessage()); } } - public function incrementJobError($identifier, $jobId) { - $query = ""; - if ($identifier == 'error') { - $query = "UPDATE Job SET logalyzerErrorCount=logalyzerErrorCount+1 WHERE jobId=?"; + public function IncrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $amount) { + $selectQuery = "SELECT JSON_EXTRACT(Job.logalyzerResults, $.results) WHERE $.results.logLevel= " . $logLevel . " AND $.results.pattern=". $pattern . " AND $.results.regex=". $regex . " AND $.results.type=" . $type; + $query = "UPDATE Job JSON_SET(" . $selectQuery . ", $.results.count, " . $amount. ") WHERE jobId=?"; + + $dbh = self::getDB(); + $stmt = $dbh->prepare($query); + $stmt->execute([$jobId]); } - elseif ($identifier == 'warning') { - $query = "UPDATE Job SET logalyzerWarningCount=logalyzerWarningCount+1 WHERE jobId=?"; - } else { echo 'No identifier'; } - $dbh = self::getDB(); - $stmt = $dbh->prepare($query); - $stmt->execute([$jobId]); - } + + + /** + * Goes over all results and aggregates the counts for keywords of the same logLevel + * Returns an array of type ['logLevel'=> int] ex. ['warn'=> 5] + * @param $job + * @param $type + * @return array + */ + public function getJobCountPerLogLevel($job, $type) { + $json = json_decode($job->getLogalyzerResults(), true); + $resultArray = $json->results; + $accumulatedCounts = []; + foreach ($resultArray as $element) { + if($type === 'negative' && $element->type === 'negative') { + if(array_key_exists($element->logLevel, $accumulatedCounts)) { + $accumulatedCounts[$element->logLevel] += $element->count; + } + else { + $accumulatedCounts[$element->logLevel] = $element->count; + } + } + elseif ($type === 'positive' && $element->type === 'positive') { + if(!array_key_exists($element->logLevel, $accumulatedCounts)) { + $accumulatedCounts[$element->logLevel] = 1; + } + } + } + return $accumulatedCounts; + } + public function getJobHash($job) { + $json = json_decode($job->getLogalyzerResults(), true); + return $json->hash; + } + public function setJobHash($job, $hash) { + $json = json_decode($job->getLogalyzerResults(), true); + $json->hash = $hash; + $job->setLogalyzerResults(json_encode($json)); + Factory::getJobFactory()->update($job); + } } diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 5bc3352bb1..6ca8ae2e19 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -11,10 +11,8 @@ class Logalyzer_Library { private $job; private $system; private $log; - private $warningPatterns; - private $errorPatterns; - private $mandatoryPatterns; private $data; + private $results; /** * @throws Exception @@ -45,16 +43,20 @@ public function setJob($job) { * @param bool $regex * @return int */ - public function countLogOccurances(string $keyword, string $target, bool $regex = false) { - if ($regex) { + public function countLogOccurances(string $keyword, string $target, string $regex) { + if ($regex === 'regex') { return preg_match_all($keyword, $target); - } else { + } elseif ($regex === 'string') { return substr_count($target, $keyword); } + else { + return 0; + } } private function checkHashDifference() { - return !($this->job->getLogalyzerHash() === hash('sha1', json_encode('sha1', $this->data))); + $results = json_decode($this->job->getLogalyzerResults(), true); + return !($results->hash === hash('sha1', json_encode($this->data))); } /** @@ -69,59 +71,27 @@ public function examineEntireLog() { } else { $this->log = $log; } - // Check if there have been changes to the log + $this->results = $this->job->getLogalyzerResults(); + $this->createEmptyJobLogalyzerResults(); + $hash = $this->calculateHash(); - $mandatoryPatternPresent = 0; - // Count occurrences of all defined keywords. - $warningCount = 0; - $errorCount = 0; - $LOG_ERRORS_MAX = 10; - // TODO change to constant when available - foreach ($this->warningPatterns['regex'] as $key) { - $warningCount += $this->countLogOccurances($key, $this->log, true); - if($warningCount >= $LOG_ERRORS_MAX) { - break; - } - } - foreach ($this->warningPatterns['string'] as $key) { - $count = $this->countLogOccurances($key, $this->log); - $warningCount += $count; - if($warningCount >= $LOG_ERRORS_MAX) { - break; - } - } - foreach ($this->errorPatterns['regex'] as $key) { - $errorCount += $this->countLogOccurances($key, $this->log, true); - if($errorCount >= $LOG_ERRORS_MAX) { - break; - } - } - foreach ($this->errorPatterns['string'] as $key) { - $errorCount += $this->countLogOccurances($key, $this->log); - if($errorCount >= $LOG_ERRORS_MAX) { - break; - } - } - // If no mandatory pattern is defined - if (count($this->mandatoryPatterns['string'])==0 && count($this->mandatoryPatterns['regex']) == 0) { - $mandatoryPatternPresent = 1; - } - else { - foreach ($this->mandatoryPatterns['regex'] as $key) { - if ($this->countLogOccurances($key, $this->log, true) > 0) { - $mandatoryPatternPresent = 1; + + foreach($this->data->patterns as $pattern) { + $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); + $found = false; + foreach($this->results->patterns as $result) { + if($pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { + $result['count'] += $number; + $found = true; } } - foreach ($this->mandatoryPatterns['string'] as $key) { - if ($this->countLogOccurances($key, $this->log) > 0) { - $mandatoryPatternPresent = 1; - } + if(!$found) { + $pattern['count'] = $number; + $this->results->patterns[] = $pattern; } } - $this->job->setLogalyzerContainsMandatoryPattern($mandatoryPatternPresent); - $this->job->setLogalyzerWarningCount($warningCount); - $this->job->setLogalyzerErrorCount($errorCount); - $this->job->setLogalyzerHash($hash); + $this->results->hash = $hash; + $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); } @@ -132,53 +102,7 @@ public function examineEntireLog() { * @return void */ public function examineLogLine($logLine) { - echo "Type: " . gettype($logLine) . "\n"; - echo "Line: " . $logLine . "\n"; $hash = $this->calculateHash(); - foreach ($this->warningPatterns['regex'] as $key) { - if ($this->countLogOccurances($key, $logLine, true) > 0) { - Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); - } - } - foreach ($this->warningPatterns['string'] as $key) { - if ($this->countLogOccurances($key, $logLine) > 0) { - Factory::getJobFactory()->incrementJobError('warning', $this->job->getId()); - } - } - foreach ($this->errorPatterns['regex'] as $key) { - if ($this->countLogOccurances($key, $logLine, true) > 0) { - Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); - } - } - foreach ($this->errorPatterns['string'] as $key) { - echo "checking for error key: " . $key . "\n"; - if ($this->countLogOccurances($key, $logLine) > 0) { - echo "error increment\n"; - Factory::getJobFactory()->incrementJobError('error', $this->job->getId()); - } - } - // If no mandatory pattern is defined - if (count($this->mandatoryPatterns['string'])==0 && count($this->mandatoryPatterns['regex']) == 0) { - $this->job->setLogalyzerContainsMandatoryPattern(1); - } else { - $mandatoryPatternPresent = 0; - foreach ($this->mandatoryPatterns['regex'] as $key) { - if ($this->countLogOccurances($key, $this->log, true) > 0) { - $this->job->setLogalyzerContainsMandatoryPattern(1); - Factory::getJobFactory()->update($this->job); - } - } - foreach ($this->mandatoryPatterns['string'] as $key) { - if ($this->countLogOccurances($key, $this->log) > 0) { - $this->job->setLogalyzerContainsMandatoryPattern(1); - Factory::getJobFactory()->update($this->job); - } - } - } - if($this->job->getLogalyzerHash == null) { - $this->job->setLogalyzerHash($hash); - Factory::getJobFactory()->update($this->job); - } } /** @@ -186,46 +110,32 @@ public function examineLogLine($logLine) { * @return void */ private function createBasicPatterns() { - $this->data['warningPattern'] = ['string' => [], 'regex' => []]; - $this->data['errorPattern'] = ['string' => [], 'regex' => []]; - $this->data['mandatoryPattern'] = ['string' => [], 'regex' => []]; - $this->warningPatterns['string'] = []; - $this->warningPatterns['regex'] = []; - $this->errorPatterns['string'] = []; - $this->errorPatterns['regex'] = []; - $this->mandatoryPatterns['string'] = []; - $this->mandatoryPatterns['regex'] = []; + $this->data->hash = ""; + $this->data->pattern[] = array(); } /** * Returns the arrays containing pattern - * $identifier can be 'all', 'warning' or 'error' or 'mandatory - * @param $identifier - * @return array|mixed + * $identifier can be 'all', or the desired logLevel such as 'warn' or 'error' + * @param string $identifier + * @param string $type 'regex' or 'string' + * @return array */ - public function getPatterns($identifier) { - if($this->system->getLogalyzerPatterns() == null) { - $this->createBasicPatterns(); - $this->savePatterns(); + public function getPatterns(string $identifier, string $type) { + if ($this->data == null) { + echo "Error in getPatterns. loadPatterns() first"; + return ['Error in getPatterns. loadPatterns() first']; } - $patterns = $this->system->getLogalyzerPatterns(); - if ($patterns != null) { - $this->data = json_decode($patterns, true); - if ($identifier === 'all') { - return $this->data; - }elseif ($identifier === 'warning') { - return $this->data['warningPattern']; - } elseif ($identifier === 'error') { - return $this->data['errorPattern']; - } elseif ($identifier === 'mandatory') { - return $this->data['mandatoryPattern']; - } else { - echo "Error in getpatterns"; - return []; - } + if ($identifier === 'all') { + return $this->data->pattern; } else { - echo "Error in getpatterns"; - return []; + $temp = []; + foreach ($this->data->pattern as $pattern) { + if ($pattern->logLegel === $identifier && $pattern->type === $type) { + $temp[] = $pattern; + } + } + return $temp; } } @@ -238,9 +148,6 @@ public function loadPatterns() { $patterns = $this->system->getLogalyzerPatterns(); if ($patterns != null) { $this->data = json_decode($patterns, true); - $this->warningPatterns = $this->data['warningPattern']; - $this->errorPatterns = $this->data['errorPattern']; - $this->mandatoryPatterns = $this->data['mandatoryPattern']; } else { // Initial load of patterns returned null @@ -255,93 +162,63 @@ public function loadPatterns() { * @return void */ private function savePatterns() { - $this->data['warningPattern'] = $this->warningPatterns; - $this->data['errorPattern'] = $this->errorPatterns; - $this->data['mandatoryPattern'] = $this->mandatoryPatterns; - - $encoded = json_encode($this->data); - $this->system->setLogalyzerPatterns($encoded); + $this->data->hash = hash('sha1', $this->data->pattern); + $this->system->setLogalyzerPatterns(json_encode($this->data)); Factory::getSystemFactory()->update($this->system); } /** - * @param string $identifier 'log level' - * @param string $type 'string' or 'regex' - * @param string $key new key + * @param string $logLevel + * @param string $pattern 'the pattern string' + * @param string $regex 'string' or 'regex' + * @param string $type 'positive' or 'negative' * @return void */ - public function addKey(string $identifier, string $type, string $key) { + public function addKey(string $logLevel, string $pattern, string $regex, string $type) { if($this->system == null) { echo 'System not defined\n'; } else { - if ($identifier == 'warning') { - if (!in_array($key, $this->warningPatterns[$type])) { - $this->warningPatterns[$type][] = $key; - } - } elseif ($identifier == 'error') { - if (!in_array($key, $this->errorPatterns[$type])) { - $this->errorPatterns[$type][] = $key; - } - } elseif ($identifier == 'mandatory') { - if (!in_array($key, $this->mandatoryPatterns[$type])) { - $this->mandatoryPatterns[$type][] = $key; - } - } else { - echo "Error in identifier or isRegex inside logalyzer."; + $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => $regex, 'type' => $type); + if(!in_array($array, $this->data->pattern)) { + $this->data->pattern[] = $array; + $this->savePatterns(); } - $this->savePatterns(); } } /** - * @param string $identifier is $key a warning or error? - * @param string $key key to delete + * @param string $logLevel + * @param string $pattern 'the pattern string' + * @param string $regex 'string' or 'regex' + * @param string $type 'positive' or 'negative' * @return void */ - public function removeKey(string $identifier, string $key) { - if ($this->system == null) { + public function removeKey(string $logLevel, string $pattern, string $regex, string $type) { + if($this->system == null) { echo 'System not defined\n'; } else { - if ($identifier == 'warning') { - if (($index = array_search($key, $this->warningPatterns['string'])) !== false) { - unset($this->warningPatterns['string'][$index]); - } - if (($index = array_search($key, $this->warningPatterns['regex'])) !== false) { - unset($this->warningPatterns['string'][$index]); - } - } - elseif ($identifier == 'error') { - if (($index = array_search($key, $this->errorPatterns['string'])) !== false) { - unset($this->errorPatterns['string'][$index]); - $this->errorPatterns['string'] = array_values($this->errorPatterns['string']); - } - if (($index = array_search($key, $this->errorPatterns['regex'])) !== false) { - unset($this->errorPatterns['regex'][$index]); - $this->errorPatterns['regex'] = array_values($this->errorPatterns['regex']); - } - } - elseif ($identifier == 'mandatory') { - if (($index = array_search($key, $this->mandatoryPatterns['string'])) !== false) { - unset($this->mandatoryPatterns['string'][$index]); - $this->mandatoryPatterns['string'] = array_values($this->mandatoryPatterns['string']); - } - if (($index = array_search($key, $this->mandatoryPatterns['regex'])) !== false) { - unset($this->mandatoryPatterns['regex'][$index]); - $this->mandatoryPatterns['regex'] = array_values($this->mandatoryPatterns['regex']); - } + $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => $regex, 'type' => $type); + if(in_array($array, $this->data->pattern)) { + $index = array_search($array, $this->data->pattern); + unset($this->data->pattern[$index]); + $this->savePatterns(); } - else { - echo "identifier not recognized."; - } - $this->savePatterns(); } } + private function createEmptyJobLogalyzerResults() { + $this->results->hash = ""; + $this->results->pattern = array(); + } + private function saveJobLogalyzerResults() { + $this->job->setLogalyzerResults(json_encode($this->results)); + Factory::getJobFactory()->update($this->job); + } /** * Allows calculating the hash before any operations are done * @return string */ function calculateHash() { - return hash('sha1', json_encode($this->data)); + return hash('sha1', json_encode($this->data->pattern)); } } From 3c21b1f3e709717d0dc49438dd463547d5a66665 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 15:32:15 +0200 Subject: [PATCH 386/644] Changed all backend to support new json structures. Frontend must be patched aswell --- libraries/dba/models/Job.class.php | 54 ++++--------------- libraries/dba/models/JobFactory.class.php | 4 +- libraries/dba/models/JobView.class.php | 42 ++++----------- libraries/dba/models/JobViewFactory.class.php | 4 +- libraries/dba/models/System.class.php | 2 +- libraries/dba/models/SystemFactory.class.php | 2 +- 6 files changed, 24 insertions(+), 84 deletions(-) diff --git a/libraries/dba/models/Job.class.php b/libraries/dba/models/Job.class.php index 30e95a9d74..fe2b36970c 100644 --- a/libraries/dba/models/Job.class.php +++ b/libraries/dba/models/Job.class.php @@ -43,12 +43,9 @@ class Job extends AbstractModel { private $evaluationId; private $internalId; private $configurationIdentifier; - private $logalyzerWarningCount; - private $logalyzerErrorCount; - private $logalyzerHash; - private $logalyzerContainsMandatoryPattern; + private $logalyzerResults; - function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $logalyzerWarningCount=null, $logalyzerErrorCount=null, $logalyzerHash=null, $logalyzerContainsMandatoryPattern=null) { + function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $logalyzerResults=null) { $this->jobId = $jobId; $this->userId = $userId; $this->description = $description; @@ -65,10 +62,7 @@ function __construct($jobId, $userId, $description, $systemId, $environment, $ph $this->evaluationId = $evaluationId; $this->internalId = $internalId; $this->configurationIdentifier = $configurationIdentifier; - $this->logalyzerWarningCount = $logalyzerWarningCount; - $this->logalyzerErrorCount = $logalyzerErrorCount; - $this->logalyzerHash = $logalyzerHash; - $this->logalyzerContainsMandatoryPattern = $logalyzerContainsMandatoryPattern; + $this->logalyzerResults = $logalyzerResults; } function getKeyValueDict() { @@ -89,10 +83,7 @@ function getKeyValueDict() { $dict['evaluationId'] = $this->evaluationId; $dict['internalId'] = $this->internalId; $dict['configurationIdentifier'] = $this->configurationIdentifier; - $dict['logalyzerWarningCount'] = $this->logalyzerWarningCount; - $dict['logalyzerErrorCount'] = $this->logalyzerErrorCount; - $dict['logalyzerHash'] = $this->logalyzerHash; - $dict['logalyzerContainsMandatoryPattern'] = $this->logalyzerContainsMandatoryPattern; + $dict['logalyzerResults'] = $this->logalyzerResults; return $dict; } @@ -233,36 +224,12 @@ function setConfigurationIdentifier($configurationIdentifier){ $this->configurationIdentifier = $configurationIdentifier; } - function getLogalyzerWarningCount(){ - return $this->logalyzerWarningCount; + function getLogalyzerResults(){ + return $this->logalyzerResults; } - function setLogalyzerWarningCount($logalyzerWarningCount){ - $this->logalyzerWarningCount = $logalyzerWarningCount; - } - - function getLogalyzerErrorCount(){ - return $this->logalyzerErrorCount; - } - - function setLogalyzerErrorCount($logalyzerErrorCount){ - $this->logalyzerErrorCount = $logalyzerErrorCount; - } - - function getLogalyzerHash(){ - return $this->logalyzerHash; - } - - function setLogalyzerHash($logalyzerHash){ - $this->logalyzerHash = $logalyzerHash; - } - - function getLogalyzerContainsMandatoryPattern(){ - return $this->logalyzerContainsMandatoryPattern; - } - - function setLogalyzerContainsMandatoryPattern($logalyzerContainsMandatoryPattern){ - $this->logalyzerContainsMandatoryPattern = $logalyzerContainsMandatoryPattern; + function setLogalyzerResults($logalyzerResults){ + $this->logalyzerResults = $logalyzerResults; } const JOB_ID = "jobId"; @@ -281,8 +248,5 @@ function setLogalyzerContainsMandatoryPattern($logalyzerContainsMandatoryPattern const EVALUATION_ID = "evaluationId"; const INTERNAL_ID = "internalId"; const CONFIGURATION_IDENTIFIER = "configurationIdentifier"; - const LOGALYZER_WARNING_COUNT = "logalyzerWarningCount"; - const LOGALYZER_ERROR_COUNT = "logalyzerErrorCount"; - const LOGALYZER_HASH = "logalyzerHash"; - const LOGALYZER_CONTAINS_MANDATORY_PATTERN = "logalyzerContainsMandatoryPattern"; + const LOGALYZER_RESULTS = "logalyzerResults"; } diff --git a/libraries/dba/models/JobFactory.class.php b/libraries/dba/models/JobFactory.class.php index bc66ba7d6c..04b1f2f03c 100644 --- a/libraries/dba/models/JobFactory.class.php +++ b/libraries/dba/models/JobFactory.class.php @@ -47,7 +47,7 @@ function getCacheValidTime() { * @return Job */ function getNullObject() { - $o = new Job(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); + $o = new Job(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); return $o; } @@ -57,7 +57,7 @@ function getNullObject() { * @return Job */ function createObjectFromDict($pk, $dict) { - $o = new Job($dict['jobId'], $dict['userId'], $dict['description'], $dict['systemId'], $dict['environment'], $dict['phases'], $dict['configuration'], $dict['status'], $dict['progress'], $dict['result'], $dict['created'], $dict['started'], $dict['finished'], $dict['evaluationId'], $dict['internalId'], $dict['configurationIdentifier'], $dict['logalyzerWarningCount'], $dict['logalyzerErrorCount'], $dict['logalyzerHash'], $dict['logalyzerContainsMandatoryPattern']); + $o = new Job($dict['jobId'], $dict['userId'], $dict['description'], $dict['systemId'], $dict['environment'], $dict['phases'], $dict['configuration'], $dict['status'], $dict['progress'], $dict['result'], $dict['created'], $dict['started'], $dict['finished'], $dict['evaluationId'], $dict['internalId'], $dict['configurationIdentifier'], $dict['logalyzerResults']); return $o; } diff --git a/libraries/dba/models/JobView.class.php b/libraries/dba/models/JobView.class.php index 63b6dca7df..8b86a28e5b 100644 --- a/libraries/dba/models/JobView.class.php +++ b/libraries/dba/models/JobView.class.php @@ -44,11 +44,9 @@ class JobView extends AbstractModel { private $internalId; private $configurationIdentifier; private $projectUserId; - private $logalyzerCountWarnings; - private $logalyzerCountErrors; - private $logalyzerHash; + private $logalyzerResults; - function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $projectUserId, $logalyzerCountWarnings, $logalyzerCountErrors, $logalyzerHash) { + function __construct($jobId, $userId, $description, $systemId, $environment, $phases, $configuration, $status, $progress, $result, $created, $started, $finished, $evaluationId, $internalId, $configurationIdentifier, $projectUserId, $logalyzerResults=null) { $this->jobId = $jobId; $this->userId = $userId; $this->description = $description; @@ -66,9 +64,7 @@ function __construct($jobId, $userId, $description, $systemId, $environment, $ph $this->internalId = $internalId; $this->configurationIdentifier = $configurationIdentifier; $this->projectUserId = $projectUserId; - $this->logalyzerCountWarnings = $logalyzerCountWarnings; - $this->logalyzerCountErrors = $logalyzerCountErrors; - $this->logalyzerHash = $logalyzerHash; + $this->logalyzerResults = $logalyzerResults; } function getKeyValueDict() { @@ -90,9 +86,7 @@ function getKeyValueDict() { $dict['internalId'] = $this->internalId; $dict['configurationIdentifier'] = $this->configurationIdentifier; $dict['projectUserId'] = $this->projectUserId; - $dict['logalyzerCountWarnings'] = $this->logalyzerCountWarnings; - $dict['logalyzerCountErrors'] = $this->logalyzerCountErrors; - $dict['logalyzerHash'] = $this->logalyzerHash; + $dict['logalyzerResults'] = $this->logalyzerResults; return $dict; } @@ -241,28 +235,12 @@ function setProjectUserId($projectUserId){ $this->projectUserId = $projectUserId; } - function getLogalyzerCountWarnings(){ - return $this->logalyzerCountWarnings; + function getLogalyzerResults(){ + return $this->logalyzerResults; } - function setLogalyzerCountWarnings($logalyzerCountWarnings){ - $this->logalyzerCountWarnings = $logalyzerCountWarnings; - } - - function getLogalyzerCountErrors(){ - return $this->logalyzerCountErrors; - } - - function setLogalyzerCountErrors($logalyzerCountErrors){ - $this->logalyzerCountErrors = $logalyzerCountErrors; - } - - function getLogalyzerHash(){ - return $this->logalyzerHash; - } - - function setLogalyzerHash($logalyzerHash){ - $this->logalyzerHash = $logalyzerHash; + function setLogalyzerResults($logalyzerResults){ + $this->logalyzerResults = $logalyzerResults; } const JOB_ID = "jobId"; @@ -282,7 +260,5 @@ function setLogalyzerHash($logalyzerHash){ const INTERNAL_ID = "internalId"; const CONFIGURATION_IDENTIFIER = "configurationIdentifier"; const PROJECT_USER_ID = "projectUserId"; - const LOGALYZER_COUNT_WARNINGS = "logalyzerCountWarnings"; - const LOGALYZER_COUNT_ERRORS = "logalyzerCountErrors"; - const LOGALYZER_HASH = "logalyzerHash"; + const LOGALYZER_RESULTS = "logalyzerResults"; } diff --git a/libraries/dba/models/JobViewFactory.class.php b/libraries/dba/models/JobViewFactory.class.php index 539f11380a..06cf5cd15f 100644 --- a/libraries/dba/models/JobViewFactory.class.php +++ b/libraries/dba/models/JobViewFactory.class.php @@ -47,7 +47,7 @@ function getCacheValidTime() { * @return JobView */ function getNullObject() { - $o = new JobView(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); + $o = new JobView(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); return $o; } @@ -57,7 +57,7 @@ function getNullObject() { * @return JobView */ function createObjectFromDict($pk, $dict) { - $o = new JobView($dict['jobId'], $dict['userId'], $dict['description'], $dict['systemId'], $dict['environment'], $dict['phases'], $dict['configuration'], $dict['status'], $dict['progress'], $dict['result'], $dict['created'], $dict['started'], $dict['finished'], $dict['evaluationId'], $dict['internalId'], $dict['configurationIdentifier'], $dict['projectUserId'], $dict['logalyzerCountWarnings'], $dict['logalyzerCountErrors'], $dict['logalyzerHash']); + $o = new JobView($dict['jobId'], $dict['userId'], $dict['description'], $dict['systemId'], $dict['environment'], $dict['phases'], $dict['configuration'], $dict['status'], $dict['progress'], $dict['result'], $dict['created'], $dict['started'], $dict['finished'], $dict['evaluationId'], $dict['internalId'], $dict['configurationIdentifier'], $dict['projectUserId'], $dict['logalyzerResults']); return $o; } diff --git a/libraries/dba/models/System.class.php b/libraries/dba/models/System.class.php index 7db3dc6039..6056a291bf 100644 --- a/libraries/dba/models/System.class.php +++ b/libraries/dba/models/System.class.php @@ -41,7 +41,7 @@ class System extends AbstractModel { private $isArchived; private $logalyzerPatterns; - function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns=false) { + function __construct($systemId, $name, $description, $userId, $vcsUrl, $vcsBranch, $vcsType, $vcsUser, $vcsPassword, $created, $lastEdit, $isArchived, $logalyzerPatterns=null) { $this->systemId = $systemId; $this->name = $name; $this->description = $description; diff --git a/libraries/dba/models/SystemFactory.class.php b/libraries/dba/models/SystemFactory.class.php index e9fd90fe95..8d4e47f8cc 100644 --- a/libraries/dba/models/SystemFactory.class.php +++ b/libraries/dba/models/SystemFactory.class.php @@ -32,7 +32,7 @@ function getModelName() { } function getModelTable() { - return "`System`"; + return "System"; } function isCachable() { From c6e572cbd208dd58155b4d49791b0302499728f2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 15:33:32 +0200 Subject: [PATCH 387/644] Changed all backend to support new json structures. Frontend must be patched aswell --- libraries/dba/models/SystemFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/models/SystemFactory.class.php b/libraries/dba/models/SystemFactory.class.php index 8d4e47f8cc..e9fd90fe95 100644 --- a/libraries/dba/models/SystemFactory.class.php +++ b/libraries/dba/models/SystemFactory.class.php @@ -32,7 +32,7 @@ function getModelName() { } function getModelTable() { - return "System"; + return "`System`"; } function isCachable() { From 7997edaecd29c3f30391a575a1c24bfd7731b929 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 15:56:03 +0200 Subject: [PATCH 388/644] Changed all backend to support new json structures. Frontend must be patched aswell --- controllers/admin.php | 24 ++++++++++++------------ libraries/logalyzer.php | 21 ++++++++++++++------- views/admin/system.php | 10 ++++------ 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 4c0932ac54..0b0de4aa0b 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -396,9 +396,9 @@ public function system() { $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); if(!empty($this->post['regexError'])&&$this->post['regexError']=='on') { - $logalyzer->addKey('error', 'regex', $key); + $logalyzer->addKey('error', $key, 'regex', 'negative'); } else { - $logalyzer->addKey('error', 'string', $key); + $logalyzer->addKey('error', $key, 'string', 'negative'); } } } else if (!empty($this->post['group'] == 'newWarning')) { @@ -408,9 +408,9 @@ public function system() { $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); if(!empty($this->post['regexWarning'])&&$this->post['regexWarning']=='on') { - $logalyzer->addKey('warning', 'regex', $key); + $logalyzer->addKey('warn', $key, 'regex', 'negative'); } else { - $logalyzer->addKey('warning', 'string', $key); + $logalyzer->addKey('warn', $key, 'string', 'negative'); } } } else if (!empty($this->post['group'] == 'newMandatory')) { @@ -420,9 +420,9 @@ public function system() { $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); if(!empty($this->post['regexMandatory'])&&$this->post['regexMandatory']=='on') { - $logalyzer->addKey('mandatory', 'regex', $key); + $logalyzer->addKey('error', $key, 'regex', 'positive'); } else { - $logalyzer->addKey('mandatory', 'string', $key); + $logalyzer->addKey('error', $key, 'string', 'positive'); } } } @@ -433,7 +433,7 @@ public function system() { $system = Factory::getSystemFactory()->get($this->get['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); - $logalyzer->removeKey('warning', $key); + $logalyzer->removeKey('warn', $key, 'negative'); } } else if (!empty($this->get['deleteErrorPattern'])) { $key = $this->get['deleteErrorPattern']; @@ -441,7 +441,7 @@ public function system() { $system = Factory::getSystemFactory()->get($this->get['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); - $logalyzer->removeKey('error', $key); + $logalyzer->removeKey('error', $key, 'negative'); } } else if (!empty($this->get['deleteMandatoryPattern'])) { $key = $this->get['deleteMandatoryPattern']; @@ -449,7 +449,7 @@ public function system() { $system = Factory::getSystemFactory()->get($this->get['id']); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); - $logalyzer->removeKey('mandatory', $key); + $logalyzer->removeKey('error', $key, 'positive'); } } else if (!empty($this->get['delete'])) { @@ -560,9 +560,9 @@ public function system() { $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); - $errors = $logalyzer->getPatterns("error"); - $warnings = $logalyzer->getPatterns("warning"); - $mandatory = $logalyzer->getPatterns("mandatory"); + $errors = $logalyzer->getPatterns('error', 'negative'); + $warnings = $logalyzer->getPatterns('warn', 'negative'); + $mandatory = $logalyzer->getPatterns('error', "positive"); $this->view->assign('errorPatterns', $errors); $this->view->assign('warningPatterns', $warnings); $this->view->assign('mandatoryPatterns', $mandatory); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 6ca8ae2e19..eb02190c5c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -121,17 +121,16 @@ private function createBasicPatterns() { * @param string $type 'regex' or 'string' * @return array */ - public function getPatterns(string $identifier, string $type) { + public function getPatterns(string $logLevel, string $type) { if ($this->data == null) { - echo "Error in getPatterns. loadPatterns() first"; - return ['Error in getPatterns. loadPatterns() first']; + $this->createBasicPatterns(); } - if ($identifier === 'all') { + if ($logLevel === 'all') { return $this->data->pattern; } else { $temp = []; foreach ($this->data->pattern as $pattern) { - if ($pattern->logLegel === $identifier && $pattern->type === $type) { + if ($pattern->logLegel === $logLevel && $pattern->type === $type) { $temp[] = $pattern; } } @@ -193,17 +192,25 @@ public function addKey(string $logLevel, string $pattern, string $regex, string * @param string $type 'positive' or 'negative' * @return void */ - public function removeKey(string $logLevel, string $pattern, string $regex, string $type) { + public function removeKey(string $logLevel, string $pattern, string $type) { if($this->system == null) { echo 'System not defined\n'; } else { - $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => $regex, 'type' => $type); + $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => 'string', 'type' => $type); if(in_array($array, $this->data->pattern)) { $index = array_search($array, $this->data->pattern); unset($this->data->pattern[$index]); $this->savePatterns(); } + else { + $array['regex'] = 'regex'; + if(in_array($array, $this->data->pattern)) { + $index = array_search($array, $this->data->pattern); + unset($this->data->pattern[$index]); + $this->savePatterns(); + } + } } } private function createEmptyJobLogalyzerResults() { diff --git a/views/admin/system.php b/views/admin/system.php index 1b27da5a2e..b046799904 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -515,21 +515,19 @@
- $array) { - foreach ($array as $key) {?> + - +
From 608051ae6eefe5990d490b740393387dabd17215 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 15:59:19 +0200 Subject: [PATCH 389/644] Front-End for System --- views/admin/system.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index b046799904..943388db83 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -479,22 +479,20 @@
- $array) { - foreach ($array as $key) {?> + - +

@@ -545,23 +543,21 @@
- - $array) { - foreach ($array as $key) {?> + + - +
From 41344c775175ad013e5ea8e941b30c6ed192fcdf Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:09:55 +0200 Subject: [PATCH 390/644] Front-End for System --- api/ui/job.php | 6 +++--- controllers/job.php | 22 ++++++++++++---------- views/evaluation/detail.php | 6 +++--- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/api/ui/job.php b/api/ui/job.php index a0841b11ab..3866a5fbf7 100644 --- a/api/ui/job.php +++ b/api/ui/job.php @@ -39,9 +39,9 @@ public function patch() { } if(isset($this->request['getLogalyzerResponse'])) { //echo "working"; - $warning = $job->getLogalyzerWarningCount(); - $error = $job->getLogalyzerErrorCount(); - $mandatory = $job->getLogalyzerContainsMandatoryPattern(); + $warning = -1; + $error = -1; + $mandatory = -1; $string = json_encode('{"warning": ' . $warning .',"error": '. $error . ',"mandatory": '. $mandatory .'}'); $this->addData('response', $string); } diff --git a/controllers/job.php b/controllers/job.php index 312f189cbb..63a20849be 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -147,19 +147,21 @@ public function detail() { $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); } - $warnings = $job->getLogalyzerWarningCount(); - $errors = $job->getLogalyzerErrorCount(); - $this->view->assign('logWarningCount', $warnings); - $this->view->assign('logErrorCount', $errors); - if($job->getStatus()==Define::JOB_STATUS_FINISHED && $job->getLogalyzerContainsMandatoryPattern()==0) { - $this->view->assign('logContainsMandatory', 0); - } + //$warnings = $job->getLogalyzerWarningCount(); + //$errors = $job->getLogalyzerErrorCount(); + $this->view->assign('logWarningCount', -1); + $this->view->assign('logErrorCount', -1); + //if($job->getStatus()==Define::JOB_STATUS_FINISHED && $job->getLogalyzerContainsMandatoryPattern()==0) { + // $this->view->assign('logContainsMandatory', 0); + //} TODO $system = Factory::getSystemFactory()->get($job->getSystemId()); // Shenanigans to normalize whitespaces and newlines - $systemHash = json_encode(json_decode($system->getLogalyzerPatterns()), true); - $systemHash = hash('sha1', $systemHash); - if($job->getLogalyzerHash() != $systemHash) { + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystemAndLoadPattern($system); + $hash = $logalyzer->calculateHash(); + $results = json_decode($job->getLogalyzerResults(), true) + if($results['hash'] != $hash) { $this->view->assign('usedOutdatedPattern', true); } $events = Util::eventFilter(['job' => $job]); diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 2bb740dd77..c92b3742be 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -232,12 +232,12 @@ function getLogalyzerResponses(evalId) { getInternalId(); ?> getDescription(); ?> - getLogalyzerErrorCount() > 0) { ?> + - getLogalyzerWarningCount() > 0) { ?> + - getStatus() == Define::JOB_STATUS_FINISHED && $job->getLogalyzerContainsMandatoryPattern() == 0) { ?> + getStatus() == Define::JOB_STATUS_FINISHED) { ?> From 2cee54879b6c28254699a7cf70e7212198922aed Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:10:58 +0200 Subject: [PATCH 391/644] Front-End for System --- controllers/job.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/job.php b/controllers/job.php index 63a20849be..18a1c7be9e 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -160,7 +160,7 @@ public function detail() { $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); $hash = $logalyzer->calculateHash(); - $results = json_decode($job->getLogalyzerResults(), true) + $results = json_decode($job->getLogalyzerResults(), true); if($results['hash'] != $hash) { $this->view->assign('usedOutdatedPattern', true); } From e40bba0fe33b3d49cd47a785c14fdf00c10d9da4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:20:58 +0200 Subject: [PATCH 392/644] Front-End for System --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index eb02190c5c..71fe637c9c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -18,6 +18,8 @@ class Logalyzer_Library { * @throws Exception */ public function __construct($job = null) { + $this->createBasicPatterns(); + $this->savePatterns(); $this->job = $job; if($this->job != null) { $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); From 2ce484bf12fe78dd0e9441b289ffc944ff9e15ab Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:27:59 +0200 Subject: [PATCH 393/644] Front-End for System --- libraries/logalyzer.php | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 71fe637c9c..0e5372827c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -58,7 +58,7 @@ public function countLogOccurances(string $keyword, string $target, string $rege private function checkHashDifference() { $results = json_decode($this->job->getLogalyzerResults(), true); - return !($results->hash === hash('sha1', json_encode($this->data))); + return !($results['hash'] === hash('sha1', json_encode($this->data))); } /** @@ -78,10 +78,10 @@ public function examineEntireLog() { $hash = $this->calculateHash(); - foreach($this->data->patterns as $pattern) { + foreach($this->data['pattern'] as $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); $found = false; - foreach($this->results->patterns as $result) { + foreach($this->results['pattern'] as $result) { if($pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $result['count'] += $number; $found = true; @@ -89,10 +89,10 @@ public function examineEntireLog() { } if(!$found) { $pattern['count'] = $number; - $this->results->patterns[] = $pattern; + $this->results['pattern'] = $pattern; } } - $this->results->hash = $hash; + $this->results['hash'] = $hash; $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); } @@ -112,8 +112,8 @@ public function examineLogLine($logLine) { * @return void */ private function createBasicPatterns() { - $this->data->hash = ""; - $this->data->pattern[] = array(); + $this->data['hash'] = ""; + $this->data['pattern'] = array(); } /** @@ -128,10 +128,10 @@ public function getPatterns(string $logLevel, string $type) { $this->createBasicPatterns(); } if ($logLevel === 'all') { - return $this->data->pattern; + return $this->data['pattern']; } else { $temp = []; - foreach ($this->data->pattern as $pattern) { + foreach ($this->data['pattern'] as $pattern) { if ($pattern->logLegel === $logLevel && $pattern->type === $type) { $temp[] = $pattern; } @@ -163,7 +163,7 @@ public function loadPatterns() { * @return void */ private function savePatterns() { - $this->data->hash = hash('sha1', $this->data->pattern); + $this->data['hash'] = hash('sha1', $this->data['pattern']); $this->system->setLogalyzerPatterns(json_encode($this->data)); Factory::getSystemFactory()->update($this->system); } @@ -180,8 +180,8 @@ public function addKey(string $logLevel, string $pattern, string $regex, string } else { $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => $regex, 'type' => $type); - if(!in_array($array, $this->data->pattern)) { - $this->data->pattern[] = $array; + if(!in_array($array, $this->data['pattern'])) { + $this->data['pattern'] = $array; $this->savePatterns(); } } @@ -200,24 +200,24 @@ public function removeKey(string $logLevel, string $pattern, string $type) { } else { $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => 'string', 'type' => $type); - if(in_array($array, $this->data->pattern)) { - $index = array_search($array, $this->data->pattern); - unset($this->data->pattern[$index]); + if(in_array($array, $this->data['pattern'])) { + $index = array_search($array, $this->data['pattern']); + unset($this->data['pattern'][$index]); $this->savePatterns(); } else { $array['regex'] = 'regex'; - if(in_array($array, $this->data->pattern)) { - $index = array_search($array, $this->data->pattern); - unset($this->data->pattern[$index]); + if(in_array($array, $this->data['pattern'])) { + $index = array_search($array, $this->data['pattern']); + unset($this->data['pattern'][$index]); $this->savePatterns(); } } } } private function createEmptyJobLogalyzerResults() { - $this->results->hash = ""; - $this->results->pattern = array(); + $this->results['hash'] = ""; + $this->results['pattern'] = array(); } private function saveJobLogalyzerResults() { $this->job->setLogalyzerResults(json_encode($this->results)); @@ -228,6 +228,6 @@ private function saveJobLogalyzerResults() { * @return string */ function calculateHash() { - return hash('sha1', json_encode($this->data->pattern)); + return hash('sha1', json_encode($this->data['pattern'])); } } From b6d397ba28d42da5caa5306326a16d18aa4de4f5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:29:54 +0200 Subject: [PATCH 394/644] Front-End for System --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 0e5372827c..af0912facf 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -163,7 +163,7 @@ public function loadPatterns() { * @return void */ private function savePatterns() { - $this->data['hash'] = hash('sha1', $this->data['pattern']); + $this->data['hash'] = hash('sha1', json_encode($this->data['pattern'])); $this->system->setLogalyzerPatterns(json_encode($this->data)); Factory::getSystemFactory()->update($this->system); } From 80d29882b6049a5e6713063617631041eaaf5f9d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:31:24 +0200 Subject: [PATCH 395/644] Front-End for System --- libraries/logalyzer.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index af0912facf..a9da8d4c01 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -18,8 +18,6 @@ class Logalyzer_Library { * @throws Exception */ public function __construct($job = null) { - $this->createBasicPatterns(); - $this->savePatterns(); $this->job = $job; if($this->job != null) { $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); @@ -34,6 +32,10 @@ public function getSystem() { } public function setSystemAndLoadPattern($system) { $this->system = $system; + // DEBUGGING DELETE the 2 lines below + $this->createBasicPatterns(); + $this->savePatterns(); + $this->loadPatterns(); } public function setJob($job) { From b3c84a422dd83009200bb2dc831d139913d454ba Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:31:39 +0200 Subject: [PATCH 396/644] Front-End for System --- libraries/logalyzer.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index a9da8d4c01..f9252c2697 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -32,10 +32,6 @@ public function getSystem() { } public function setSystemAndLoadPattern($system) { $this->system = $system; - // DEBUGGING DELETE the 2 lines below - $this->createBasicPatterns(); - $this->savePatterns(); - $this->loadPatterns(); } public function setJob($job) { From dc8dfb45f4ef213716139bfcfc9a8765a2d45585 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:34:54 +0200 Subject: [PATCH 397/644] Front-End for System --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index f9252c2697..90a6d3e45d 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -130,7 +130,7 @@ public function getPatterns(string $logLevel, string $type) { } else { $temp = []; foreach ($this->data['pattern'] as $pattern) { - if ($pattern->logLegel === $logLevel && $pattern->type === $type) { + if ($pattern['logLegel'] === $logLevel && $pattern['type'] === $type) { $temp[] = $pattern; } } From e8e20f86f89ba2dcd826a7592481ee2345a94910 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:36:24 +0200 Subject: [PATCH 398/644] Front-End for System --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 90a6d3e45d..27c0ed4969 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -130,7 +130,7 @@ public function getPatterns(string $logLevel, string $type) { } else { $temp = []; foreach ($this->data['pattern'] as $pattern) { - if ($pattern['logLegel'] === $logLevel && $pattern['type'] === $type) { + if ($pattern['logLevel'] == $logLevel && $pattern['type'] == $type) { $temp[] = $pattern; } } From 0753d229815596947eb9584d4d7273ce639a6d38 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:36:57 +0200 Subject: [PATCH 399/644] Front-End for System --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 27c0ed4969..e8ac0f427f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -129,6 +129,8 @@ public function getPatterns(string $logLevel, string $type) { return $this->data['pattern']; } else { $temp = []; + echo $this->data['pattern']; + echo gettype($this->data['pattern']); foreach ($this->data['pattern'] as $pattern) { if ($pattern['logLevel'] == $logLevel && $pattern['type'] == $type) { $temp[] = $pattern; From ea4f0fd3fb28c49c178620270d8619fcb24d460f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:37:24 +0200 Subject: [PATCH 400/644] Front-End for System --- libraries/logalyzer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e8ac0f427f..e9c7944493 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -129,8 +129,7 @@ public function getPatterns(string $logLevel, string $type) { return $this->data['pattern']; } else { $temp = []; - echo $this->data['pattern']; - echo gettype($this->data['pattern']); + print_r($this->data['pattern']); foreach ($this->data['pattern'] as $pattern) { if ($pattern['logLevel'] == $logLevel && $pattern['type'] == $type) { $temp[] = $pattern; From 785245d544d7e57d0f6bca3657c9581f98ef3f1a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:40:24 +0200 Subject: [PATCH 401/644] Front-End for System --- libraries/logalyzer.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e9c7944493..fa6f0faea0 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -130,6 +130,11 @@ public function getPatterns(string $logLevel, string $type) { } else { $temp = []; print_r($this->data['pattern']); + foreach ($this->data['pattern'] as $pattern) { + foreach ($pattern as $key => $value) { + echo 'Keytype: ' . gettype($key) . '. value type: ' .gettype($value); + } + } foreach ($this->data['pattern'] as $pattern) { if ($pattern['logLevel'] == $logLevel && $pattern['type'] == $type) { $temp[] = $pattern; From 3dac3aa3024f0dfd802b6fd46c717bd9cea71199 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:41:34 +0200 Subject: [PATCH 402/644] Front-End for System --- libraries/logalyzer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index fa6f0faea0..de97bea5ee 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -32,6 +32,8 @@ public function getSystem() { } public function setSystemAndLoadPattern($system) { $this->system = $system; + $this->createBasicPatterns(); + $this->savePatterns(); $this->loadPatterns(); } public function setJob($job) { @@ -185,7 +187,7 @@ public function addKey(string $logLevel, string $pattern, string $regex, string else { $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => $regex, 'type' => $type); if(!in_array($array, $this->data['pattern'])) { - $this->data['pattern'] = $array; + $this->data['pattern'][] = $array; $this->savePatterns(); } } From 84423585502076ec5a5819b149e7e9e35fd8cc0f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:41:52 +0200 Subject: [PATCH 403/644] Front-End for System --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index de97bea5ee..88242e82f9 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -32,8 +32,8 @@ public function getSystem() { } public function setSystemAndLoadPattern($system) { $this->system = $system; - $this->createBasicPatterns(); - $this->savePatterns(); + //$this->createBasicPatterns(); + //$this->savePatterns(); $this->loadPatterns(); } public function setJob($job) { From dc959e4ad5d41329f5d50deeb6900aaedf139d11 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:44:00 +0200 Subject: [PATCH 404/644] Front-End for System --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 88242e82f9..de97bea5ee 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -32,8 +32,8 @@ public function getSystem() { } public function setSystemAndLoadPattern($system) { $this->system = $system; - //$this->createBasicPatterns(); - //$this->savePatterns(); + $this->createBasicPatterns(); + $this->savePatterns(); $this->loadPatterns(); } public function setJob($job) { From 1f0006863315b865b79a2498e642cc047a50029d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:44:40 +0200 Subject: [PATCH 405/644] Front-End for System --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index de97bea5ee..88242e82f9 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -32,8 +32,8 @@ public function getSystem() { } public function setSystemAndLoadPattern($system) { $this->system = $system; - $this->createBasicPatterns(); - $this->savePatterns(); + //$this->createBasicPatterns(); + //$this->savePatterns(); $this->loadPatterns(); } public function setJob($job) { From d7abbefd894aa26d61dc8b0c36ec5b9b4c2c3840 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:45:49 +0200 Subject: [PATCH 406/644] Front-End for System --- libraries/logalyzer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 88242e82f9..3352327a03 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -131,7 +131,6 @@ public function getPatterns(string $logLevel, string $type) { return $this->data['pattern']; } else { $temp = []; - print_r($this->data['pattern']); foreach ($this->data['pattern'] as $pattern) { foreach ($pattern as $key => $value) { echo 'Keytype: ' . gettype($key) . '. value type: ' .gettype($value); From e435ae197f7fdb8f31a3dbd18f1cbcfa885537e8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:46:47 +0200 Subject: [PATCH 407/644] Front-End for System --- libraries/logalyzer.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 3352327a03..115f40c7fd 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -131,11 +131,7 @@ public function getPatterns(string $logLevel, string $type) { return $this->data['pattern']; } else { $temp = []; - foreach ($this->data['pattern'] as $pattern) { - foreach ($pattern as $key => $value) { - echo 'Keytype: ' . gettype($key) . '. value type: ' .gettype($value); - } - } + print_r($this->data['pattern']); foreach ($this->data['pattern'] as $pattern) { if ($pattern['logLevel'] == $logLevel && $pattern['type'] == $type) { $temp[] = $pattern; From 1f0eba0f11f4f2c6432720fd382f0f382b5a2a72 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:47:01 +0200 Subject: [PATCH 408/644] Front-End for System --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 115f40c7fd..b9259bfc12 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -131,7 +131,7 @@ public function getPatterns(string $logLevel, string $type) { return $this->data['pattern']; } else { $temp = []; - print_r($this->data['pattern']); + print_r($this->data['pattern']); // TODO remove debug info foreach ($this->data['pattern'] as $pattern) { if ($pattern['logLevel'] == $logLevel && $pattern['type'] == $type) { $temp[] = $pattern; From d11964a9b5b758e5ff309a53240efe1ee025dbaf Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:56:24 +0200 Subject: [PATCH 409/644] Front-End for System --- controllers/evaluation.php | 7 ++-- libraries/dba/AbstractModelFactory.class.php | 41 +++++++++++--------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index f5dcb88412..199a0b4ce6 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -167,9 +167,8 @@ public function detail() { $this->view->assign('supportsShowResults', $sys->supportsFullResults()); $system = Factory::getSystemFactory()->get($experiment->getSystemId()); - // Shenanigans to normalize whitespaces and newlines - $systemHash = json_encode(json_decode($system->getLogalyzerPatterns()), true); - $systemHash = hash('sha1', $systemHash); + $systemHash = json_decode($system->getLogalyzerPatterns(), true); + $systemHash = $systemHash['hash']; $this->view->assign('systemHash', $systemHash); $usedOutdatedPattern = false; @@ -182,7 +181,7 @@ public function detail() { } else { $resultsAvailable = true; } - if($subJob->getLogalyzerHash() != $systemHash) { + if($subJob->getJobHash($subJob) != $systemHash) { $usedOutdatedPattern = true; } } diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index c65c824035..eaac1e94b9 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -793,25 +793,28 @@ public function IncrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, * @return array */ public function getJobCountPerLogLevel($job, $type) { - $json = json_decode($job->getLogalyzerResults(), true); - $resultArray = $json->results; - $accumulatedCounts = []; - foreach ($resultArray as $element) { - if($type === 'negative' && $element->type === 'negative') { - if(array_key_exists($element->logLevel, $accumulatedCounts)) { - $accumulatedCounts[$element->logLevel] += $element->count; - } - else { - $accumulatedCounts[$element->logLevel] = $element->count; - } - } - elseif ($type === 'positive' && $element->type === 'positive') { - if(!array_key_exists($element->logLevel, $accumulatedCounts)) { - $accumulatedCounts[$element->logLevel] = 1; - } - } - } - return $accumulatedCounts; + if($job->getLogalyzerResults() != null) { + $json = json_decode($job->getLogalyzerResults(), true); + $resultArray = $json->results; + $accumulatedCounts = []; + foreach ($resultArray as $element) { + if ($type === 'negative' && $element->type === 'negative') { + if (array_key_exists($element->logLevel, $accumulatedCounts)) { + $accumulatedCounts[$element->logLevel] += $element->count; + } else { + $accumulatedCounts[$element->logLevel] = $element->count; + } + } elseif ($type === 'positive' && $element->type === 'positive') { + if (!array_key_exists($element->logLevel, $accumulatedCounts)) { + $accumulatedCounts[$element->logLevel] = 1; + } + } + } + return $accumulatedCounts; + } + else { + return null; + } } public function getJobHash($job) { $json = json_decode($job->getLogalyzerResults(), true); From 11fc3f06239cd5513cb494b84285a28dafc0ccf1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:58:22 +0200 Subject: [PATCH 410/644] Front-End for System --- controllers/evaluation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 199a0b4ce6..a9ea871a23 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -181,7 +181,7 @@ public function detail() { } else { $resultsAvailable = true; } - if($subJob->getJobHash($subJob) != $systemHash) { + if(Factory::getJobFactory()->getJobHash($subJob) != $systemHash) { $usedOutdatedPattern = true; } } From b38c6f2bd8279f3ea68678458a522cb3638f55cf Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 16:59:43 +0200 Subject: [PATCH 411/644] Front-End for System --- libraries/dba/AbstractModelFactory.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index eaac1e94b9..7a1cfaeeff 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -817,8 +817,14 @@ public function getJobCountPerLogLevel($job, $type) { } } public function getJobHash($job) { - $json = json_decode($job->getLogalyzerResults(), true); - return $json->hash; + $json = $job->getLogalyzerResults(); + if ($json != null) { + $json = json_decode($job->getLogalyzerResults(), true); + return $json->hash; + } + else { + return ""; + } } public function setJobHash($job, $hash) { $json = json_decode($job->getLogalyzerResults(), true); From 2bacbef74d8d6c4d472042b7ab837ee171414cff Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:11:33 +0200 Subject: [PATCH 412/644] Front-End for System --- libraries/dba/AbstractModelFactory.class.php | 26 ++++++++++++++++---- views/evaluation/detail.php | 7 +++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 7a1cfaeeff..ee5276ef28 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -826,11 +826,27 @@ public function getJobHash($job) { return ""; } } - public function setJobHash($job, $hash) { - $json = json_decode($job->getLogalyzerResults(), true); - $json->hash = $hash; - $job->setLogalyzerResults(json_encode($json)); - Factory::getJobFactory()->update($job); + public function setJobHash($job, $hash) { // potentially useless + $json = $job->getLogalyzerResults(); + if ($json != null) { + $json = json_decode($json, true); + $json['hash'] = $hash; + $job->setLogalyzerResults(json_encode($json)); + Factory::getJobFactory()->update($job); + } + } + public function checkAllPositiveJobPatterns($job) { + $json = $job->getLogalyzerResults(); + if ($json != null) { + $data = json_decode($job->getLogalyzerResults(), true); + foreach ($data['pattern'] as $element) { + if($element->type === 'positive' && $element->count <= 0) { + return false; + } + } + return true; + } + return true; } } diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index c92b3742be..32043626af 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -26,6 +26,7 @@ */ use DBA\Job; +use DBA\Factory; $this->includeInlineJS(" function validateForm() { @@ -237,8 +238,8 @@ function getLogalyzerResponses(evalId) { - getStatus() == Define::JOB_STATUS_FINISHED) { ?> - + getStatus() == Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { ?> + @@ -260,7 +261,7 @@ function getLogalyzerResponses(evalId) { - getLogalyzerHash() != $data['systemHash']) { ?> + getJobHash($job) != $data['systemHash']) { ?>
From 454c4077714ec049775a8c7f15312f92ae438196 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:17:37 +0200 Subject: [PATCH 413/644] Front-End for System --- libraries/dba/AbstractModelFactory.class.php | 9 --------- libraries/logalyzer.php | 4 +--- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index ee5276ef28..007acf8485 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -826,15 +826,6 @@ public function getJobHash($job) { return ""; } } - public function setJobHash($job, $hash) { // potentially useless - $json = $job->getLogalyzerResults(); - if ($json != null) { - $json = json_decode($json, true); - $json['hash'] = $hash; - $job->setLogalyzerResults(json_encode($json)); - Factory::getJobFactory()->update($job); - } - } public function checkAllPositiveJobPatterns($job) { $json = $job->getLogalyzerResults(); if ($json != null) { diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b9259bfc12..3357691faf 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -73,16 +73,14 @@ public function examineEntireLog() { } else { $this->log = $log; } - $this->results = $this->job->getLogalyzerResults(); $this->createEmptyJobLogalyzerResults(); - $hash = $this->calculateHash(); foreach($this->data['pattern'] as $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); $found = false; foreach($this->results['pattern'] as $result) { - if($pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { + if(isset($result) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $result['count'] += $number; $found = true; } From 716d3e38a1eea8235400119de8bee785a1af4da7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:20:10 +0200 Subject: [PATCH 414/644] Front-End for System --- controllers/job.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 18a1c7be9e..5e09926aab 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -160,10 +160,15 @@ public function detail() { $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); $hash = $logalyzer->calculateHash(); - $results = json_decode($job->getLogalyzerResults(), true); - if($results['hash'] != $hash) { - $this->view->assign('usedOutdatedPattern', true); + $json = $job->getLogalyzerResults(); + if($json != null) { + $results = json_decode($json, true); + if($results['hash'] != $hash) { + $this->view->assign('usedOutdatedPattern', true); + } } + + $events = Util::eventFilter(['job' => $job]); $this->view->assign('events', $events); } else { From 3f78e5b714fa149429c4b77a305763837f84c28c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:26:36 +0200 Subject: [PATCH 415/644] Front-End for System --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 3357691faf..e640240ada 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -80,6 +80,7 @@ public function examineEntireLog() { $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); $found = false; foreach($this->results['pattern'] as $result) { + echo gettype($result); if(isset($result) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $result['count'] += $number; $found = true; From 077547e20f48ebc7a440807671bb8646d59e88a1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:29:40 +0200 Subject: [PATCH 416/644] Front-End for System --- libraries/logalyzer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e640240ada..6b60a28ecb 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -77,10 +77,12 @@ public function examineEntireLog() { $hash = $this->calculateHash(); foreach($this->data['pattern'] as $pattern) { + echo $pattern['pattern']; $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); $found = false; + echo 'Type of $this->results: ' . gettype($this->results); foreach($this->results['pattern'] as $result) { - echo gettype($result); + echo 'Type of $result: ' . gettype($result); if(isset($result) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $result['count'] += $number; $found = true; From 633bdb05ee781385f851625a35ea08fe25418ea2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:37:23 +0200 Subject: [PATCH 417/644] Front-End for System --- libraries/logalyzer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 6b60a28ecb..9f93b8666a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -77,13 +77,13 @@ public function examineEntireLog() { $hash = $this->calculateHash(); foreach($this->data['pattern'] as $pattern) { - echo $pattern['pattern']; + echo $pattern['pattern'] . "\n"; $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); $found = false; - echo 'Type of $this->results: ' . gettype($this->results); + echo 'Type of $this->results: ' . gettype($this->results) . "\n"; foreach($this->results['pattern'] as $result) { - echo 'Type of $result: ' . gettype($result); - if(isset($result) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { + echo 'Type of $result: ' . gettype($result) . "\n"; + if(isset($result['logLevel'],$result['pattern'],$result['regex'],$result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $result['count'] += $number; $found = true; } From ba0c3c868cfa1dc6c1e508753b5525bd4fa92f67 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:39:06 +0200 Subject: [PATCH 418/644] Front-End for System --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 007acf8485..45f61aafee 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -820,7 +820,7 @@ public function getJobHash($job) { $json = $job->getLogalyzerResults(); if ($json != null) { $json = json_decode($job->getLogalyzerResults(), true); - return $json->hash; + return $json['hash']; } else { return ""; From 5d48818e534b5ccfce9496d5ef74bb1283585d22 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:41:45 +0200 Subject: [PATCH 419/644] Front-End for System --- libraries/logalyzer.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 9f93b8666a..e245c7af0a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -77,12 +77,11 @@ public function examineEntireLog() { $hash = $this->calculateHash(); foreach($this->data['pattern'] as $pattern) { - echo $pattern['pattern'] . "\n"; + print_r($pattern['pattern']); $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); $found = false; - echo 'Type of $this->results: ' . gettype($this->results) . "\n"; foreach($this->results['pattern'] as $result) { - echo 'Type of $result: ' . gettype($result) . "\n"; + print_r($result); if(isset($result['logLevel'],$result['pattern'],$result['regex'],$result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $result['count'] += $number; $found = true; @@ -90,7 +89,9 @@ public function examineEntireLog() { } if(!$found) { $pattern['count'] = $number; - $this->results['pattern'] = $pattern; + echo "\nset result\n"; + print_r($pattern); + $this->results['pattern'][] = $pattern; } } $this->results['hash'] = $hash; From 661cf2f85bb47056b185827ba48b7427ac229469 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:56:33 +0200 Subject: [PATCH 420/644] Front-End for System --- controllers/job.php | 14 +++++++------- libraries/dba/AbstractModelFactory.class.php | 18 +++++------------- libraries/logalyzer.php | 1 - 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 5e09926aab..f7908f4f7b 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -147,13 +147,13 @@ public function detail() { $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); } - //$warnings = $job->getLogalyzerWarningCount(); - //$errors = $job->getLogalyzerErrorCount(); - $this->view->assign('logWarningCount', -1); - $this->view->assign('logErrorCount', -1); - //if($job->getStatus()==Define::JOB_STATUS_FINISHED && $job->getLogalyzerContainsMandatoryPattern()==0) { - // $this->view->assign('logContainsMandatory', 0); - //} TODO + + + $this->view->assign('logWarningCount', Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative')); + $this->view->assign('logErrorCount', Factory::getJobFactory()->getJobCountForLogLevel($job, 'error', 'negative')); + if($job->getStatus()==Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { + $this->view->assign('logContainsMandatory', 0); + } $system = Factory::getSystemFactory()->get($job->getSystemId()); // Shenanigans to normalize whitespaces and newlines diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 45f61aafee..b11b68ee8f 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -792,25 +792,17 @@ public function IncrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, * @param $type * @return array */ - public function getJobCountPerLogLevel($job, $type) { + public function getJobCountForLogLevel($job, $logLevel, $type) { if($job->getLogalyzerResults() != null) { $json = json_decode($job->getLogalyzerResults(), true); $resultArray = $json->results; - $accumulatedCounts = []; + $count = 0; foreach ($resultArray as $element) { - if ($type === 'negative' && $element->type === 'negative') { - if (array_key_exists($element->logLevel, $accumulatedCounts)) { - $accumulatedCounts[$element->logLevel] += $element->count; - } else { - $accumulatedCounts[$element->logLevel] = $element->count; - } - } elseif ($type === 'positive' && $element->type === 'positive') { - if (!array_key_exists($element->logLevel, $accumulatedCounts)) { - $accumulatedCounts[$element->logLevel] = 1; - } + if ($type === 'negative' && $element['type'] === 'negative' && $element['logLevel'] === $logLevel) { + $count += $element['count']; } } - return $accumulatedCounts; + return $count; } else { return null; diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e245c7af0a..3d289e5537 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -77,7 +77,6 @@ public function examineEntireLog() { $hash = $this->calculateHash(); foreach($this->data['pattern'] as $pattern) { - print_r($pattern['pattern']); $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); $found = false; foreach($this->results['pattern'] as $result) { From 887af6e532b2185690216fd669ac19b4ebdc468d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:57:02 +0200 Subject: [PATCH 421/644] Front-End for System --- libraries/logalyzer.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 3d289e5537..baeb36e65d 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -80,7 +80,7 @@ public function examineEntireLog() { $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); $found = false; foreach($this->results['pattern'] as $result) { - print_r($result); + //print_r($result); if(isset($result['logLevel'],$result['pattern'],$result['regex'],$result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $result['count'] += $number; $found = true; @@ -88,8 +88,7 @@ public function examineEntireLog() { } if(!$found) { $pattern['count'] = $number; - echo "\nset result\n"; - print_r($pattern); + //print_r($pattern); $this->results['pattern'][] = $pattern; } } From 0ffa2c2ab32e90dded5637703cd1020223f5e218 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 17:58:56 +0200 Subject: [PATCH 422/644] Front-End for System --- libraries/dba/AbstractModelFactory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index b11b68ee8f..5b5fcfb11d 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -795,7 +795,7 @@ public function IncrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, public function getJobCountForLogLevel($job, $logLevel, $type) { if($job->getLogalyzerResults() != null) { $json = json_decode($job->getLogalyzerResults(), true); - $resultArray = $json->results; + $resultArray = $json['results']; $count = 0; foreach ($resultArray as $element) { if ($type === 'negative' && $element['type'] === 'negative' && $element['logLevel'] === $logLevel) { @@ -823,7 +823,7 @@ public function checkAllPositiveJobPatterns($job) { if ($json != null) { $data = json_decode($job->getLogalyzerResults(), true); foreach ($data['pattern'] as $element) { - if($element->type === 'positive' && $element->count <= 0) { + if($element['type'] === 'positive' && $element['count'] <= 0) { return false; } } From 28675e85f1044384b845396982127d2a638eb5f8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 18:01:32 +0200 Subject: [PATCH 423/644] Front-End for System --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 5b5fcfb11d..cf8667dc75 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -795,7 +795,7 @@ public function IncrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, public function getJobCountForLogLevel($job, $logLevel, $type) { if($job->getLogalyzerResults() != null) { $json = json_decode($job->getLogalyzerResults(), true); - $resultArray = $json['results']; + $resultArray = $json['pattern']; $count = 0; foreach ($resultArray as $element) { if ($type === 'negative' && $element['type'] === 'negative' && $element['logLevel'] === $logLevel) { From d042f5f83410b60dbe77e7be7ac72dc5a6801740 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 18:14:39 +0200 Subject: [PATCH 424/644] Front-End for System --- controllers/evaluation.php | 1 + libraries/dba/AbstractModelFactory.class.php | 3 ++- libraries/logalyzer.php | 3 +-- views/evaluation/detail.php | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index a9ea871a23..1532810bf0 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -169,6 +169,7 @@ public function detail() { $systemHash = json_decode($system->getLogalyzerPatterns(), true); $systemHash = $systemHash['hash']; + echo "systemHash: " . $systemHash; $this->view->assign('systemHash', $systemHash); $usedOutdatedPattern = false; diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index cf8667dc75..f4b5176c43 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -811,7 +811,8 @@ public function getJobCountForLogLevel($job, $logLevel, $type) { public function getJobHash($job) { $json = $job->getLogalyzerResults(); if ($json != null) { - $json = json_decode($job->getLogalyzerResults(), true); + $json = json_decode($json, true); + //echo "JobHash: " . $json['jobHash'] . " returned.\n"; return $json['hash']; } else { diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index baeb36e65d..7100b00174 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -119,7 +119,7 @@ private function createBasicPatterns() { /** * Returns the arrays containing pattern * $identifier can be 'all', or the desired logLevel such as 'warn' or 'error' - * @param string $identifier + * @param string $logLevel * @param string $type 'regex' or 'string' * @return array */ @@ -131,7 +131,6 @@ public function getPatterns(string $logLevel, string $type) { return $this->data['pattern']; } else { $temp = []; - print_r($this->data['pattern']); // TODO remove debug info foreach ($this->data['pattern'] as $pattern) { if ($pattern['logLevel'] == $logLevel && $pattern['type'] == $type) { $temp[] = $pattern; diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 32043626af..eb8ed5bd69 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -233,9 +233,9 @@ function getLogalyzerResponses(evalId) { getInternalId(); ?> getDescription(); ?> - + getJobCountForLogLevel($job, 'error', 'negative')>=1) { ?> - + getJobCountForLogLevel($job, 'warn', 'negative')>=1) { ?> getStatus() == Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { ?> @@ -261,7 +261,7 @@ function getLogalyzerResponses(evalId) { - getJobHash($job) != $data['systemHash']) { ?> + getJobHash($job) != $data['systemHash']) { echo Factory::getJobFactory()->getJobHash($job);?> From 9362132ceb775f123527830b64554fd8121de3d7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 18:19:54 +0200 Subject: [PATCH 425/644] Front-End for System --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index eb8ed5bd69..36465f7e8e 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -261,7 +261,7 @@ function getLogalyzerResponses(evalId) { - getJobHash($job) != $data['systemHash']) { echo Factory::getJobFactory()->getJobHash($job);?> + getJobHash($job) != $data['systemHash']) {?> From 2178f99a46a80e6455d70addf839aaca2f106110 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 18:20:13 +0200 Subject: [PATCH 426/644] Front-End for System --- controllers/evaluation.php | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 1532810bf0..a9ea871a23 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -169,7 +169,6 @@ public function detail() { $systemHash = json_decode($system->getLogalyzerPatterns(), true); $systemHash = $systemHash['hash']; - echo "systemHash: " . $systemHash; $this->view->assign('systemHash', $systemHash); $usedOutdatedPattern = false; From d556d352257e7bb651d51fb15eda797e16194a58 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 18:21:03 +0200 Subject: [PATCH 427/644] Front-End for System --- controllers/evaluation.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index a9ea871a23..3be99851c0 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -167,9 +167,8 @@ public function detail() { $this->view->assign('supportsShowResults', $sys->supportsFullResults()); $system = Factory::getSystemFactory()->get($experiment->getSystemId()); - $systemHash = json_decode($system->getLogalyzerPatterns(), true); - $systemHash = $systemHash['hash']; - $this->view->assign('systemHash', $systemHash); + $systemPattern = json_decode($system->getLogalyzerPatterns(), true); + $this->view->assign('systemHash', $systemPattern['hash']); $usedOutdatedPattern = false; // check if all jobs have finished @@ -181,7 +180,7 @@ public function detail() { } else { $resultsAvailable = true; } - if(Factory::getJobFactory()->getJobHash($subJob) != $systemHash) { + if(Factory::getJobFactory()->getJobHash($subJob) != $systemPattern) { $usedOutdatedPattern = true; } } From 511ea7acdf3acfeb30be38fa9eaf4aa5823da11a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 18:21:54 +0200 Subject: [PATCH 428/644] Front-End for System --- controllers/evaluation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 3be99851c0..4ef469747d 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -180,7 +180,7 @@ public function detail() { } else { $resultsAvailable = true; } - if(Factory::getJobFactory()->getJobHash($subJob) != $systemPattern) { + if(Factory::getJobFactory()->getJobHash($subJob) != $systemPattern['hash']) { $usedOutdatedPattern = true; } } From 51b0604f1d66aba465fad2dc5cc74e62a21a9273 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 18:24:36 +0200 Subject: [PATCH 429/644] Front-End for System --- views/admin/system.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 943388db83..efa61ff887 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -530,10 +530,11 @@
-

Mandatory Patterns

+

Positive Patterns

+ All positive patterns must be present in a log for it to be considered valid.
- +
From 8ea847401a23b526a55d2ac820accc01d3d94418 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 18:26:13 +0200 Subject: [PATCH 430/644] Front-End for System --- views/admin/system.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index efa61ff887..66b2bdc6de 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -459,8 +459,7 @@

Log Analysis

-

Regex Expression: Any expression consisting of more than just letters and numbers is treated as regex.

-

Patterns are case sensitive

+

All patterns are case-sensitive, unless it's a regex that considers case-insensitivity.

From 712b71661a2d888cecc4c4ce8a5ec94f34bd6877 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 18:28:07 +0200 Subject: [PATCH 431/644] Front-End for System --- views/admin/system.php | 63 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 66b2bdc6de..40e18ef262 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -525,39 +525,40 @@
-
+
+
+
-
- -

Positive Patterns

- All positive patterns must be present in a log for it to be considered valid. -
-
- - -
- - - Regex - -
- -
- - -
-
- - - - - - Delete - - -
+
+

Positive Patterns

+ All positive patterns must be present in a log for it to be considered valid. +
+
+ + +
+ + + Regex + +
+
+
+ + +
+
+ + + + + + Delete + +
- +
+
From b5a8e677a5394f7927908dc2958e94318811ad85 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 26 Jul 2024 19:48:40 +0200 Subject: [PATCH 432/644] LogLine debugging --- api/v1/job.php | 1 + 1 file changed, 1 insertion(+) diff --git a/api/v1/job.php b/api/v1/job.php index 1ffc817c85..991b3a1efc 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -300,5 +300,6 @@ private function appendLog($id) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); $logalyzer = new Logalyzer_Library($job); $logalyzer->examineLogLine($this->request['log']); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', "Logalyzer checked Logline\n", FILE_APPEND); } } From 6076b91a3607d6a0249cb7ce6227e1ecffd59b26 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 28 Jul 2024 13:56:16 +0200 Subject: [PATCH 433/644] LogLine debugging --- api/v1/job.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/v1/job.php b/api/v1/job.php index 991b3a1efc..cd222a32bd 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -297,9 +297,10 @@ private function appendLog($id) { if (!file_exists(UPLOADED_DATA_PATH . 'log')) { mkdir(UPLOADED_DATA_PATH . 'log'); } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', "Logalyzer checked Logline\n", FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); $logalyzer = new Logalyzer_Library($job); $logalyzer->examineLogLine($this->request['log']); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', "Logalyzer checked Logline\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', "Logalyzer checked Logline\n", FILE_APPEND); } } From d0ec8112030fe2b9a2129371a1f4c7bd0b640a24 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 28 Jul 2024 13:58:15 +0200 Subject: [PATCH 434/644] LogLine debugging --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 7100b00174..cdc16555bf 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -22,6 +22,8 @@ public function __construct($job = null) { if($this->job != null) { $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); $this->loadPatterns(); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "Logalyzer checked Logline\n", FILE_APPEND); + } } public function getJob() { From 64a3615eb2f5381b6ab1bfa4bdcdadf8da3e212c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 28 Jul 2024 13:59:02 +0200 Subject: [PATCH 435/644] LogLine debugging --- libraries/logalyzer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index cdc16555bf..a2b0cffec0 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -22,7 +22,6 @@ public function __construct($job = null) { if($this->job != null) { $this->system = Factory::getSystemFactory()->get($this->job->getSystemId()); $this->loadPatterns(); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "Logalyzer checked Logline\n", FILE_APPEND); } } From a58c823942227af3fdf0fd2dd71440df6f05f67a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 28 Jul 2024 14:00:11 +0200 Subject: [PATCH 436/644] LogLine debugging --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index a2b0cffec0..34cef5376d 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -106,6 +106,8 @@ public function examineEntireLog() { */ public function examineLogLine($logLine) { $hash = $this->calculateHash(); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Logalyzer checked Logline: ".$logLine.".\n", FILE_APPEND); + } /** From bb53e285e9a80bb84172e01435624cd349ddfb69 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 28 Jul 2024 15:03:49 +0200 Subject: [PATCH 437/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 36 ++++++++++++++++---- libraries/logalyzer.php | 31 +++++++++++++++++ 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index f4b5176c43..b204348955 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -775,16 +775,38 @@ public function getDB($test = false) { die("Fatal Error! Database connection failed. Message: " . $e->getMessage()); } } - public function IncrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $amount) { - $selectQuery = "SELECT JSON_EXTRACT(Job.logalyzerResults, $.results) WHERE $.results.logLevel= " . $logLevel . " AND $.results.pattern=". $pattern . " AND $.results.regex=". $regex . " AND $.results.type=" . $type; - $query = "UPDATE Job JSON_SET(" . $selectQuery . ", $.results.count, " . $amount. ") WHERE jobId=?"; - - $dbh = self::getDB(); - $stmt = $dbh->prepare($query); - $stmt->execute([$jobId]); + public function incrementJobCountAtomically($jobId, $pattern, $amount) { + $dbh = self::getDB(); + $dbh->beginTransaction(); + $incrementQuery = " + UPDATE Job + SET logalyzerResults = JSON_SET( + logalyzerResults, + CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern')), '].count'), + JSON_EXTRACT(logalyzerResults, CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern')), '].count')) + ? + ) + WHERE jobId = ? + AND JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern') IS NOT NULL; + "; + $stmt = $dbh->prepare($incrementQuery); + return $stmt->execute([$pattern, $pattern, $amount, $jobId, $pattern]); } + public function logalyzerAppendNewResult($jobId, $logLevel, $pattern, $regex, $type, $amount=0) { + $dbh = self::getDB(); + $dbh->beginTransaction(); + $lockQuery = "SELECT logalyzerResults FROM Job WHERE jobId = ? FOR UPDATE"; + $stmt = $dbh->prepare($lockQuery); + $stmt->execute([$jobId]); + + $query = "UPDATE Job SET logalyzerResults = JSON_ARRAY_APPEND(logalyzerResults, '$.results', JSON_OBJECT('logLevel', ".$logLevel.", 'pattern', '".$pattern."', 'regex', '".$regex."', 'type', '".$type."', 'count', ".$amount.")) WHERE jobId=?"; + $stmt2 = $dbh->prepare($query); + $result = $stmt2->execute([$jobId]); + $dbh->commit(); + return $result; + } + /** * Goes over all results and aggregates the counts for keywords of the same logLevel * Returns an array of type ['logLevel'=> int] ex. ['warn'=> 5] diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 34cef5376d..772b648be6 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -106,6 +106,37 @@ public function examineEntireLog() { */ public function examineLogLine($logLine) { $hash = $this->calculateHash(); + $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId() . '.log'; + // Load existing result set + $this->results = json_decode($this->job->getLogalyzerResults(), true); + + foreach($this->data['pattern'] as $pattern) { + $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); + foreach($this->results['pattern'] as $result) { + //print_r($result); + // Did we ever find this result before? + if(isset($result['logLevel'],$result['pattern'],$result['regex'],$result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { + $response = $this->job->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $number); + if($response === false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); + } + } + // First time seeing this result, create result then increment $number times (TODO atomically) + else { + $response1= $this->job->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], 0); + if($response1 === false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); + } + $response2 = $this->job->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $number); + if($response2 === false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); + } + } + } + } + // Manipulate hash and counts atomically using sql + + // TODO remove debug file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Logalyzer checked Logline: ".$logLine.".\n", FILE_APPEND); } From cb7aa505fbfcea058fd9295f3965fb638c7b0783 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sun, 28 Jul 2024 15:04:00 +0200 Subject: [PATCH 438/644] LogLine debugging --- libraries/logalyzer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 772b648be6..9b6382c8b8 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -121,7 +121,6 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } } - // First time seeing this result, create result then increment $number times (TODO atomically) else { $response1= $this->job->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], 0); if($response1 === false) { From 8873d6ea875865a843719f9aa85f621c537d0bbd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 12:34:40 +0200 Subject: [PATCH 439/644] LogLine debugging --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 71146bd690..0c580ebad1 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -249,12 +249,12 @@ function updateProgress() {

Outdated pattern used, use 'Recheck'

- = 0) { ?> + = 1) { ?>
×

Log contains Errors

- = 0) { ?> + = 1) { ?>
×

Log contains Warnings

From 535a8cfd326d8fb575c3578ce30542737b19c537 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 13:28:01 +0200 Subject: [PATCH 440/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 32 +++++++++++++++++--- libraries/logalyzer.php | 13 +++----- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index b204348955..6de79d64c3 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -775,7 +775,7 @@ public function getDB($test = false) { die("Fatal Error! Database connection failed. Message: " . $e->getMessage()); } } - public function incrementJobCountAtomically($jobId, $pattern, $amount) { + public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $hash, $amount) { $dbh = self::getDB(); $dbh->beginTransaction(); $incrementQuery = " @@ -789,9 +789,15 @@ public function incrementJobCountAtomically($jobId, $pattern, $amount) { AND JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern') IS NOT NULL; "; $stmt = $dbh->prepare($incrementQuery); - return $stmt->execute([$pattern, $pattern, $amount, $jobId, $pattern]); + $result = $stmt->execute([$pattern, $pattern, $amount, $jobId, $pattern]); + + $hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; + $stmt2 = $dbh->prepare($hashUpdate); + $stmt2->execute([$hash, $jobId]); + $dbh->commit(); + return $result; } - public function logalyzerAppendNewResult($jobId, $logLevel, $pattern, $regex, $type, $amount=0) { + public function logalyzerAppendNewResult($jobId, $logLevel, $pattern, $regex, $type, $hash, $amount=0) { $dbh = self::getDB(); $dbh->beginTransaction(); $lockQuery = "SELECT logalyzerResults FROM Job WHERE jobId = ? FOR UPDATE"; @@ -799,14 +805,30 @@ public function logalyzerAppendNewResult($jobId, $logLevel, $pattern, $regex, $t $stmt->execute([$jobId]); $query = "UPDATE Job SET logalyzerResults = JSON_ARRAY_APPEND(logalyzerResults, '$.results', JSON_OBJECT('logLevel', ".$logLevel.", 'pattern', '".$pattern."', 'regex', '".$regex."', 'type', '".$type."', 'count', ".$amount.")) WHERE jobId=?"; - - $stmt2 = $dbh->prepare($query); $result = $stmt2->execute([$jobId]); + + $hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; + $stmt3 = $dbh->prepare($hashUpdate); + $result = $stmt3->execute([$hash, $jobId]); $dbh->commit(); return $result; } + public function logalyzerUpdateHash($jobId, $hash) { + $dbh = self::getDB(); + $dbh->beginTransaction(); + $lockQuery = "SELECT logalyzerResults FROM Job WHERE jobId = ? FOR UPDATE"; + $stmt = $dbh->prepare($lockQuery); + $stmt->execute([$jobId]); + + $hashQuery = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; + + $stmt2 = $dbh->prepare($hashQuery); + $result = $stmt2->execute([$hash, $jobId]); + $dbh->commit(); + return $result; + } /** * Goes over all results and aggregates the counts for keywords of the same logLevel * Returns an array of type ['logLevel'=> int] ex. ['warn'=> 5] diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 9b6382c8b8..97e81d4faa 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -113,30 +113,27 @@ public function examineLogLine($logLine) { foreach($this->data['pattern'] as $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); foreach($this->results['pattern'] as $result) { - //print_r($result); - // Did we ever find this result before? + // Check if the result has been previously set in the job's result if(isset($result['logLevel'],$result['pattern'],$result['regex'],$result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { - $response = $this->job->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $number); + $response = $this->job->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); if($response === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } } else { - $response1= $this->job->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], 0); + $response1= $this->job->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); if($response1 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } - $response2 = $this->job->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $number); + $response2 = $this->job->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); if($response2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } } } } - // Manipulate hash and counts atomically using sql - // TODO remove debug - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Logalyzer checked Logline: ".$logLine.".\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Logalyzer checked Logline: ".$logLine.".\n", FILE_APPEND); } From 200ca8f7088c53cc260e7b6ed27f49ea670c1dbf Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 13:30:53 +0200 Subject: [PATCH 441/644] LogLine debugging --- api/v1/job.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index cd222a32bd..1ffc817c85 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -297,10 +297,8 @@ private function appendLog($id) { if (!file_exists(UPLOADED_DATA_PATH . 'log')) { mkdir(UPLOADED_DATA_PATH . 'log'); } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', "Logalyzer checked Logline\n", FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); $logalyzer = new Logalyzer_Library($job); $logalyzer->examineLogLine($this->request['log']); - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', "Logalyzer checked Logline\n", FILE_APPEND); } } From 48c21063c79e5cbb703b776e3341a60938e99de6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 13:31:08 +0200 Subject: [PATCH 442/644] LogLine debugging --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 97e81d4faa..d80124e1ae 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -133,7 +133,7 @@ public function examineLogLine($logLine) { } } - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Logalyzer checked Logline: ".$logLine.".\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Logalyzer checked Logline: ".$logLine.".\n", FILE_APPEND); } From 68f5b138af225e4a9d90b8a2e146f8b1ba7794eb Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 13:34:16 +0200 Subject: [PATCH 443/644] LogLine debugging --- libraries/logalyzer.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index d80124e1ae..93f251edcf 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -105,6 +105,9 @@ public function examineEntireLog() { * @return void */ public function examineLogLine($logLine) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Start of logalyzer checkLogline()\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', $logLine, FILE_APPEND); + $hash = $this->calculateHash(); $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId() . '.log'; // Load existing result set @@ -133,7 +136,7 @@ public function examineLogLine($logLine) { } } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Logalyzer checked Logline: ".$logLine.".\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "End of logalyzer checkLogline()\n", FILE_APPEND); } From d752f8d560df793a7d7b8dcbb828b9c36cf0847e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 13:38:29 +0200 Subject: [PATCH 444/644] LogLine debugging --- libraries/logalyzer.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 93f251edcf..e471973667 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -105,7 +105,8 @@ public function examineEntireLog() { * @return void */ public function examineLogLine($logLine) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Start of logalyzer checkLogline()\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\n--------------------------------\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nStart of logalyzer checkLogline()\n", FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', $logLine, FILE_APPEND); $hash = $this->calculateHash(); @@ -118,12 +119,14 @@ public function examineLogLine($logLine) { foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result if(isset($result['logLevel'],$result['pattern'],$result['regex'],$result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\n Found result in result set, trying to increment..\n", FILE_APPEND); $response = $this->job->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); if($response === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } } else { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..\n", FILE_APPEND); $response1= $this->job->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); if($response1 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); @@ -136,7 +139,7 @@ public function examineLogLine($logLine) { } } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "End of logalyzer checkLogline()\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nEnd of logalyzer checkLogline()\n", FILE_APPEND); } From 16b4cff75306815c5d33d9048c42f9c5ec8c6708 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 13:41:19 +0200 Subject: [PATCH 445/644] LogLine debugging --- libraries/logalyzer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e471973667..c143920514 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -120,18 +120,18 @@ public function examineLogLine($logLine) { // Check if the result has been previously set in the job's result if(isset($result['logLevel'],$result['pattern'],$result['regex'],$result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\n Found result in result set, trying to increment..\n", FILE_APPEND); - $response = $this->job->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); + $response = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); if($response === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } } else { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..\n", FILE_APPEND); - $response1= $this->job->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); + $response1= Factory::getJobFactory()->logalyzerAppendNewResult($pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); if($response1 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } - $response2 = $this->job->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); + $response2 = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); if($response2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } From 582636f72fc9fa576597ec1cb84940dca54705d7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 13:59:55 +0200 Subject: [PATCH 446/644] LogLine debugging --- libraries/logalyzer.php | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c143920514..10557c1642 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -106,7 +106,7 @@ public function examineEntireLog() { */ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\n--------------------------------\n", FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nStart of logalyzer checkLogline()\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Start of logalyzer checkLogline()\n", FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', $logLine, FILE_APPEND); $hash = $this->calculateHash(); @@ -116,27 +116,30 @@ public function examineLogLine($logLine) { foreach($this->data['pattern'] as $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); + $isInResultSet = false; foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result - if(isset($result['logLevel'],$result['pattern'],$result['regex'],$result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\n Found result in result set, trying to increment..\n", FILE_APPEND); + if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { + $isInResultSet = true; + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n Found result in result set, trying to increment..\n", FILE_APPEND); $response = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); - if($response === false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); + if ($response === false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } } - else { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..\n", FILE_APPEND); - $response1= Factory::getJobFactory()->logalyzerAppendNewResult($pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); - if($response1 === false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); - } - $response2 = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); - if($response2 === false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); - } + } + if(!$isInResultSet) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..\n", FILE_APPEND); + $response1= Factory::getJobFactory()->logalyzerAppendNewResult($pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); + if($response1 === false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); + } + $response2 = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); + if($response2 === false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } } + } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nEnd of logalyzer checkLogline()\n", FILE_APPEND); From 66afd004c39688480a2683358092157bbd81d533 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 14:04:47 +0200 Subject: [PATCH 447/644] LogLine debugging --- libraries/logalyzer.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 10557c1642..4ca1083457 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -130,7 +130,7 @@ public function examineLogLine($logLine) { } if(!$isInResultSet) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..\n", FILE_APPEND); - $response1= Factory::getJobFactory()->logalyzerAppendNewResult($pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); + $response1= Factory::getJobFactory()->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); if($response1 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } @@ -138,12 +138,11 @@ public function examineLogLine($logLine) { if($response2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nPassed appending.\n", FILE_APPEND); } } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nEnd of logalyzer checkLogline()\n", FILE_APPEND); - } /** From 92a6b0a2c92b8c91313e4d0979ebe99e7258f8c7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 14:11:42 +0200 Subject: [PATCH 448/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- libraries/logalyzer.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 6de79d64c3..597721df7b 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -800,7 +800,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, public function logalyzerAppendNewResult($jobId, $logLevel, $pattern, $regex, $type, $hash, $amount=0) { $dbh = self::getDB(); $dbh->beginTransaction(); - $lockQuery = "SELECT logalyzerResults FROM Job WHERE jobId = ? FOR UPDATE"; + $lockQuery = "SELECT logalyzerResults FROM Job WHERE jobId=? FOR UPDATE"; $stmt = $dbh->prepare($lockQuery); $stmt->execute([$jobId]); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4ca1083457..d6efdd40cd 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -130,14 +130,19 @@ public function examineLogLine($logLine) { } if(!$isInResultSet) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..\n", FILE_APPEND); - $response1= Factory::getJobFactory()->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); - if($response1 === false) { + $pattern['count'] = $number; + $this->results['pattern'][] = $pattern; + $this->results['hash'] = $hash; + $this->job->setLogalyzerResults(json_encode($this->results)); + Factory::getJobFactory()->update($this->job); + //$response1= Factory::getJobFactory()->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); + /*if($response1 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } $response2 = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); if($response2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); - } + }*/ file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nPassed appending.\n", FILE_APPEND); } From 076d6b4a2fd3a6bc21d063434d76f52385271c76 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 14:14:22 +0200 Subject: [PATCH 449/644] LogLine debugging --- libraries/logalyzer.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index d6efdd40cd..d31ee6aeaa 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -120,7 +120,7 @@ public function examineLogLine($logLine) { foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { - $isInResultSet = true; + $isInResultSet = $result['pattern']; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n Found result in result set, trying to increment..\n", FILE_APPEND); $response = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); if ($response === false) { @@ -129,7 +129,7 @@ public function examineLogLine($logLine) { } } if(!$isInResultSet) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set.." . $isInResultSet. "\n", FILE_APPEND); $pattern['count'] = $number; $this->results['pattern'][] = $pattern; $this->results['hash'] = $hash; @@ -143,7 +143,6 @@ public function examineLogLine($logLine) { if($response2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); }*/ - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nPassed appending.\n", FILE_APPEND); } } From a217de6f8656a99d9c747a3f1d45b2e06cb4edce Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 14:16:20 +0200 Subject: [PATCH 450/644] LogLine debugging --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index d31ee6aeaa..de009fb369 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -129,7 +129,8 @@ public function examineLogLine($logLine) { } } if(!$isInResultSet) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set.." . $isInResultSet. "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', $isInResultSet, FILE_APPEND); $pattern['count'] = $number; $this->results['pattern'][] = $pattern; $this->results['hash'] = $hash; From 530ffd43600b039b33313a9ef5757de451218d7f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 14:21:35 +0200 Subject: [PATCH 451/644] LogLine debugging --- libraries/logalyzer.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index de009fb369..60f04af516 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -121,10 +121,15 @@ public function examineLogLine($logLine) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $isInResultSet = $result['pattern']; - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n Found result in result set, trying to increment..\n", FILE_APPEND); - $response = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); - if ($response === false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); + if ($number >= 1) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n Found result in result set, trying to increment..\n", FILE_APPEND); + print_r($this->results); + $response = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); + if ($response === false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); + } + $resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); + print_r($resultsAfterUpdate); } } } From 27066e78f5dd60213723af428e9cb932e8888a3e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 14:23:47 +0200 Subject: [PATCH 452/644] LogLine debugging --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 60f04af516..e34a7f233d 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -123,13 +123,13 @@ public function examineLogLine($logLine) { $isInResultSet = $result['pattern']; if ($number >= 1) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n Found result in result set, trying to increment..\n", FILE_APPEND); - print_r($this->results); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); $response = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); if ($response === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); } $resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); - print_r($resultsAfterUpdate); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultsAfterUpdate, true), FILE_APPEND); } } } From c04599fc3f664f6a8fb53190dec91f341d691545 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 14:26:11 +0200 Subject: [PATCH 453/644] LogLine debugging --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e34a7f233d..c5032c7f92 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -122,7 +122,8 @@ public function examineLogLine($logLine) { if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $isInResultSet = $result['pattern']; if ($number >= 1) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n Found result in result set, trying to increment..\n", FILE_APPEND); + $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number; + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); $response = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); if ($response === false) { From 57a1bd2010f3cbf44acfb20cf31d4dfd0e456a8f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 14:28:51 +0200 Subject: [PATCH 454/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 6 +++--- libraries/logalyzer.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 597721df7b..ff79587a7e 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -791,9 +791,9 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt = $dbh->prepare($incrementQuery); $result = $stmt->execute([$pattern, $pattern, $amount, $jobId, $pattern]); - $hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; - $stmt2 = $dbh->prepare($hashUpdate); - $stmt2->execute([$hash, $jobId]); + //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; + //$stmt2 = $dbh->prepare($hashUpdate); + //$stmt2->execute([$hash, $jobId]); $dbh->commit(); return $result; } diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c5032c7f92..4bb3083c11 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -122,7 +122,7 @@ public function examineLogLine($logLine) { if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $isInResultSet = $result['pattern']; if ($number >= 1) { - $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number; + $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); $response = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); From 3fddef9545be50a6f69d02de29129cd058d361c5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 14:43:07 +0200 Subject: [PATCH 455/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 54 ++++++++++++-------- libraries/logalyzer.php | 5 +- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index ff79587a7e..bd4140178a 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -775,27 +775,39 @@ public function getDB($test = false) { die("Fatal Error! Database connection failed. Message: " . $e->getMessage()); } } - public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $hash, $amount) { - $dbh = self::getDB(); - $dbh->beginTransaction(); - $incrementQuery = " - UPDATE Job - SET logalyzerResults = JSON_SET( - logalyzerResults, - CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern')), '].count'), - JSON_EXTRACT(logalyzerResults, CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern')), '].count')) + ? - ) - WHERE jobId = ? - AND JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern') IS NOT NULL; - "; - $stmt = $dbh->prepare($incrementQuery); - $result = $stmt->execute([$pattern, $pattern, $amount, $jobId, $pattern]); - - //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; - //$stmt2 = $dbh->prepare($hashUpdate); - //$stmt2->execute([$hash, $jobId]); - $dbh->commit(); - return $result; + public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $hash, $amount) + { + $dbh = self::getDB(); + $dbh->beginTransaction(); + try { + $incrementQuery = " + UPDATE Job + SET logalyzerResults = JSON_SET( + logalyzerResults, + CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern')), '].count'), + JSON_EXTRACT(logalyzerResults, CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern')), '].count')) + ? + ) + WHERE jobId = ? + AND JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern') IS NOT NULL; + "; + $stmt = $dbh->prepare($incrementQuery); + if ($stmt === false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); + } + if (!$stmt->execute([$pattern, $pattern, $amount, $jobId, $pattern])) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); + } + //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; + //$stmt2 = $dbh->prepare($hashUpdate); + //$stmt2->execute([$hash, $jobId]); + $dbh->commit(); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $stmt->affected_rows, FILE_APPEND); + $stmt->close(); + } + catch (PDOException $e) { + $dbh->rollback(); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $e->getMessage(), FILE_APPEND); + } } public function logalyzerAppendNewResult($jobId, $logLevel, $pattern, $regex, $type, $hash, $amount=0) { $dbh = self::getDB(); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4bb3083c11..7dad5fd68c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -125,10 +125,7 @@ public function examineLogLine($logLine) { $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); - $response = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); - if ($response === false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); - } + Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); $resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultsAfterUpdate, true), FILE_APPEND); } From fe6fc0d74d1243a5598d85b7ea12570934b5ffd5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 14:57:12 +0200 Subject: [PATCH 456/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index bd4140178a..881ff3eb48 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -784,26 +784,29 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, - CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern')), '].count'), - JSON_EXTRACT(logalyzerResults, CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern')), '].count')) + ? + CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', :pattern, NULL, '$.results[*].pattern')), '].count'), + JSON_EXTRACT(logalyzerResults, CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', :pattern, NULL, '$.results[*].pattern')), '].count')) + :amount ) - WHERE jobId = ? - AND JSON_SEARCH(logalyzerResults, 'one', ?, NULL, '$.results[*].pattern') IS NOT NULL; + WHERE jobId = :jobId + AND JSON_SEARCH(logalyzerResults, 'one', :pattern, NULL, '$.results[*].pattern') IS NOT NULL; "; $stmt = $dbh->prepare($incrementQuery); if ($stmt === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); } - if (!$stmt->execute([$pattern, $pattern, $amount, $jobId, $pattern])) { + $stmt->bindParam(':pattern', $pattern, PDO::PARAM_STR); + $stmt->bindParam(':amount', $amount, PDO::PARAM_INT); + $stmt->bindParam(':jobId', $jobId, PDO::PARAM_INT); + if (!$stmt->execute()) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); } //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; //$stmt2 = $dbh->prepare($hashUpdate); //$stmt2->execute([$hash, $jobId]); $dbh->commit(); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $stmt->affected_rows, FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $stmt->rowCount(), FILE_APPEND); $stmt->close(); - } + } catch (PDOException $e) { $dbh->rollback(); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $e->getMessage(), FILE_APPEND); From 866bcdde1df1652c350da8234c468ab73728d974 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 15:02:02 +0200 Subject: [PATCH 457/644] LogLine debugging --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 7dad5fd68c..64f4da0fe0 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -126,8 +126,8 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); - $resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultsAfterUpdate, true), FILE_APPEND); + //$resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultsAfterUpdate, true), FILE_APPEND); } } } From 80ca6ae4a83de67f450ec5915385e406be610c26 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 15:03:18 +0200 Subject: [PATCH 458/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- libraries/logalyzer.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 881ff3eb48..00fc21d249 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -804,7 +804,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, //$stmt2 = $dbh->prepare($hashUpdate); //$stmt2->execute([$hash, $jobId]); $dbh->commit(); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $stmt->rowCount(), FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $stmt->rowCount(), FILE_APPEND); $stmt->close(); } catch (PDOException $e) { diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 64f4da0fe0..33ebf2212e 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -123,8 +123,8 @@ public function examineLogLine($logLine) { $isInResultSet = $result['pattern']; if ($number >= 1) { $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); //$resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultsAfterUpdate, true), FILE_APPEND); From e3add0302cc189031c0891c8d9c5036210e8451c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 15:05:05 +0200 Subject: [PATCH 459/644] LogLine debugging --- libraries/logalyzer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 33ebf2212e..4f45d250d3 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -107,7 +107,6 @@ public function examineEntireLog() { public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\n--------------------------------\n", FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Start of logalyzer checkLogline()\n", FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', $logLine, FILE_APPEND); $hash = $this->calculateHash(); $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId() . '.log'; @@ -120,7 +119,7 @@ public function examineLogLine($logLine) { foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { - $isInResultSet = $result['pattern']; + $isInResultSet = true; if ($number >= 1) { $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); From 9f71ab05b8f891f5123ec8c4498f42c72e0f84f6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 15:09:10 +0200 Subject: [PATCH 460/644] LogLine debugging --- libraries/logalyzer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4f45d250d3..8fb8da7b1f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -109,11 +109,11 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Start of logalyzer checkLogline()\n", FILE_APPEND); $hash = $this->calculateHash(); - $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId() . '.log'; // Load existing result set $this->results = json_decode($this->job->getLogalyzerResults(), true); foreach($this->data['pattern'] as $pattern) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Checking pattern: " . $pattern['pattern'] . "\n", FILE_APPEND); $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; foreach($this->results['pattern'] as $result) { @@ -132,7 +132,6 @@ public function examineLogLine($logLine) { } if(!$isInResultSet) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..", FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', $isInResultSet, FILE_APPEND); $pattern['count'] = $number; $this->results['pattern'][] = $pattern; $this->results['hash'] = $hash; From 333bb96ac9d81a2636b4e430fa543d58b14ac0dd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 15:12:02 +0200 Subject: [PATCH 461/644] LogLine debugging --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 8fb8da7b1f..96b5c0b35f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -122,7 +122,7 @@ public function examineLogLine($logLine) { $isInResultSet = true; if ($number >= 1) { $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); //$resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); From 64f51846f3fb36739543776dd05d509187d5d1ac Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 15:13:00 +0200 Subject: [PATCH 462/644] LogLine debugging --- libraries/logalyzer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 96b5c0b35f..ff08016e65 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -125,8 +125,9 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); - //$resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultsAfterUpdate, true), FILE_APPEND); + sleep(2); + $resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultsAfterUpdate, true), FILE_APPEND); } } } From c81944d86f30efe882255e8b54a510d89426957f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 20:25:07 +0200 Subject: [PATCH 463/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 42 ++++++++++---------- libraries/logalyzer.php | 4 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 00fc21d249..9ffdb95fe9 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -775,37 +775,37 @@ public function getDB($test = false) { die("Fatal Error! Database connection failed. Message: " . $e->getMessage()); } } - public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $hash, $amount) + public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $hash, $index, $amount) { $dbh = self::getDB(); $dbh->beginTransaction(); try { - $incrementQuery = " - UPDATE Job - SET logalyzerResults = JSON_SET( - logalyzerResults, - CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', :pattern, NULL, '$.results[*].pattern')), '].count'), - JSON_EXTRACT(logalyzerResults, CONCAT('$.results[', JSON_UNQUOTE(JSON_SEARCH(logalyzerResults, 'one', :pattern, NULL, '$.results[*].pattern')), '].count')) + :amount - ) - WHERE jobId = :jobId - AND JSON_SEARCH(logalyzerResults, 'one', :pattern, NULL, '$.results[*].pattern') IS NOT NULL; - "; - $stmt = $dbh->prepare($incrementQuery); - if ($stmt === false) { + $stmt1 = $dbh->prepare("SET @concat = CONCAT('$.results[',".$index.",'].count')"); + $stmt1->execute(); + + $incrementQuery = "UPDATE Job + SET logalyzerResults = JSON_SET( + logalyzerResults, + @concat, + CAST(CAST(JSON_UNQUOTE( + JSON_EXTRACT(logalyzerResults, @concat) + ) AS UNSIGNED) + :amount AS CHAR)) + WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; + $stmt2 = $dbh->prepare($incrementQuery); + if ($stmt2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); } - $stmt->bindParam(':pattern', $pattern, PDO::PARAM_STR); - $stmt->bindParam(':amount', $amount, PDO::PARAM_INT); - $stmt->bindParam(':jobId', $jobId, PDO::PARAM_INT); - if (!$stmt->execute()) { + $stmt2->bindParam(':pattern', $pattern, PDO::PARAM_STR); + $stmt2->bindParam(':amount', $amount, PDO::PARAM_INT); + $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); + if (!$stmt2->execute()) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); } //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; - //$stmt2 = $dbh->prepare($hashUpdate); - //$stmt2->execute([$hash, $jobId]); + //$stmt3 = $dbh->prepare($hashUpdate); + //$stmt3->execute([$hash, $jobId]); $dbh->commit(); - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $stmt->rowCount(), FILE_APPEND); - $stmt->close(); + $stmt2->close(); } catch (PDOException $e) { $dbh->rollback(); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index ff08016e65..49c19c8527 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -112,7 +112,7 @@ public function examineLogLine($logLine) { // Load existing result set $this->results = json_decode($this->job->getLogalyzerResults(), true); - foreach($this->data['pattern'] as $pattern) { + foreach($this->data['pattern'] as $index => $pattern) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Checking pattern: " . $pattern['pattern'] . "\n", FILE_APPEND); $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; @@ -124,7 +124,7 @@ public function examineLogLine($logLine) { $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); - Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); + Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $index, $number); sleep(2); $resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultsAfterUpdate, true), FILE_APPEND); From 850b038be0453872fc9870d85cedbed62f65a5b7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 20:30:41 +0200 Subject: [PATCH 464/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 9ffdb95fe9..9b4dd1e6f3 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -789,18 +789,18 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, @concat, CAST(CAST(JSON_UNQUOTE( JSON_EXTRACT(logalyzerResults, @concat) - ) AS UNSIGNED) + :amount AS CHAR)) - WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; + ) AS UNSIGNED) + 7 AS CHAR)) + WHERE jobId = 29633 AND JSON_SEARCH(logalyzerResults, 'one', 'Error') is not null;"; $stmt2 = $dbh->prepare($incrementQuery); if ($stmt2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); } - $stmt2->bindParam(':pattern', $pattern, PDO::PARAM_STR); - $stmt2->bindParam(':amount', $amount, PDO::PARAM_INT); - $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); - if (!$stmt2->execute()) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); - } + //$stmt2->bindParam(':pattern', $pattern, PDO::PARAM_STR); + //$stmt2->bindParam(':amount', $amount, PDO::PARAM_INT); + //$stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); + //if (!$stmt2->execute()) { + // file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); + //} //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; //$stmt3 = $dbh->prepare($hashUpdate); //$stmt3->execute([$hash, $jobId]); From 2dace2cf6526db6805a5345d200c9f0e1199b78b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 20:33:13 +0200 Subject: [PATCH 465/644] LogLine debugging --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 49c19c8527..e3125be85f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -121,7 +121,7 @@ public function examineLogLine($logLine) { if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $isInResultSet = true; if ($number >= 1) { - $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; + $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . " at index ".$index."\n"; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $index, $number); From 12574d0b29183933c545207a3458717728affcdb Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 20:34:31 +0200 Subject: [PATCH 466/644] LogLine debugging --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e3125be85f..acd1f54fb2 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -113,7 +113,7 @@ public function examineLogLine($logLine) { $this->results = json_decode($this->job->getLogalyzerResults(), true); foreach($this->data['pattern'] as $index => $pattern) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Checking pattern: " . $pattern['pattern'] . "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Checking pattern: " . $pattern['pattern'] . " at index: ".$index."\n", FILE_APPEND); $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; foreach($this->results['pattern'] as $result) { From 99f6b8e0f846b0311a0187d32445f5acb763bdf8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 20:36:09 +0200 Subject: [PATCH 467/644] LogLine debugging --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index acd1f54fb2..aa5f53f1de 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -113,6 +113,7 @@ public function examineLogLine($logLine) { $this->results = json_decode($this->job->getLogalyzerResults(), true); foreach($this->data['pattern'] as $index => $pattern) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', print_r($this->data['pattern'],true), FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Checking pattern: " . $pattern['pattern'] . " at index: ".$index."\n", FILE_APPEND); $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; From 22e123cc517d80a088cee9c29f385290f4d1ed7e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 20:52:13 +0200 Subject: [PATCH 468/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 31 +++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 9b4dd1e6f3..6843376d5e 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -780,27 +780,36 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $dbh = self::getDB(); $dbh->beginTransaction(); try { - $stmt1 = $dbh->prepare("SET @concat = CONCAT('$.results[',".$index.",'].count')"); + $stmt1 = $dbh->prepare("SELECT + JSON_UNQUOTE( + JSON_EXTRACT( + JSON_SEARCH(logalyzerResults, 'one', :pattern, NULL, '$.results[*].pattern'), '$[0]')) + INTO @index + FROM Job + WHERE jobId = :jobId;"); + $stmt1->bindParam(':pattern', $pattern, PDO::PARAM_STR); + $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); $stmt1->execute(); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nFIRST QUERY SUCCESSFUL\n", FILE_APPEND); $incrementQuery = "UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, - @concat, + @index, CAST(CAST(JSON_UNQUOTE( - JSON_EXTRACT(logalyzerResults, @concat) - ) AS UNSIGNED) + 7 AS CHAR)) - WHERE jobId = 29633 AND JSON_SEARCH(logalyzerResults, 'one', 'Error') is not null;"; + JSON_EXTRACT(logalyzerResults, @index) + ) AS UNSIGNED) + :amount AS CHAR)) + WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); if ($stmt2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); } - //$stmt2->bindParam(':pattern', $pattern, PDO::PARAM_STR); - //$stmt2->bindParam(':amount', $amount, PDO::PARAM_INT); - //$stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); - //if (!$stmt2->execute()) { - // file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); - //} + $stmt2->bindParam(':pattern', $pattern, PDO::PARAM_STR); + $stmt2->bindParam(':amount', $amount, PDO::PARAM_INT); + $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); + if (!$stmt2->execute()) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); + } //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; //$stmt3 = $dbh->prepare($hashUpdate); //$stmt3->execute([$hash, $jobId]); From 6ab0ee8e17d00f0610d85624231778782c579bb3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:03:35 +0200 Subject: [PATCH 469/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 6843376d5e..0179322816 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -793,13 +793,15 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nFIRST QUERY SUCCESSFUL\n", FILE_APPEND); $incrementQuery = "UPDATE Job - SET logalyzerResults = JSON_SET( - logalyzerResults, - @index, - CAST(CAST(JSON_UNQUOTE( - JSON_EXTRACT(logalyzerResults, @index) - ) AS UNSIGNED) + :amount AS CHAR)) - WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; + SET logalyzerResults = JSON_SET( + logalyzerResults, + REPLACE(@index, 'pattern', 'count'), + CAST(CAST( + JSON_UNQUOTE( + JSON_EXTRACT(logalyzerResults, REPLACE(@index, 'pattern', 'count')) + ) AS UNSIGNED) + 3 AS CHAR)) + WHERE jobId = 1 AND JSON_SEARCH(logalyzerResults, 'one', 'Error') is not null; +"; $stmt2 = $dbh->prepare($incrementQuery); if ($stmt2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); @@ -810,6 +812,8 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, if (!$stmt2->execute()) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nSECOND QUERY SUCCESSFUL\n", FILE_APPEND); + //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; //$stmt3 = $dbh->prepare($hashUpdate); //$stmt3->execute([$hash, $jobId]); From 2f601f1f646e034d28b976ef1920387df4b1cf7a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:05:20 +0200 Subject: [PATCH 470/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- libraries/logalyzer.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 0179322816..248980d594 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -775,7 +775,7 @@ public function getDB($test = false) { die("Fatal Error! Database connection failed. Message: " . $e->getMessage()); } } - public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $hash, $index, $amount) + public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $hash, $amount) { $dbh = self::getDB(); $dbh->beginTransaction(); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index aa5f53f1de..508f491870 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -113,7 +113,6 @@ public function examineLogLine($logLine) { $this->results = json_decode($this->job->getLogalyzerResults(), true); foreach($this->data['pattern'] as $index => $pattern) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', print_r($this->data['pattern'],true), FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Checking pattern: " . $pattern['pattern'] . " at index: ".$index."\n", FILE_APPEND); $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; @@ -122,10 +121,10 @@ public function examineLogLine($logLine) { if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $isInResultSet = true; if ($number >= 1) { - $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . " at index ".$index."\n"; + $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); - Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $index, $number); + Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); sleep(2); $resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultsAfterUpdate, true), FILE_APPEND); From f2dbdfc6eb734e558402233415255f686b238ddd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:07:31 +0200 Subject: [PATCH 471/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 248980d594..b9c368b3dd 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -799,8 +799,8 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, CAST(CAST( JSON_UNQUOTE( JSON_EXTRACT(logalyzerResults, REPLACE(@index, 'pattern', 'count')) - ) AS UNSIGNED) + 3 AS CHAR)) - WHERE jobId = 1 AND JSON_SEARCH(logalyzerResults, 'one', 'Error') is not null; + ) AS UNSIGNED) + :amount AS CHAR)) + WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null; "; $stmt2 = $dbh->prepare($incrementQuery); if ($stmt2 === false) { From 128856320613694782b6bc96b25e915405183afe Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:14:38 +0200 Subject: [PATCH 472/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index b9c368b3dd..1d201a8b22 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -800,8 +800,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, JSON_UNQUOTE( JSON_EXTRACT(logalyzerResults, REPLACE(@index, 'pattern', 'count')) ) AS UNSIGNED) + :amount AS CHAR)) - WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null; -"; + WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); if ($stmt2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); From 8b4576943078b2e814b55a6d116c69fac176b41a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:22:48 +0200 Subject: [PATCH 473/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 1d201a8b22..23fa8cff00 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -813,6 +813,16 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nSECOND QUERY SUCCESSFUL\n", FILE_APPEND); + $stmt = $dbh->query("SELECT logalyzerResults FROM Job WHERE jobId = :jobId"); + $stmt->bindParam(':jobId', $jobId, PDO::PARAM_INT); + // Fetch all results + $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + + // Print the results + foreach ($results as $row) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "logalyzerResults: " . $row . "\n", FILE_APPEND); + + } //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; //$stmt3 = $dbh->prepare($hashUpdate); //$stmt3->execute([$hash, $jobId]); From 1e25a7232499a7548c79ce48ac322b96835d0eed Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:23:52 +0200 Subject: [PATCH 474/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 23fa8cff00..97b038e520 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -813,7 +813,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nSECOND QUERY SUCCESSFUL\n", FILE_APPEND); - $stmt = $dbh->query("SELECT logalyzerResults FROM Job WHERE jobId = :jobId"); + $stmt = $dbh->query("SELECT logalyzerResults FROM Job WHERE jobId = :jobId;"); $stmt->bindParam(':jobId', $jobId, PDO::PARAM_INT); // Fetch all results $results = $stmt->fetchAll(PDO::FETCH_ASSOC); From 89179ac627dcb1f478763d481f5bd7e625be05ba Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:31:40 +0200 Subject: [PATCH 475/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 97b038e520..ccba588138 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -790,7 +790,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt1->bindParam(':pattern', $pattern, PDO::PARAM_STR); $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); $stmt1->execute(); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nFIRST QUERY SUCCESSFUL\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nFIRST QUERY OVER\n", FILE_APPEND); $incrementQuery = "UPDATE Job SET logalyzerResults = JSON_SET( @@ -811,22 +811,22 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, if (!$stmt2->execute()) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nSECOND QUERY SUCCESSFUL\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nSECOND QUERY OVER\n", FILE_APPEND); - $stmt = $dbh->query("SELECT logalyzerResults FROM Job WHERE jobId = :jobId;"); - $stmt->bindParam(':jobId', $jobId, PDO::PARAM_INT); - // Fetch all results - $results = $stmt->fetchAll(PDO::FETCH_ASSOC); - - // Print the results - foreach ($results as $row) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "logalyzerResults: " . $row . "\n", FILE_APPEND); - - } //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; //$stmt3 = $dbh->prepare($hashUpdate); //$stmt3->execute([$hash, $jobId]); $dbh->commit(); + + $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); + $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + + // Display the updated results + foreach ($results as $row) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); + } + + $stmt2->close(); } catch (PDOException $e) { From 68b7959a33e347d600118939459e838e0d84e935 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:32:48 +0200 Subject: [PATCH 476/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index ccba588138..cf53b73853 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -791,7 +791,13 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); $stmt1->execute(); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nFIRST QUERY OVER\n", FILE_APPEND); + $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); + $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + // Display the updated results + foreach ($results as $row) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); + } $incrementQuery = "UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, From 18d1b825f3c2b2f975a827ad7471f3f6618db434 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:40:15 +0200 Subject: [PATCH 477/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index cf53b73853..5bff36b83d 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -793,8 +793,10 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nFIRST QUERY OVER\n", FILE_APPEND); $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $stmt5 = $dbh->query("SELECT @index"); + $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$res5."\n", FILE_APPEND); - // Display the updated results foreach ($results as $row) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); } @@ -824,13 +826,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, //$stmt3->execute([$hash, $jobId]); $dbh->commit(); - $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); - $results = $stmt->fetchAll(PDO::FETCH_ASSOC); - - // Display the updated results - foreach ($results as $row) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); - } + $data = json_decode($this->job->getLogalyzerResults(), true); $stmt2->close(); From 488aa26c1d03a960e818f119631413f07166ad79 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:43:16 +0200 Subject: [PATCH 478/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 5bff36b83d..db8ded299d 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -794,8 +794,10 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt5 = $dbh->query("SELECT @index"); - $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$res5."\n", FILE_APPEND); + $res5 = $stmt5->fetchAll(PDO::FETCH_ASSOC); + foreach ($res5 as $row) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row."\n", FILE_APPEND); + } foreach ($results as $row) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); From f0a780356223f2abc96a9ea00cbdbdda78b095cc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:44:40 +0200 Subject: [PATCH 479/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index db8ded299d..f2d6e9406b 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -796,7 +796,9 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt5 = $dbh->query("SELECT @index"); $res5 = $stmt5->fetchAll(PDO::FETCH_ASSOC); foreach ($res5 as $row) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row."\n", FILE_APPEND); + foreach ($row as $entry) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n" . $entry . "\n", FILE_APPEND); + } } foreach ($results as $row) { From 9cd478ac85fabdc3d29a37f7f937c9bbc02f5c23 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:47:51 +0200 Subject: [PATCH 480/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index f2d6e9406b..32d1bc1325 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -783,7 +783,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt1 = $dbh->prepare("SELECT JSON_UNQUOTE( JSON_EXTRACT( - JSON_SEARCH(logalyzerResults, 'one', :pattern, NULL, '$.results[*].pattern'), '$[0]')) + JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]')) INTO @index FROM Job WHERE jobId = :jobId;"); From 0cd2c3d986003da0e8a8925e51df673467766bfe Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:49:55 +0200 Subject: [PATCH 481/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 32d1bc1325..68c83784ee 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -796,8 +796,9 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt5 = $dbh->query("SELECT @index"); $res5 = $stmt5->fetchAll(PDO::FETCH_ASSOC); foreach ($res5 as $row) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRow: " . $row . "\n", FILE_APPEND); foreach ($row as $entry) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n" . $entry . "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nEntry: " . $entry . "\n", FILE_APPEND); } } From c1a65229de0c41973bb76b7eb3a5aec082a0b9ae Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:51:36 +0200 Subject: [PATCH 482/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 68c83784ee..89dce8b9ae 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -793,8 +793,9 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nFIRST QUERY OVER\n", FILE_APPEND); $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $stmt5 = $dbh->query("SELECT @index"); - $res5 = $stmt5->fetchAll(PDO::FETCH_ASSOC); + $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); foreach ($res5 as $row) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRow: " . $row . "\n", FILE_APPEND); foreach ($row as $entry) { From 8d4df9a4190608ec5cb84913df3e4380d4936d53 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:52:05 +0200 Subject: [PATCH 483/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 89dce8b9ae..c5503b4b1d 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -796,6 +796,8 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt5 = $dbh->query("SELECT @index"); $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRes5 is: " . $res5 . "\n", FILE_APPEND); + foreach ($res5 as $row) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRow: " . $row . "\n", FILE_APPEND); foreach ($row as $entry) { From cde675b696676abc1bd796808ea1db8e5f707e2b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:53:42 +0200 Subject: [PATCH 484/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index c5503b4b1d..eb203748b8 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -796,13 +796,10 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt5 = $dbh->query("SELECT @index"); $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRes5 is: " . $res5 . "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRes5[0] is: " . $res5[0] . "\n", FILE_APPEND); foreach ($res5 as $row) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRow: " . $row . "\n", FILE_APPEND); - foreach ($row as $entry) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nEntry: " . $entry . "\n", FILE_APPEND); - } } foreach ($results as $row) { From 1ee77b813c8bd8f8c76abfdbd692b250b75281e6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:54:37 +0200 Subject: [PATCH 485/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index eb203748b8..f4ba5063f3 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -796,7 +796,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt5 = $dbh->query("SELECT @index"); $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRes5[0] is: " . $res5[0] . "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRes5 is: " . print_r($res5[0], true) . "\n", FILE_APPEND); foreach ($res5 as $row) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRow: " . $row . "\n", FILE_APPEND); From 5e5e41fea9a17849b5d79bca451f0b469e952fbc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:55:15 +0200 Subject: [PATCH 486/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index f4ba5063f3..9325896d35 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -796,7 +796,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt5 = $dbh->query("SELECT @index"); $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRes5 is: " . print_r($res5[0], true) . "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRes5 is: " . print_r($res5, true) . "\n", FILE_APPEND); foreach ($res5 as $row) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRow: " . $row . "\n", FILE_APPEND); From 85522a169c00b8d9bead5d50302da3685ea5e32f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 21:57:46 +0200 Subject: [PATCH 487/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 9325896d35..1937ac143a 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -796,11 +796,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt5 = $dbh->query("SELECT @index"); $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRes5 is: " . print_r($res5, true) . "\n", FILE_APPEND); - - foreach ($res5 as $row) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRow: " . $row . "\n", FILE_APPEND); - } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRes5[@index] is: " . $res5['@index'] . "\n", FILE_APPEND); foreach ($results as $row) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); @@ -808,16 +804,17 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $incrementQuery = "UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, - REPLACE(@index, 'pattern', 'count'), + REPLACE(:index, 'pattern', 'count'), CAST(CAST( JSON_UNQUOTE( - JSON_EXTRACT(logalyzerResults, REPLACE(@index, 'pattern', 'count')) + JSON_EXTRACT(logalyzerResults, REPLACE(:index, 'pattern', 'count')) ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); if ($stmt2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); } + $stmt2->bindParam(':index', $res5['@index'], PDO::PARAM_STR); $stmt2->bindParam(':pattern', $pattern, PDO::PARAM_STR); $stmt2->bindParam(':amount', $amount, PDO::PARAM_INT); $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); From 27c04b6d4019d3a4a516218b823463809cbd15b4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:01:57 +0200 Subject: [PATCH 488/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 1937ac143a..6b43c27917 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -796,7 +796,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt5 = $dbh->query("SELECT @index"); $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nRes5[@index] is: " . $res5['@index'] . "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Res5[@index] is: " . $res5['@index'] . "\n", FILE_APPEND); foreach ($results as $row) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); @@ -811,7 +811,8 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); - if ($stmt2 === false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $stmt2, FILE_APPEND); + if ($stmt2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); } $stmt2->bindParam(':index', $res5['@index'], PDO::PARAM_STR); From 418fe2ee3a2b9ccc590e2aca36f958cd8bdb98fc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:03:40 +0200 Subject: [PATCH 489/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 6b43c27917..1540751a9d 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -811,7 +811,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $stmt2, FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $stmt2, FILE_APPEND); if ($stmt2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); } @@ -829,7 +829,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, //$stmt3->execute([$hash, $jobId]); $dbh->commit(); - $data = json_decode($this->job->getLogalyzerResults(), true); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nCOMMIT OVER\n", FILE_APPEND); $stmt2->close(); From 1292eb1d70429348d33d18b45b04a12cb9f9b0ed Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:07:03 +0200 Subject: [PATCH 490/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 1540751a9d..50e58a9bca 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -796,7 +796,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt5 = $dbh->query("SELECT @index"); $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Res5[@index] is: " . $res5['@index'] . "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Res5[@index] is: " . $res5['@index'] . ". Amount is ".$amount."\n", FILE_APPEND); foreach ($results as $row) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); @@ -811,7 +811,6 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $stmt2, FILE_APPEND); if ($stmt2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); } @@ -830,7 +829,11 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $dbh->commit(); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nCOMMIT OVER\n", FILE_APPEND); - + $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); + $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + foreach ($results as $row) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); + } $stmt2->close(); } From 50cba7fe8d9f61bd65e88b55e13ee417cb37b25d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:11:09 +0200 Subject: [PATCH 491/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 50e58a9bca..92cb965717 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -808,7 +808,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, CAST(CAST( JSON_UNQUOTE( JSON_EXTRACT(logalyzerResults, REPLACE(:index, 'pattern', 'count')) - ) AS UNSIGNED) + :amount AS CHAR)) + ) AS UNSIGNED) + :amount+44 AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); if ($stmt2 === false) { From ce25b17053616e6a21d3f92b869e26b217ebea0c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:17:47 +0200 Subject: [PATCH 492/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 92cb965717..982c89f30a 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -782,8 +782,8 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, try { $stmt1 = $dbh->prepare("SELECT JSON_UNQUOTE( - JSON_EXTRACT( - JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]')) + JSON_REPLACE(JSON_EXTRACT( + JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]')), '.pattern', '.count') INTO @index FROM Job WHERE jobId = :jobId;"); @@ -804,10 +804,10 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $incrementQuery = "UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, - REPLACE(:index, 'pattern', 'count'), + :index, CAST(CAST( JSON_UNQUOTE( - JSON_EXTRACT(logalyzerResults, REPLACE(:index, 'pattern', 'count')) + JSON_EXTRACT(logalyzerResults, :index) ) AS UNSIGNED) + :amount+44 AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); From efb3e1202d097cea532bb7524aa38026ab1b9389 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:19:14 +0200 Subject: [PATCH 493/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 982c89f30a..1a62fe2724 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -783,7 +783,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt1 = $dbh->prepare("SELECT JSON_UNQUOTE( JSON_REPLACE(JSON_EXTRACT( - JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]')), '.pattern', '.count') + JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]'), '.pattern', '.count')) INTO @index FROM Job WHERE jobId = :jobId;"); From dd01caadc2249be0a64d5b002dd61ccb5a1016ad Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:21:41 +0200 Subject: [PATCH 494/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 1a62fe2724..8606a39b23 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -782,7 +782,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, try { $stmt1 = $dbh->prepare("SELECT JSON_UNQUOTE( - JSON_REPLACE(JSON_EXTRACT( + REPLACE(JSON_EXTRACT( JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]'), '.pattern', '.count')) INTO @index FROM Job From e300fcf361263fc57d84018aac1649df36538767 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:25:48 +0200 Subject: [PATCH 495/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 8606a39b23..ba20cba772 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -783,7 +783,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt1 = $dbh->prepare("SELECT JSON_UNQUOTE( REPLACE(JSON_EXTRACT( - JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]'), '.pattern', '.count')) + JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]')), '].pattern', '].count' INTO @index FROM Job WHERE jobId = :jobId;"); From 6e7c1ed6a4b05ef8b9352ffda4874221709d45c3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:27:08 +0200 Subject: [PATCH 496/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index ba20cba772..89d5e5b349 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -783,7 +783,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt1 = $dbh->prepare("SELECT JSON_UNQUOTE( REPLACE(JSON_EXTRACT( - JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]')), '].pattern', '].count' + JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]'), '].pattern', '].count')) INTO @index FROM Job WHERE jobId = :jobId;"); From d6211258cb1d9a2c2724cba5aeb8360975da7124 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:27:41 +0200 Subject: [PATCH 497/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 89d5e5b349..49f16ce04e 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -808,7 +808,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, CAST(CAST( JSON_UNQUOTE( JSON_EXTRACT(logalyzerResults, :index) - ) AS UNSIGNED) + :amount+44 AS CHAR)) + ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); if ($stmt2 === false) { From f27491cc06225e3fbd16715ef698fff379dad6b5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:37:57 +0200 Subject: [PATCH 498/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 29 +++++++++----------- libraries/logalyzer.php | 5 +--- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 49f16ce04e..25cc3ab6c6 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -790,17 +790,17 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt1->bindParam(':pattern', $pattern, PDO::PARAM_STR); $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); $stmt1->execute(); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nFIRST QUERY OVER\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nFIRST QUERY OVER\n", FILE_APPEND); $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt5 = $dbh->query("SELECT @index"); $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Res5[@index] is: " . $res5['@index'] . ". Amount is ".$amount."\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Res5[@index] is: " . $res5['@index'] . ". Amount is ".$amount."\n", FILE_APPEND); - foreach ($results as $row) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); - } + //foreach ($results as $row) { + // file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); + //} $incrementQuery = "UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, @@ -821,21 +821,18 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, if (!$stmt2->execute()) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nSECOND QUERY OVER\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nSECOND QUERY OVER\n", FILE_APPEND); - //$hashUpdate = "UPDATE Job SET logalyzerResults = JSON_SET(logalyzerResults, '$.hash', ?) WHERE jobId=?"; - //$stmt3 = $dbh->prepare($hashUpdate); - //$stmt3->execute([$hash, $jobId]); $dbh->commit(); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nCOMMIT OVER\n", FILE_APPEND); - $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); - $results = $stmt->fetchAll(PDO::FETCH_ASSOC); - foreach ($results as $row) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); - } - - $stmt2->close(); + //$stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); + //$results = $stmt->fetchAll(PDO::FETCH_ASSOC); + //foreach ($results as $row) { + // file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); + //} + //$stmt5->close(); + //$stmt2->close(); } catch (PDOException $e) { $dbh->rollback(); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 508f491870..2bb4605954 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -121,13 +121,10 @@ public function examineLogLine($logLine) { if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $isInResultSet = true; if ($number >= 1) { - $string = "\n Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; + $string = "Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); - sleep(2); - $resultsAfterUpdate = json_decode($this->job->getLogalyzerResults(), true); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultsAfterUpdate, true), FILE_APPEND); } } } From 181d94f97e2b02330fa94b39740afcd79e676f07 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:43:25 +0200 Subject: [PATCH 499/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 8 ++++---- libraries/logalyzer.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 25cc3ab6c6..cde45539a2 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -794,8 +794,8 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt5 = $dbh->query("SELECT @index"); - $res5 = $stmt5->fetch(PDO::FETCH_ASSOC); + $helper = $dbh->query("SELECT @index"); + $index = $helper->fetch(PDO::FETCH_ASSOC); //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Res5[@index] is: " . $res5['@index'] . ". Amount is ".$amount."\n", FILE_APPEND); //foreach ($results as $row) { @@ -814,7 +814,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, if ($stmt2 === false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); } - $stmt2->bindParam(':index', $res5['@index'], PDO::PARAM_STR); + $stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); $stmt2->bindParam(':pattern', $pattern, PDO::PARAM_STR); $stmt2->bindParam(':amount', $amount, PDO::PARAM_INT); $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); @@ -825,7 +825,7 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $dbh->commit(); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nCOMMIT OVER\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nCOMMIT OVER\n", FILE_APPEND); //$stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); //$results = $stmt->fetchAll(PDO::FETCH_ASSOC); //foreach ($results as $row) { diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 2bb4605954..4cfebf6548 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -105,15 +105,15 @@ public function examineEntireLog() { * @return void */ public function examineLogLine($logLine) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\n--------------------------------\n", FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Start of logalyzer checkLogline()\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\n--------------------------------\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Start of logalyzer checkLogline()\n", FILE_APPEND); $hash = $this->calculateHash(); // Load existing result set $this->results = json_decode($this->job->getLogalyzerResults(), true); foreach($this->data['pattern'] as $index => $pattern) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Checking pattern: " . $pattern['pattern'] . " at index: ".$index."\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Checking pattern: " . $pattern['pattern'] . " at index: ".$index."\n", FILE_APPEND); $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; foreach($this->results['pattern'] as $result) { @@ -121,8 +121,8 @@ public function examineLogLine($logLine) { if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $isInResultSet = true; if ($number >= 1) { - $string = "Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); + //$string = "Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); } @@ -146,7 +146,7 @@ public function examineLogLine($logLine) { } } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nEnd of logalyzer checkLogline()\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nEnd of logalyzer checkLogline()\n", FILE_APPEND); } /** From 964756cb7e7acf9f8a5b0ab3ae1940a09b5f86aa Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 22:44:28 +0200 Subject: [PATCH 500/644] LogLine debugging --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4cfebf6548..25cffef3f3 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -129,7 +129,7 @@ public function examineLogLine($logLine) { } } if(!$isInResultSet) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..", FILE_APPEND); $pattern['count'] = $number; $this->results['pattern'][] = $pattern; $this->results['hash'] = $hash; From 42c5ed0f380d31b104045ace688dc50d0cfbc742 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:11:44 +0200 Subject: [PATCH 501/644] LogLine debugging --- libraries/logalyzer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 25cffef3f3..99db7f2b9a 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -144,7 +144,9 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); }*/ } - + if($this->results['hash'] === "") { + Factory::getJobFactory()->logalyzerUpdateHash($this->job->getJobId(), $hash); + } } //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nEnd of logalyzer checkLogline()\n", FILE_APPEND); } From ed41d7de14db00521c5fe15729ee2ebceee8ffa5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:13:35 +0200 Subject: [PATCH 502/644] LogLine debugging --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 99db7f2b9a..4a6cfc3cb3 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -145,6 +145,7 @@ public function examineLogLine($logLine) { }*/ } if($this->results['hash'] === "") { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); Factory::getJobFactory()->logalyzerUpdateHash($this->job->getJobId(), $hash); } } From 47eb2528af411d9bfba8f5c06c58a6a7503bde4f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:17:16 +0200 Subject: [PATCH 503/644] LogLine debugging --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4a6cfc3cb3..d86c690be0 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -144,6 +144,8 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); }*/ } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash is: ".$this->results['hash']."\n", FILE_APPEND); + if($this->results['hash'] === "") { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); Factory::getJobFactory()->logalyzerUpdateHash($this->job->getJobId(), $hash); From ccc556a6f5fcb916764ff96c3d73da45dfb9c15d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:18:50 +0200 Subject: [PATCH 504/644] LogLine debugging --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index d86c690be0..a8ebad6232 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -144,7 +144,7 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); }*/ } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash is: ".$this->results['hash']."\n", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash is: ".$this->results['hash']."\n", FILE_APPEND); if($this->results['hash'] === "") { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); From c238e2fde8465c4c1b0f4a69da4ca0e245621f51 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:19:31 +0200 Subject: [PATCH 505/644] LogLine debugging --- libraries/logalyzer.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index a8ebad6232..6b98c9b71e 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -144,12 +144,12 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); }*/ } - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash is: ".$this->results['hash']."\n", FILE_APPEND); + } + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash is: ".$this->results['hash']."\n", FILE_APPEND); - if($this->results['hash'] === "") { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); - Factory::getJobFactory()->logalyzerUpdateHash($this->job->getJobId(), $hash); - } + if($this->results['hash'] === "") { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); + Factory::getJobFactory()->logalyzerUpdateHash($this->job->getJobId(), $hash); } //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nEnd of logalyzer checkLogline()\n", FILE_APPEND); } From e576f5921f95db0f894489d559c180370d807718 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:22:04 +0200 Subject: [PATCH 506/644] LogLine debugging --- libraries/logalyzer.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 6b98c9b71e..4c020df9f5 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,7 +132,10 @@ public function examineLogLine($logLine) { //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..", FILE_APPEND); $pattern['count'] = $number; $this->results['pattern'][] = $pattern; - $this->results['hash'] = $hash; + if($this->results['hash'] === "") { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); + Factory::getJobFactory()->logalyzerUpdateHash($this->job->getJobId(), $hash); + } $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); //$response1= Factory::getJobFactory()->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); @@ -145,12 +148,6 @@ public function examineLogLine($logLine) { }*/ } } - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash is: ".$this->results['hash']."\n", FILE_APPEND); - - if($this->results['hash'] === "") { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); - Factory::getJobFactory()->logalyzerUpdateHash($this->job->getJobId(), $hash); - } //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nEnd of logalyzer checkLogline()\n", FILE_APPEND); } From af659fefb5a234a0e336a7b955e0c1cdb2f5fe50 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:23:53 +0200 Subject: [PATCH 507/644] LogLine debugging --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4c020df9f5..c2f00060a0 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,6 +132,7 @@ public function examineLogLine($logLine) { //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..", FILE_APPEND); $pattern['count'] = $number; $this->results['pattern'][] = $pattern; + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash is: ".$this->results['hash']."\n", FILE_APPEND); if($this->results['hash'] === "") { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); Factory::getJobFactory()->logalyzerUpdateHash($this->job->getJobId(), $hash); From 6a59e3f40fe7ca122cf5d65df70263ebb259b981 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:25:09 +0200 Subject: [PATCH 508/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 2 +- libraries/logalyzer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index cde45539a2..95d1ff1143 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -775,7 +775,7 @@ public function getDB($test = false) { die("Fatal Error! Database connection failed. Message: " . $e->getMessage()); } } - public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $hash, $amount) + public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $amount) { $dbh = self::getDB(); $dbh->beginTransaction(); diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c2f00060a0..85c3f4ee26 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -124,7 +124,7 @@ public function examineLogLine($logLine) { //$string = "Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); - Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); + Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $number); } } } From c3ed19637481b4ae5c2cba642f3dd0dc6c10a944 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:27:23 +0200 Subject: [PATCH 509/644] LogLine debugging --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 85c3f4ee26..9f21df144b 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -133,7 +133,7 @@ public function examineLogLine($logLine) { $pattern['count'] = $number; $this->results['pattern'][] = $pattern; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash is: ".$this->results['hash']."\n", FILE_APPEND); - if($this->results['hash'] === "") { + if($this->results['hash'] === "" || $this->results['hash'] === null) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); Factory::getJobFactory()->logalyzerUpdateHash($this->job->getJobId(), $hash); } From ba01b04c00c8e811c1676c88c7903265ffc74dc7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:28:59 +0200 Subject: [PATCH 510/644] LogLine debugging --- controllers/job.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/job.php b/controllers/job.php index f7908f4f7b..85d76c890f 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -163,7 +163,7 @@ public function detail() { $json = $job->getLogalyzerResults(); if($json != null) { $results = json_decode($json, true); - if($results['hash'] != $hash) { + if(!isset($results['hash'])||$results['hash'] != $hash) { $this->view->assign('usedOutdatedPattern', true); } } From dc8b73fa883f4476e1d678acc551759335b8d5ca Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:31:48 +0200 Subject: [PATCH 511/644] LogLine debugging --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 9f21df144b..319ee07755 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -135,7 +135,7 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash is: ".$this->results['hash']."\n", FILE_APPEND); if($this->results['hash'] === "" || $this->results['hash'] === null) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); - Factory::getJobFactory()->logalyzerUpdateHash($this->job->getJobId(), $hash); + $this->results['hash'] = $hash; } $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); From 6a473cf04f27895da532987d2f0bc0c1305f9c3e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:33:31 +0200 Subject: [PATCH 512/644] LogLine debugging --- libraries/logalyzer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 319ee07755..3a5918aa7c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,7 +132,6 @@ public function examineLogLine($logLine) { //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..", FILE_APPEND); $pattern['count'] = $number; $this->results['pattern'][] = $pattern; - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash is: ".$this->results['hash']."\n", FILE_APPEND); if($this->results['hash'] === "" || $this->results['hash'] === null) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); $this->results['hash'] = $hash; From eafada04bdb28acba7e4b5e275ee8193581cf054 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:34:45 +0200 Subject: [PATCH 513/644] LogLine debugging --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 3a5918aa7c..a7065e8168 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -133,7 +133,7 @@ public function examineLogLine($logLine) { $pattern['count'] = $number; $this->results['pattern'][] = $pattern; if($this->results['hash'] === "" || $this->results['hash'] === null) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); + //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); $this->results['hash'] = $hash; } $this->job->setLogalyzerResults(json_encode($this->results)); From 046dfe51c70034bdad9e7f6e60e1422dfc8a9ba4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 29 Jul 2024 23:56:23 +0200 Subject: [PATCH 514/644] LogLine debugging --- libraries/dba/AbstractModelFactory.class.php | 54 ++++++++++++-------- libraries/logalyzer.php | 37 ++++---------- 2 files changed, 42 insertions(+), 49 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 95d1ff1143..98c4e5d7e0 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -775,7 +775,17 @@ public function getDB($test = false) { die("Fatal Error! Database connection failed. Message: " . $e->getMessage()); } } - public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $type, $amount) + + /** + * Creates two queries to identify the right value to increment + * $stmt1 will search for the index of the array's entry + * $incrementQuery will look in the specified :index of the array and replace the value of the key + * @param $jobId + * @param $pattern + * @param $amount + * @return void + */ + public function incrementJobCountAtomically($jobId, $pattern, $amount) { $dbh = self::getDB(); $dbh->beginTransaction(); @@ -790,17 +800,10 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, $stmt1->bindParam(':pattern', $pattern, PDO::PARAM_STR); $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); $stmt1->execute(); - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nFIRST QUERY OVER\n", FILE_APPEND); - $stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); - $results = $stmt->fetchAll(PDO::FETCH_ASSOC); $helper = $dbh->query("SELECT @index"); $index = $helper->fetch(PDO::FETCH_ASSOC); - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Res5[@index] is: " . $res5['@index'] . ". Amount is ".$amount."\n", FILE_APPEND); - //foreach ($results as $row) { - // file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); - //} $incrementQuery = "UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, @@ -821,24 +824,26 @@ public function incrementJobCountAtomically($jobId, $logLevel, $pattern, $regex, if (!$stmt2->execute()) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); } - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nSECOND QUERY OVER\n", FILE_APPEND); $dbh->commit(); - - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nCOMMIT OVER\n", FILE_APPEND); - //$stmt = $dbh->query("SELECT * FROM Job WHERE jobId = 29633"); - //$results = $stmt->fetchAll(PDO::FETCH_ASSOC); - //foreach ($results as $row) { - // file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\n".$row['logalyzerResults']."\n", FILE_APPEND); - //} - //$stmt5->close(); - //$stmt2->close(); - } + } catch (PDOException $e) { $dbh->rollback(); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $e->getMessage(), FILE_APPEND); } } + + /** + * currently not in use + * @param $jobId + * @param $logLevel + * @param $pattern + * @param $regex + * @param $type + * @param $hash + * @param $amount + * @return bool + */ public function logalyzerAppendNewResult($jobId, $logLevel, $pattern, $regex, $type, $hash, $amount=0) { $dbh = self::getDB(); $dbh->beginTransaction(); @@ -873,10 +878,11 @@ public function logalyzerUpdateHash($jobId, $hash) { } /** * Goes over all results and aggregates the counts for keywords of the same logLevel - * Returns an array of type ['logLevel'=> int] ex. ['warn'=> 5] + * Returns the accumulated number of all patterns with the specified $logLevel * @param $job + * @param $logLevel * @param $type - * @return array + * @return int */ public function getJobCountForLogLevel($job, $logLevel, $type) { if($job->getLogalyzerResults() != null) { @@ -905,6 +911,12 @@ public function getJobHash($job) { return ""; } } + + /** + * Returns true if all positive patterns are present, or if no positive pattern exists for this system + * @param $job + * @return bool + */ public function checkAllPositiveJobPatterns($job) { $json = $job->getLogalyzerResults(); if ($json != null) { diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index a7065e8168..876b1bdf38 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -99,21 +99,16 @@ public function examineEntireLog() { } /** - * Reads a single logLine and increments error/warnings counters if a pattern word is present inside. - * Number or occurances does not matter for now. One error logLine is considered one potential error event. + * Reads a submitted logLine and updates the database object with a new result json object * @param $logLine * @return void */ public function examineLogLine($logLine) { - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\n--------------------------------\n", FILE_APPEND); - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Start of logalyzer checkLogline()\n", FILE_APPEND); - $hash = $this->calculateHash(); // Load existing result set $this->results = json_decode($this->job->getLogalyzerResults(), true); foreach($this->data['pattern'] as $index => $pattern) { - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "Checking pattern: " . $pattern['pattern'] . " at index: ".$index."\n", FILE_APPEND); $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; foreach($this->results['pattern'] as $result) { @@ -121,38 +116,24 @@ public function examineLogLine($logLine) { if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $isInResultSet = true; if ($number >= 1) { - //$string = "Found result in result set, trying to increment.. " . $result["pattern"] . " by " . $number . "\n"; - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $string, FILE_APPEND); - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); - Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $number); + Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['pattern'], $number); } } } if(!$isInResultSet) { - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nNew result. Appending to result set..", FILE_APPEND); $pattern['count'] = $number; $this->results['pattern'][] = $pattern; if($this->results['hash'] === "" || $this->results['hash'] === null) { - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nHash was empty.. setting hash", FILE_APPEND); $this->results['hash'] = $hash; } $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); - //$response1= Factory::getJobFactory()->logalyzerAppendNewResult($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, 0); - /*if($response1 === false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); - } - $response2 = Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['logLevel'], $pattern['pattern'], $pattern['regex'], $pattern['type'], $hash, $number); - if($response2 === false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nDatabase incrementJobCountAtomically failed.\n", FILE_APPEND); - }*/ } } - //file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId(). '.log', "\nEnd of logalyzer checkLogline()\n", FILE_APPEND); } /** - * Creates empty pattern objects + * Creates empty pattern for a system * @return void */ private function createBasicPatterns() { @@ -234,7 +215,6 @@ public function addKey(string $logLevel, string $pattern, string $regex, string /** * @param string $logLevel * @param string $pattern 'the pattern string' - * @param string $regex 'string' or 'regex' * @param string $type 'positive' or 'negative' * @return void */ @@ -259,16 +239,17 @@ public function removeKey(string $logLevel, string $pattern, string $type) { } } } + + /** + * Populates the local variables for a new Job Result + * @return void + */ private function createEmptyJobLogalyzerResults() { $this->results['hash'] = ""; $this->results['pattern'] = array(); } - private function saveJobLogalyzerResults() { - $this->job->setLogalyzerResults(json_encode($this->results)); - Factory::getJobFactory()->update($this->job); - } + /** - * Allows calculating the hash before any operations are done * @return string */ function calculateHash() { From 0a0c5753b57871979fd73646654d73361f3449db Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 30 Jul 2024 18:33:10 +0200 Subject: [PATCH 515/644] Methods to record time for Evaluation added --- libraries/logalyzer.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 876b1bdf38..40f2f1f5ac 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -104,6 +104,7 @@ public function examineEntireLog() { * @return void */ public function examineLogLine($logLine) { + $start = microtime(true); $hash = $this->calculateHash(); // Load existing result set $this->results = json_decode($this->job->getLogalyzerResults(), true); @@ -130,8 +131,24 @@ public function examineLogLine($logLine) { Factory::getJobFactory()->update($this->job); } } + $end = microtime(true); + $this->logTime($start, $end); } + private function mailResults() { + $to = "p.buetler@stud.unibas.ch"; + $subj = "Eval Results"; + $from = 'chronos@stud.unibas.ch'; + $from_name = 'chronos'; + $path = UPLOADED_DATA_PATH . '/log/time.log'; + mail($to, $subj, file_get_contents($path)); + // Empty the file afterwards + file_put_contents($path, ""); + } + private function logTime($start, $end) { + $path = UPLOADED_DATA_PATH . '/log/time.log'; + file_put_contents($path, $start-$end.'\n', FILE_APPEND); + } /** * Creates empty pattern for a system * @return void From 34deddf2fec6ea9b8893b7c5886d0f666e396716 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 30 Jul 2024 18:34:32 +0200 Subject: [PATCH 516/644] Methods to record time for Evaluation added --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 40f2f1f5ac..f504b1248d 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,7 +132,8 @@ public function examineLogLine($logLine) { } } $end = microtime(true); - $this->logTime($start, $end); + //$this->logTime($start, $end); + $this->mailResults(); } private function mailResults() { $to = "p.buetler@stud.unibas.ch"; From 4a3c876e9d300260912803ba87bdbb548f167fd1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 30 Jul 2024 18:36:45 +0200 Subject: [PATCH 517/644] Methods to record time for Evaluation added --- libraries/logalyzer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index f504b1248d..5d5beeabc4 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,8 +132,8 @@ public function examineLogLine($logLine) { } } $end = microtime(true); - //$this->logTime($start, $end); - $this->mailResults(); + $this->logTime($start, $end); + //$this->mailResults(); } private function mailResults() { $to = "p.buetler@stud.unibas.ch"; @@ -148,7 +148,7 @@ private function mailResults() { } private function logTime($start, $end) { $path = UPLOADED_DATA_PATH . '/log/time.log'; - file_put_contents($path, $start-$end.'\n', FILE_APPEND); + file_put_contents($path, $end-$start.",", FILE_APPEND); } /** * Creates empty pattern for a system From b5a7ed057a568d667ad949a5295250c962573705 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 30 Jul 2024 18:48:25 +0200 Subject: [PATCH 518/644] Methods to record time for Evaluation added --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 5d5beeabc4..f571003fca 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,8 +132,8 @@ public function examineLogLine($logLine) { } } $end = microtime(true); - $this->logTime($start, $end); - //$this->mailResults(); + //$this->logTime($start, $end); + $this->mailResults(); } private function mailResults() { $to = "p.buetler@stud.unibas.ch"; From 0253580e210f46bf86a1d01eb18a5d717766615e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 30 Jul 2024 18:50:46 +0200 Subject: [PATCH 519/644] Methods to record time for Evaluation added --- libraries/logalyzer.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index f571003fca..64b068bb60 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,8 +132,12 @@ public function examineLogLine($logLine) { } } $end = microtime(true); - //$this->logTime($start, $end); - $this->mailResults(); + if($logLine == "SendMail") { + $this->mailResults(); + } + else { + $this->logTime($start, $end); + } } private function mailResults() { $to = "p.buetler@stud.unibas.ch"; From 2965c696e93e7d41676db619b1c1677ec06d8e03 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 30 Jul 2024 18:55:36 +0200 Subject: [PATCH 520/644] Methods to record time for Evaluation added --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 64b068bb60..bdb9949c6c 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,7 +132,7 @@ public function examineLogLine($logLine) { } } $end = microtime(true); - if($logLine == "SendMail") { + if($logLine == "SendMail\n") { $this->mailResults(); } else { From 708d7f28858ea0ffd7fbda2cb09da3ec14d38505 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 30 Jul 2024 18:57:53 +0200 Subject: [PATCH 521/644] Methods to record time for Evaluation added --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index bdb9949c6c..9329daf8d2 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -152,7 +152,7 @@ private function mailResults() { } private function logTime($start, $end) { $path = UPLOADED_DATA_PATH . '/log/time.log'; - file_put_contents($path, $end-$start.",", FILE_APPEND); + file_put_contents($path, ($end-$start*1000).",", FILE_APPEND); } /** * Creates empty pattern for a system From f019186cfa869031c27197d0c72053721eb8f047 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 30 Jul 2024 19:05:17 +0200 Subject: [PATCH 522/644] Methods to record time for Evaluation added --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 9329daf8d2..bc744d6332 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -152,7 +152,7 @@ private function mailResults() { } private function logTime($start, $end) { $path = UPLOADED_DATA_PATH . '/log/time.log'; - file_put_contents($path, ($end-$start*1000).",", FILE_APPEND); + file_put_contents($path, (($end-$start)*1000).",", FILE_APPEND); } /** * Creates empty pattern for a system From eabd4ab17571215b6c6a35d5fa91f06cf60176f2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 30 Jul 2024 19:13:25 +0200 Subject: [PATCH 523/644] Methods to record time for Evaluation added --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index bc744d6332..59a06029ab 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -152,7 +152,7 @@ private function mailResults() { } private function logTime($start, $end) { $path = UPLOADED_DATA_PATH . '/log/time.log'; - file_put_contents($path, (($end-$start)*1000).",", FILE_APPEND); + file_put_contents($path, round((($end-$start)*1000),4).",", FILE_APPEND); } /** * Creates empty pattern for a system From 26362c1e31e139593dd5be9a586de6f1d56803fd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 30 Jul 2024 22:12:02 +0200 Subject: [PATCH 524/644] removed time measurement methods from being active --- libraries/logalyzer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 59a06029ab..202e9a03af 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -104,7 +104,7 @@ public function examineEntireLog() { * @return void */ public function examineLogLine($logLine) { - $start = microtime(true); + #$start = microtime(true); $hash = $this->calculateHash(); // Load existing result set $this->results = json_decode($this->job->getLogalyzerResults(), true); @@ -131,13 +131,13 @@ public function examineLogLine($logLine) { Factory::getJobFactory()->update($this->job); } } - $end = microtime(true); + /*$end = microtime(true); if($logLine == "SendMail\n") { $this->mailResults(); } else { $this->logTime($start, $end); - } + }*/ } private function mailResults() { $to = "p.buetler@stud.unibas.ch"; From a56c1db165249c5c1d0f3d6ad994bdf0c7e94adc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 31 Jul 2024 00:50:44 +0200 Subject: [PATCH 525/644] fixed hash check when new job/evaluation is created --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 36465f7e8e..e5741f3fa8 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -261,7 +261,7 @@ function getLogalyzerResponses(evalId) { - getJobHash($job) != $data['systemHash']) {?> + getJobHash($job) != $data['systemHash'] && Factory::getJobFactory()->getJobHash($job) != null ) {?>
From a750b6e6428d188b4b91d8e68e7bae323b0b3f09 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 31 Jul 2024 00:52:24 +0200 Subject: [PATCH 526/644] fixed hash check when new job/evaluation is created --- controllers/evaluation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 4ef469747d..8e8f59b8f2 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -180,7 +180,7 @@ public function detail() { } else { $resultsAvailable = true; } - if(Factory::getJobFactory()->getJobHash($subJob) != $systemPattern['hash']) { + if(Factory::getJobFactory()->getJobHash($subJob) != $systemPattern['hash'] && Factory::getJobFactory()->getJobHash($subJob) != null) { $usedOutdatedPattern = true; } } From bbd2646783ac63bc133691bd1b6045df619f3491 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 31 Jul 2024 00:53:53 +0200 Subject: [PATCH 527/644] fixed hash check when new job/evaluation is created --- controllers/evaluation.php | 2 +- views/evaluation/detail.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 8e8f59b8f2..53f730933e 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -180,7 +180,7 @@ public function detail() { } else { $resultsAvailable = true; } - if(Factory::getJobFactory()->getJobHash($subJob) != $systemPattern['hash'] && Factory::getJobFactory()->getJobHash($subJob) != null) { + if(Factory::getJobFactory()->getJobHash($subJob) != $systemPattern['hash'] && Factory::getJobFactory()->getJobHash($subJob) != "") { $usedOutdatedPattern = true; } } diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index e5741f3fa8..1d741cdfe3 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -261,7 +261,7 @@ function getLogalyzerResponses(evalId) { - getJobHash($job) != $data['systemHash'] && Factory::getJobFactory()->getJobHash($job) != null ) {?> + getJobHash($job) != $data['systemHash'] && Factory::getJobFactory()->getJobHash($job) != "" ) {?> From fd686a20e4be4c4cd657d9e91c8704420b67597d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 31 Jul 2024 00:54:57 +0200 Subject: [PATCH 528/644] fixed hash check when new job/evaluation is created --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 1d741cdfe3..71bcbe5a87 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -262,7 +262,7 @@ function getLogalyzerResponses(evalId) { getJobHash($job) != $data['systemHash'] && Factory::getJobFactory()->getJobHash($job) != "" ) {?> - + getJobHash($job); ?> From 122703fe8f0174c24dfc0a4fcbb92268fe8ca9dd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 31 Jul 2024 00:56:15 +0200 Subject: [PATCH 529/644] fixed hash check when new job/evaluation is created --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 71bcbe5a87..1d741cdfe3 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -262,7 +262,7 @@ function getLogalyzerResponses(evalId) { getJobHash($job) != $data['systemHash'] && Factory::getJobFactory()->getJobHash($job) != "" ) {?> - getJobHash($job); ?> + From 87c1b39e9fbfeea125c6695d24a47397c3dbc7ed Mon Sep 17 00:00:00 2001 From: PatrikB Date: Thu, 1 Aug 2024 13:20:35 +0200 Subject: [PATCH 530/644] Append all results at the end to create only 1 database transaction --- libraries/dba/AbstractModelFactory.class.php | 71 ++++++++++---------- libraries/logalyzer.php | 8 ++- 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 98c4e5d7e0..ff58b0736a 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -785,46 +785,47 @@ public function getDB($test = false) { * @param $amount * @return void */ - public function incrementJobCountAtomically($jobId, $pattern, $amount) + public function incrementJobCountAtomically($jobId, $resultCollection) { $dbh = self::getDB(); $dbh->beginTransaction(); try { - $stmt1 = $dbh->prepare("SELECT - JSON_UNQUOTE( - REPLACE(JSON_EXTRACT( - JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]'), '].pattern', '].count')) - INTO @index - FROM Job - WHERE jobId = :jobId;"); - $stmt1->bindParam(':pattern', $pattern, PDO::PARAM_STR); - $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); - $stmt1->execute(); - - $helper = $dbh->query("SELECT @index"); - $index = $helper->fetch(PDO::FETCH_ASSOC); - - $incrementQuery = "UPDATE Job - SET logalyzerResults = JSON_SET( - logalyzerResults, - :index, - CAST(CAST( - JSON_UNQUOTE( - JSON_EXTRACT(logalyzerResults, :index) - ) AS UNSIGNED) + :amount AS CHAR)) - WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; - $stmt2 = $dbh->prepare($incrementQuery); - if ($stmt2 === false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); - } - $stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); - $stmt2->bindParam(':pattern', $pattern, PDO::PARAM_STR); - $stmt2->bindParam(':amount', $amount, PDO::PARAM_INT); - $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); - if (!$stmt2->execute()) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); + foreach ($resultCollection as $pattern => $amount) { + $stmt1 = $dbh->prepare("SELECT + JSON_UNQUOTE( + REPLACE(JSON_EXTRACT( + JSON_SEARCH(logalyzerResults, 'one', :pattern), '$[0]'), '].pattern', '].count')) + INTO @index + FROM Job + WHERE jobId = :jobId;"); + $stmt1->bindParam(':pattern', $pattern, PDO::PARAM_STR); + $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); + $stmt1->execute(); + + $helper = $dbh->query("SELECT @index"); + $index = $helper->fetch(PDO::FETCH_ASSOC); + + $incrementQuery = "UPDATE Job + SET logalyzerResults = JSON_SET( + logalyzerResults, + :index, + CAST(CAST( + JSON_UNQUOTE( + JSON_EXTRACT(logalyzerResults, :index) + ) AS UNSIGNED) + :amount AS CHAR)) + WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; + $stmt2 = $dbh->prepare($incrementQuery); + if ($stmt2 === false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); + } + $stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); + $stmt2->bindParam(':pattern', $pattern, PDO::PARAM_STR); + $stmt2->bindParam(':amount', $amount, PDO::PARAM_INT); + $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); + if (!$stmt2->execute()) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); + } } - $dbh->commit(); } catch (PDOException $e) { diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 202e9a03af..7c560e3aea 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -108,7 +108,7 @@ public function examineLogLine($logLine) { $hash = $this->calculateHash(); // Load existing result set $this->results = json_decode($this->job->getLogalyzerResults(), true); - + $resultCollection = []; foreach($this->data['pattern'] as $index => $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; @@ -117,7 +117,7 @@ public function examineLogLine($logLine) { if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $isInResultSet = true; if ($number >= 1) { - Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $pattern['pattern'], $number); + $resultCollection[$pattern] = $number; } } } @@ -130,6 +130,10 @@ public function examineLogLine($logLine) { $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); } + + } + if(!empty($resultCollection)) { + Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); } /*$end = microtime(true); if($logLine == "SendMail\n") { From e40a32d613170ebedcb64404d10dbffe05a00a7b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Thu, 1 Aug 2024 13:32:41 +0200 Subject: [PATCH 531/644] Support for sanityCheck in frontend --- libraries/logalyzer.php | 3 ++- views/job/detail.php | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 7c560e3aea..c0306362e4 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -109,12 +109,13 @@ public function examineLogLine($logLine) { // Load existing result set $this->results = json_decode($this->job->getLogalyzerResults(), true); $resultCollection = []; + $LOG_ERRORS_MAX_ = 10; // TODO change to constant from constants.php foreach($this->data['pattern'] as $index => $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result - if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { + if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] >= $LOG_ERRORS_MAX_) { $isInResultSet = true; if ($number >= 1) { $resultCollection[$pattern] = $number; diff --git a/views/job/detail.php b/views/job/detail.php index 0c580ebad1..a8704dd389 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -237,9 +237,11 @@ function updateProgress() {
- Errors: = 0) { echo($data['logErrorCount']); } ?> + Errors: 10) { echo('> 10'); } + elseif($data['logErrorCount'] >= 0) { echo($data['logErrorCount']); } ?>
- Warnings: = 0) { echo($data['logWarningCount']);} ?> + Warnings: 10) { echo('> 10'); } + elseif($data['logWarningCount'] >= 0) { echo($data['logWarningCount']);} ?>

From 3d689ca450bc3c10b7704384f3131f2144779b01 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Thu, 1 Aug 2024 13:33:35 +0200 Subject: [PATCH 532/644] Support for sanityCheck in frontend --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c0306362e4..f160236528 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -115,7 +115,7 @@ public function examineLogLine($logLine) { $isInResultSet = false; foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result - if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] >= $LOG_ERRORS_MAX_) { + if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] > $LOG_ERRORS_MAX_) { $isInResultSet = true; if ($number >= 1) { $resultCollection[$pattern] = $number; From 2a0faa21376ab1512e3cbb78383a9e04bf589240 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Thu, 1 Aug 2024 17:43:07 +0200 Subject: [PATCH 533/644] Support for sanityCheck in frontend --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index f160236528..94d49909dd 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -109,13 +109,13 @@ public function examineLogLine($logLine) { // Load existing result set $this->results = json_decode($this->job->getLogalyzerResults(), true); $resultCollection = []; - $LOG_ERRORS_MAX_ = 10; // TODO change to constant from constants.php + $LOG_ERRORS_MAX = 100; // TODO change to constant from constants.php foreach($this->data['pattern'] as $index => $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result - if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] > $LOG_ERRORS_MAX_) { + if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] > $LOG_ERRORS_MAX) { $isInResultSet = true; if ($number >= 1) { $resultCollection[$pattern] = $number; From 36752f827a282fdafd496d485f291f8d2e261ee8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Thu, 1 Aug 2024 18:37:22 +0200 Subject: [PATCH 534/644] baseline test for evaluation --- api/v1/job.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index 1ffc817c85..866f2e5aec 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -298,7 +298,7 @@ private function appendLog($id) { mkdir(UPLOADED_DATA_PATH . 'log'); } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); - $logalyzer = new Logalyzer_Library($job); - $logalyzer->examineLogLine($this->request['log']); + //$logalyzer = new Logalyzer_Library($job); + //$logalyzer->examineLogLine($this->request['log']); } } From 146e3d19887b5ee89e99f7f70cd1b69467e66273 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Thu, 1 Aug 2024 18:50:01 +0200 Subject: [PATCH 535/644] baseline test for evaluation --- api/v1/job.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index 866f2e5aec..1ffc817c85 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -298,7 +298,7 @@ private function appendLog($id) { mkdir(UPLOADED_DATA_PATH . 'log'); } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); - //$logalyzer = new Logalyzer_Library($job); - //$logalyzer->examineLogLine($this->request['log']); + $logalyzer = new Logalyzer_Library($job); + $logalyzer->examineLogLine($this->request['log']); } } From 8fffaf94c524f127234da267ead09848f0a54f57 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 2 Aug 2024 21:13:48 +0200 Subject: [PATCH 536/644] fixed typo --- libraries/logalyzer.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 94d49909dd..12045a657b 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -136,13 +136,17 @@ public function examineLogLine($logLine) { if(!empty($resultCollection)) { Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); } - /*$end = microtime(true); - if($logLine == "SendMail\n") { - $this->mailResults(); + if($logLine == "clearLog\n") { + $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId(); + file_put_contents($path, ""); } - else { - $this->logTime($start, $end); - }*/ + /*$end = microtime(true); + if($logLine == "SendMail\n") { + $this->mailResults(); + } + else { + $this->logTime($start, $end); + }*/ } private function mailResults() { $to = "p.buetler@stud.unibas.ch"; From 730c2600d464ac3cc7cd6957b024ab9b57a8a591 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 2 Aug 2024 21:28:51 +0200 Subject: [PATCH 537/644] cleaning up files --- api/v1/job.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index 1ffc817c85..37a1de8aed 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -298,7 +298,11 @@ private function appendLog($id) { mkdir(UPLOADED_DATA_PATH . 'log'); } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); - $logalyzer = new Logalyzer_Library($job); - $logalyzer->examineLogLine($this->request['log']); + if($this->request['log'] == "clearLog") { + $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId(); + file_put_contents($path, ""); + } + #$logalyzer = new Logalyzer_Library($job); + #$logalyzer->examineLogLine($this->request['log']); } } From 6a9cf4dff04a00bee25e45db24cfcea23523d4c0 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 2 Aug 2024 21:30:22 +0200 Subject: [PATCH 538/644] cleaning up files --- api/v1/job.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index 37a1de8aed..9793cf2497 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -299,8 +299,7 @@ private function appendLog($id) { } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); if($this->request['log'] == "clearLog") { - $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId(); - file_put_contents($path, ""); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', ""); } #$logalyzer = new Logalyzer_Library($job); #$logalyzer->examineLogLine($this->request['log']); From a545cbf13a34f9b4c008ccef2c46c0c3e709894e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 2 Aug 2024 21:30:38 +0200 Subject: [PATCH 539/644] cleaning up files --- libraries/logalyzer.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 12045a657b..48dff8d3cb 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -135,10 +135,6 @@ public function examineLogLine($logLine) { } if(!empty($resultCollection)) { Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); - } - if($logLine == "clearLog\n") { - $path = UPLOADED_DATA_PATH . '/log/' . $this->job->getId(); - file_put_contents($path, ""); } /*$end = microtime(true); if($logLine == "SendMail\n") { From e092dd0b7c807f3fb8c0381773313fca0d035b57 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 2 Aug 2024 21:34:50 +0200 Subject: [PATCH 540/644] cleaning up files --- api/v1/job.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/v1/job.php b/api/v1/job.php index 9793cf2497..4bd4986363 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -299,7 +299,10 @@ private function appendLog($id) { } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); if($this->request['log'] == "clearLog") { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', ""); + $fp = fopen("UPLOADED_DATA_PATH . 'log/' . $id . '.log'", "r+"); + ftruncate($fp, 0); + fclose($fp); + # doesnt work file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', ""); } #$logalyzer = new Logalyzer_Library($job); #$logalyzer->examineLogLine($this->request['log']); From aab2267da720414124adc52234c696f6889fef29 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 2 Aug 2024 21:35:42 +0200 Subject: [PATCH 541/644] cleaning up files --- api/v1/job.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/v1/job.php b/api/v1/job.php index 4bd4986363..6086423408 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -299,6 +299,8 @@ private function appendLog($id) { } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); if($this->request['log'] == "clearLog") { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', "clearing log..\n", FILE_APPEND); + $fp = fopen("UPLOADED_DATA_PATH . 'log/' . $id . '.log'", "r+"); ftruncate($fp, 0); fclose($fp); From 7ab81051bff620837581a3100b3f64251f2a7513 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 3 Aug 2024 13:52:34 +0200 Subject: [PATCH 542/644] cleaning up files --- api/v1/job.php | 9 ++------- libraries/dba/AbstractModelFactory.class.php | 1 + 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index 6086423408..f1703b4ab3 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -300,13 +300,8 @@ private function appendLog($id) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); if($this->request['log'] == "clearLog") { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', "clearing log..\n", FILE_APPEND); - - $fp = fopen("UPLOADED_DATA_PATH . 'log/' . $id . '.log'", "r+"); - ftruncate($fp, 0); - fclose($fp); - # doesnt work file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', ""); } - #$logalyzer = new Logalyzer_Library($job); - #$logalyzer->examineLogLine($this->request['log']); + $logalyzer = new Logalyzer_Library($job); + $logalyzer->examineLogLine($this->request['log']); } } diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index ff58b0736a..8e672ba762 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -789,6 +789,7 @@ public function incrementJobCountAtomically($jobId, $resultCollection) { $dbh = self::getDB(); $dbh->beginTransaction(); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($resultCollection), FILE_APPEND); try { foreach ($resultCollection as $pattern => $amount) { $stmt1 = $dbh->prepare("SELECT From 8af85a6019eee0d2abc2c08365f6c704817a7f4a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 3 Aug 2024 13:55:20 +0200 Subject: [PATCH 543/644] cleaning up files --- api/v1/job.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index f1703b4ab3..1ffc817c85 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -298,9 +298,6 @@ private function appendLog($id) { mkdir(UPLOADED_DATA_PATH . 'log'); } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', $this->request['log'], FILE_APPEND); - if($this->request['log'] == "clearLog") { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $id . '.log', "clearing log..\n", FILE_APPEND); - } $logalyzer = new Logalyzer_Library($job); $logalyzer->examineLogLine($this->request['log']); } From 8bd2dc93ff35db0186b8ab6f453ffdebb86a7f8c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 3 Aug 2024 13:55:54 +0200 Subject: [PATCH 544/644] cleaning up files --- libraries/dba/AbstractModelFactory.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 8e672ba762..ff58b0736a 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -789,7 +789,6 @@ public function incrementJobCountAtomically($jobId, $resultCollection) { $dbh = self::getDB(); $dbh->beginTransaction(); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($resultCollection), FILE_APPEND); try { foreach ($resultCollection as $pattern => $amount) { $stmt1 = $dbh->prepare("SELECT From a4fe46c022f2504e3950bff2408aece327227c4f Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 5 Aug 2024 18:16:28 +0200 Subject: [PATCH 545/644] fixed minor bug --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 48dff8d3cb..d90fd78b37 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -205,7 +205,8 @@ public function loadPatterns() { else { // Initial load of patterns returned null $this->createBasicPatterns(); - $this->savePatterns(); + # Saving here is unnecessary and causes server load for no reason + #$this->savePatterns(); } } From f43a45b1fd414724917f640d2fcf097dd621a8f4 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 5 Aug 2024 18:19:59 +0200 Subject: [PATCH 546/644] improved performance with empty pattern set --- libraries/logalyzer.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index d90fd78b37..18a8fd5b47 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -105,9 +105,13 @@ public function examineEntireLog() { */ public function examineLogLine($logLine) { #$start = microtime(true); - $hash = $this->calculateHash(); // Load existing result set - $this->results = json_decode($this->job->getLogalyzerResults(), true); + $json = $this->job->getLogalyzerResults(); + if($json === null) { + return; + } + $this->results = json_decode($json, true); + $hash = $this->calculateHash(); $resultCollection = []; $LOG_ERRORS_MAX = 100; // TODO change to constant from constants.php foreach($this->data['pattern'] as $index => $pattern) { From 307dea403b4f1947197178fc97e86454043e4872 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Fri, 9 Aug 2024 19:29:27 +0200 Subject: [PATCH 547/644] Small fix to check for missing positive patterns if a job has status FAILED --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 1d741cdfe3..69459d94c9 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -238,7 +238,7 @@ function getLogalyzerResponses(evalId) { getJobCountForLogLevel($job, 'warn', 'negative')>=1) { ?> - getStatus() == Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { ?> + getStatus() == Define::JOB_STATUS_FINISHED || $job->getStatus() == Define::JOB_STATUS_FAILED) && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { ?> From 8c4c6cf9d7fdef9f0cf82db31aec681141b29ea9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 10 Aug 2024 21:28:28 +0200 Subject: [PATCH 548/644] removed unnecessary code --- api/ui/job.php | 1 - api/v1/job.php | 1 - 2 files changed, 2 deletions(-) diff --git a/api/ui/job.php b/api/ui/job.php index 3866a5fbf7..61023e3beb 100644 --- a/api/ui/job.php +++ b/api/ui/job.php @@ -38,7 +38,6 @@ public function patch() { $job->setProgress($this->request['progress']); } if(isset($this->request['getLogalyzerResponse'])) { - //echo "working"; $warning = -1; $error = -1; $mandatory = -1; diff --git a/api/v1/job.php b/api/v1/job.php index 1ffc817c85..e7a28b63a7 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -163,7 +163,6 @@ public function patch() { if (empty($this->get['id'])) { throw new Exception('No id provided'); } - echo "Test: do logLine uploads request to this endpoint?"; $auth = Auth_Library::getInstance(); $job = Factory::getJobFactory()->get($this->get['id']); $evaluation = Factory::getEvaluationFactory()->get($job->getEvaluationId()); From 62fd074c23fb53f75f5838aab9b25e8d6fdebfc5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 10 Aug 2024 22:14:03 +0200 Subject: [PATCH 549/644] changed button appearance --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 69459d94c9..2b1ca3a19e 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -210,7 +210,7 @@ function getLogalyzerResponses(evalId) {

Jobs

- +
From f1e9e59fe4ab8e5ae865c0618cd775c31752c033 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:28:01 +0200 Subject: [PATCH 550/644] fixed typo --- libraries/logalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 18a8fd5b47..f5174f46a2 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -113,13 +113,13 @@ public function examineLogLine($logLine) { $this->results = json_decode($json, true); $hash = $this->calculateHash(); $resultCollection = []; - $LOG_ERRORS_MAX = 100; // TODO change to constant from constants.php + $LOG_ERRORS_MAX = 10; // TODO change to constant from constants.php foreach($this->data['pattern'] as $index => $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result - if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] > $LOG_ERRORS_MAX) { + if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { $isInResultSet = true; if ($number >= 1) { $resultCollection[$pattern] = $number; From e082ed9b54f324e7985e5f60da2367e5c1c51408 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:29:52 +0200 Subject: [PATCH 551/644] fixed typo --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index f5174f46a2..c4a47d1d57 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -119,7 +119,7 @@ public function examineLogLine($logLine) { $isInResultSet = false; foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result - if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { + if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { # && $result['count'] < $LOG_ERRORS_MAX sanity check removed $isInResultSet = true; if ($number >= 1) { $resultCollection[$pattern] = $number; From 2cb5d7aadea22088aa124fab4591f4e5da54cfa3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:30:17 +0200 Subject: [PATCH 552/644] fixed typo --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c4a47d1d57..f5174f46a2 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -119,7 +119,7 @@ public function examineLogLine($logLine) { $isInResultSet = false; foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result - if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { # && $result['count'] < $LOG_ERRORS_MAX sanity check removed + if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { $isInResultSet = true; if ($number >= 1) { $resultCollection[$pattern] = $number; From 1090c80d9fee19bb47a7a101b28b9b5b2963555e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:35:19 +0200 Subject: [PATCH 553/644] fixed typo --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index f5174f46a2..57e6cbdb1f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -132,6 +132,7 @@ public function examineLogLine($logLine) { if($this->results['hash'] === "" || $this->results['hash'] === null) { $this->results['hash'] = $hash; } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($pattern, true), FILE_APPEND); $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); } From d00d6e48c14a691428f229c1c8432744cebd2382 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:38:42 +0200 Subject: [PATCH 554/644] fixed typo --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 57e6cbdb1f..7d98680c09 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -126,6 +126,7 @@ public function examineLogLine($logLine) { } } } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $isInResultSet, FILE_APPEND); if(!$isInResultSet) { $pattern['count'] = $number; $this->results['pattern'][] = $pattern; From bfaa8079d99b9b9f1213a7fa296fe829bae6d533 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:42:28 +0200 Subject: [PATCH 555/644] fixed typo --- libraries/logalyzer.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 7d98680c09..4f5a14959f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -106,11 +106,17 @@ public function examineEntireLog() { public function examineLogLine($logLine) { #$start = microtime(true); // Load existing result set - $json = $this->job->getLogalyzerResults(); + $json = $this->system->getLogalyzerPatterns(); if($json === null) { return; } - $this->results = json_decode($json, true); + $results = $this->job->getLogalyzerResults(); + if(isset($results)) { + $this->results = json_decode($results, true); + } + else { + $this->createEmptyJobLogalyzerResults(); + } $hash = $this->calculateHash(); $resultCollection = []; $LOG_ERRORS_MAX = 10; // TODO change to constant from constants.php @@ -126,7 +132,6 @@ public function examineLogLine($logLine) { } } } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $isInResultSet, FILE_APPEND); if(!$isInResultSet) { $pattern['count'] = $number; $this->results['pattern'][] = $pattern; From 1ed1d4e6179649f501024ce24bb16590454c0f12 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:42:53 +0200 Subject: [PATCH 556/644] fixed typo --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4f5a14959f..2a349c2035 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -138,7 +138,7 @@ public function examineLogLine($logLine) { if($this->results['hash'] === "" || $this->results['hash'] === null) { $this->results['hash'] = $hash; } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($pattern, true), FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($pattern, true), FILE_APPEND); # TODO remove me $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); } From 51489da52476a7ffa12db008e24e8d97ad624ec0 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:44:29 +0200 Subject: [PATCH 557/644] fixed typo --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 2a349c2035..d1e16ebe50 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -145,6 +145,7 @@ public function examineLogLine($logLine) { } if(!empty($resultCollection)) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "trying to increment using query", true); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); } /*$end = microtime(true); From c708b2692782cf7d028872fbeaf6931c361a804c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:46:30 +0200 Subject: [PATCH 558/644] fixed typo --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index d1e16ebe50..23247b5700 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -127,6 +127,7 @@ public function examineLogLine($logLine) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { $isInResultSet = true; + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "found in result set", true); if ($number >= 1) { $resultCollection[$pattern] = $number; } From b56267d2845faba322b81ffa63b11679bef89f3e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:47:59 +0200 Subject: [PATCH 559/644] fixed typo --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 23247b5700..7e9ff98573 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -127,7 +127,7 @@ public function examineLogLine($logLine) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { $isInResultSet = true; - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "found in result set", true); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "found in result set", FILE_APPEND); if ($number >= 1) { $resultCollection[$pattern] = $number; } From a451f2f487c47dd0bf6a7a577d5941c6439e194e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:56:54 +0200 Subject: [PATCH 560/644] fixed typo --- libraries/logalyzer.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 7e9ff98573..4efe838904 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -130,6 +130,9 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "found in result set", FILE_APPEND); if ($number >= 1) { $resultCollection[$pattern] = $number; + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n adding to resultCollection\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); + } } } @@ -145,8 +148,12 @@ public function examineLogLine($logLine) { } } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nlogLine processed, resultCollection is now:\n", FILE_APPEND); + + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); + if(!empty($resultCollection)) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "trying to increment using query", true); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\ntrying to increment using query\n", true); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); } /*$end = microtime(true); From 83c5239380fd74a48a160d91edb7d700b7073014 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 13 Aug 2024 23:58:46 +0200 Subject: [PATCH 561/644] fixed typo --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 4efe838904..90436dc484 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -127,7 +127,8 @@ public function examineLogLine($logLine) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { $isInResultSet = true; - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "found in result set", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "found in result set. number is: ", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $number, FILE_APPEND); if ($number >= 1) { $resultCollection[$pattern] = $number; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n adding to resultCollection\n", FILE_APPEND); From 81d9c26325b6fcffd8c58a180f2e4acdf9747ab6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:00:06 +0200 Subject: [PATCH 562/644] fixed typo --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 90436dc484..c89ec49092 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -130,6 +130,7 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "found in result set. number is: ", FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $number, FILE_APPEND); if ($number >= 1) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n number is broken!?".$number, FILE_APPEND); $resultCollection[$pattern] = $number; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n adding to resultCollection\n", FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); From 969e2fc41d55b0b4264374ff27b9aeb3a6516748 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:02:36 +0200 Subject: [PATCH 563/644] fixed typo --- libraries/logalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c89ec49092..82760a85aa 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -131,7 +131,8 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $number, FILE_APPEND); if ($number >= 1) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n number is broken!?".$number, FILE_APPEND); - $resultCollection[$pattern] = $number; + $pattern['count'] = $number; + $resultCollection[] = $pattern; file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n adding to resultCollection\n", FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); From 295e78b5910f46c81b1e00a405905452f9d3fc61 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:03:53 +0200 Subject: [PATCH 564/644] fixed typo --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 82760a85aa..1482be177b 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -156,7 +156,7 @@ public function examineLogLine($logLine) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); if(!empty($resultCollection)) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\ntrying to increment using query\n", true); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\ntrying to increment using query\n", FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); } /*$end = microtime(true); From 4b7b628a7d0f0a66bc2c52ef6b62b0977f5dcdd3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:05:57 +0200 Subject: [PATCH 565/644] fixed typo --- libraries/logalyzer.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 1482be177b..a92706271e 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -127,15 +127,10 @@ public function examineLogLine($logLine) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { $isInResultSet = true; - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "found in result set. number is: ", FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', $number, FILE_APPEND); if ($number >= 1) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n number is broken!?".$number, FILE_APPEND); $pattern['count'] = $number; $resultCollection[] = $pattern; - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n adding to resultCollection\n", FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); - } } } @@ -145,16 +140,10 @@ public function examineLogLine($logLine) { if($this->results['hash'] === "" || $this->results['hash'] === null) { $this->results['hash'] = $hash; } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($pattern, true), FILE_APPEND); # TODO remove me $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); } - } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nlogLine processed, resultCollection is now:\n", FILE_APPEND); - - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); - if(!empty($resultCollection)) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\ntrying to increment using query\n", FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); From 6d34d02744ca53b43ddaadf8d4a2525d7e703de7 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:06:32 +0200 Subject: [PATCH 566/644] fixed typo --- libraries/logalyzer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index a92706271e..e12e980e6b 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -128,7 +128,6 @@ public function examineLogLine($logLine) { if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { $isInResultSet = true; if ($number >= 1) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\n number is broken!?".$number, FILE_APPEND); $pattern['count'] = $number; $resultCollection[] = $pattern; } From 65698ef116e5ceb18bc56914faa5961e7236b767 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:14:58 +0200 Subject: [PATCH 567/644] fixed typo --- libraries/logalyzer.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e12e980e6b..a692490b5b 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -110,13 +110,14 @@ public function examineLogLine($logLine) { if($json === null) { return; } - $results = $this->job->getLogalyzerResults(); - if(isset($results)) { - $this->results = json_decode($results, true); - } - else { - $this->createEmptyJobLogalyzerResults(); - } + #$results = $this->job->getLogalyzerResults(); + #if(isset($results)) { + # $this->results = json_decode($results, true); + #} + #else { + # $this->createEmptyJobLogalyzerResults(); + #} + $this->createEmptyJobLogalyzerResults(); $hash = $this->calculateHash(); $resultCollection = []; $LOG_ERRORS_MAX = 10; // TODO change to constant from constants.php From bc6bcc8d672a3caeffb05fb5cff0dc7d73735dcc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:25:42 +0200 Subject: [PATCH 568/644] fixed typo --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index a692490b5b..6f53ae10dd 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -147,6 +147,7 @@ public function examineLogLine($logLine) { if(!empty($resultCollection)) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\ntrying to increment using query\n", FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); + Factory::getJobFactory()->update($this->job); } /*$end = microtime(true); if($logLine == "SendMail\n") { From e022b9465246a38e08ef899cf91bf57c426ff423 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:28:06 +0200 Subject: [PATCH 569/644] fixed typo --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 6f53ae10dd..af03b9c85b 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -131,6 +131,8 @@ public function examineLogLine($logLine) { if ($number >= 1) { $pattern['count'] = $number; $resultCollection[] = $pattern; + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nadded to resultCollection\n", FILE_APPEND); + } } } From f88c9294070ac749f1ac1dc833d4440d7faab112 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:33:53 +0200 Subject: [PATCH 570/644] fixed typo --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index af03b9c85b..92c791f213 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -124,6 +124,7 @@ public function examineLogLine($logLine) { foreach($this->data['pattern'] as $index => $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { From c12fdf7505d72fe9faf9eefac494bcbc80723afa Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:36:26 +0200 Subject: [PATCH 571/644] fixed typo --- libraries/logalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 92c791f213..23f2233954 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -138,6 +138,7 @@ public function examineLogLine($logLine) { } } if(!$isInResultSet) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nnot in result set adding\n".$number, FILE_APPEND); $pattern['count'] = $number; $this->results['pattern'][] = $pattern; if($this->results['hash'] === "" || $this->results['hash'] === null) { From 4ed52e03a822a98f8656bb61fd6c4f1d6b469ea2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:37:53 +0200 Subject: [PATCH 572/644] fixed typo --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 23f2233954..3cadfb407d 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -144,6 +144,8 @@ public function examineLogLine($logLine) { if($this->results['hash'] === "" || $this->results['hash'] === null) { $this->results['hash'] = $hash; } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); + $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); } From efef8af7b042c1608256e94d4a62f5c352edafcb Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:46:53 +0200 Subject: [PATCH 573/644] fixed typo --- libraries/logalyzer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 3cadfb407d..de547a0de2 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -8,7 +8,7 @@ * Results are shown inside a job's detail page */ class Logalyzer_Library { - private $job; + private DBA\Job $job; private $system; private $log; private $data; @@ -145,7 +145,6 @@ public function examineLogLine($logLine) { $this->results['hash'] = $hash; } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); - $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); } From 340596ebfedf02ae961480045cf82c4a549781cc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:49:42 +0200 Subject: [PATCH 574/644] fixed typo --- libraries/logalyzer.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 3cadfb407d..b44b8bcb8f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -117,7 +117,13 @@ public function examineLogLine($logLine) { #else { # $this->createEmptyJobLogalyzerResults(); #} - $this->createEmptyJobLogalyzerResults(); + $json = $this->job->getLogalyzerResults(); + if($json === null) { + $this->createEmptyJobLogalyzerResults(); + } + else { + $this->results = json_decode($json, true); + } $hash = $this->calculateHash(); $resultCollection = []; $LOG_ERRORS_MAX = 10; // TODO change to constant from constants.php From ac899eb00bbdf46abad7a95f483c07197588612d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:52:58 +0200 Subject: [PATCH 575/644] fixed typo --- libraries/logalyzer.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b44b8bcb8f..c8bc6dbe66 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -130,7 +130,7 @@ public function examineLogLine($logLine) { foreach($this->data['pattern'] as $index => $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); + #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); foreach($this->results['pattern'] as $result) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { @@ -150,14 +150,16 @@ public function examineLogLine($logLine) { if($this->results['hash'] === "" || $this->results['hash'] === null) { $this->results['hash'] = $hash; } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); + #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); } } if(!empty($resultCollection)) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\ntrying to increment using query\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\ntrying to increment using query given\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); + Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); Factory::getJobFactory()->update($this->job); } From c588772786169128530050a6ddcdfa945505eb3b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:54:17 +0200 Subject: [PATCH 576/644] fixed typo --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c8bc6dbe66..b3fb139df2 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -158,7 +158,7 @@ public function examineLogLine($logLine) { } if(!empty($resultCollection)) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\ntrying to increment using query given\n", FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); + #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); Factory::getJobFactory()->update($this->job); From 6b11b1529fbfe01f0a907c4da8c60f948d31db69 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 00:57:00 +0200 Subject: [PATCH 577/644] fixed typo --- libraries/dba/AbstractModelFactory.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index ff58b0736a..64113dd994 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -790,7 +790,7 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $dbh = self::getDB(); $dbh->beginTransaction(); try { - foreach ($resultCollection as $pattern => $amount) { + foreach ($resultCollection as $pattern) { $stmt1 = $dbh->prepare("SELECT JSON_UNQUOTE( REPLACE(JSON_EXTRACT( @@ -798,7 +798,7 @@ public function incrementJobCountAtomically($jobId, $resultCollection) INTO @index FROM Job WHERE jobId = :jobId;"); - $stmt1->bindParam(':pattern', $pattern, PDO::PARAM_STR); + $stmt1->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); $stmt1->execute(); @@ -819,8 +819,8 @@ public function incrementJobCountAtomically($jobId, $resultCollection) file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); } $stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); - $stmt2->bindParam(':pattern', $pattern, PDO::PARAM_STR); - $stmt2->bindParam(':amount', $amount, PDO::PARAM_INT); + $stmt2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); + $stmt2->bindParam(':amount', $pattern['count'], PDO::PARAM_INT); $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); if (!$stmt2->execute()) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); From a908a9b2bd0b529e8585450daa522b84223c23bc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:00:28 +0200 Subject: [PATCH 578/644] fixed typo --- libraries/dba/AbstractModelFactory.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 64113dd994..cbb44b83ba 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -787,6 +787,7 @@ public function getDB($test = false) { */ public function incrementJobCountAtomically($jobId, $resultCollection) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($resultCollection, true), FILE_APPEND); $dbh = self::getDB(); $dbh->beginTransaction(); try { @@ -826,8 +827,11 @@ public function incrementJobCountAtomically($jobId, $resultCollection) file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); } } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "created all queries\n", FILE_APPEND); $dbh->commit(); - } + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "commited\n", FILE_APPEND); + + } catch (PDOException $e) { $dbh->rollback(); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $e->getMessage(), FILE_APPEND); From 5b40056970fda86a0a14a571cc10ae1c688cdb07 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:05:24 +0200 Subject: [PATCH 579/644] fixed typo --- libraries/dba/AbstractModelFactory.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index cbb44b83ba..7faebb66b9 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -801,8 +801,13 @@ public function incrementJobCountAtomically($jobId, $resultCollection) WHERE jobId = :jobId;"); $stmt1->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); - $stmt1->execute(); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 1: " . var_export($stmt1->queryString, true) . "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: pattern=" . $pattern['pattern'] . ", jobId=" . $jobId . "\n", FILE_APPEND); + + if (!$stmt1->execute()) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute() for Query 1\n", FILE_APPEND); + } $helper = $dbh->query("SELECT @index"); $index = $helper->fetch(PDO::FETCH_ASSOC); From f95b0776e476435d840ce256dc64702e4f484942 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:09:24 +0200 Subject: [PATCH 580/644] fixed typo --- libraries/dba/AbstractModelFactory.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 7faebb66b9..04eb8d2aa7 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -810,6 +810,7 @@ public function incrementJobCountAtomically($jobId, $resultCollection) } $helper = $dbh->query("SELECT @index"); $index = $helper->fetch(PDO::FETCH_ASSOC); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Index is ".$index['@index']."\n", FILE_APPEND); $incrementQuery = "UPDATE Job SET logalyzerResults = JSON_SET( @@ -821,8 +822,11 @@ public function incrementJobCountAtomically($jobId, $resultCollection) ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); - if ($stmt2 === false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare()\n", FILE_APPEND); + if ($stmt2 !== false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 2: " . var_export($stmt2->queryString, true) . "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: index=" . $index['@index'] . ", amount=" . $pattern['count'] . ", jobId=" . $jobId . ", pattern=" . $pattern['pattern'] . "\n", FILE_APPEND); + } else { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare() for Query 2\n", FILE_APPEND); } $stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); $stmt2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); From 875e66a5998c000f174bc2b46b2375ae5f474194 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:10:15 +0200 Subject: [PATCH 581/644] fixed typo --- libraries/logalyzer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b3fb139df2..c30a08404f 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -144,7 +144,6 @@ public function examineLogLine($logLine) { } } if(!$isInResultSet) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nnot in result set adding\n".$number, FILE_APPEND); $pattern['count'] = $number; $this->results['pattern'][] = $pattern; if($this->results['hash'] === "" || $this->results['hash'] === null) { From ae68f5ae4df5f3bc8d6da04b759a10139bbfa6ff Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:22:46 +0200 Subject: [PATCH 582/644] fixed typo --- libraries/dba/AbstractModelFactory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 04eb8d2aa7..0eb75e4f56 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -816,10 +816,10 @@ public function incrementJobCountAtomically($jobId, $resultCollection) SET logalyzerResults = JSON_SET( logalyzerResults, :index, - CAST(CAST( + JSON_QUOTE(CAST(CAST( JSON_UNQUOTE( JSON_EXTRACT(logalyzerResults, :index) - ) AS UNSIGNED) + :amount AS CHAR)) + ) AS UNSIGNED) + :amount AS CHAR))) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); if ($stmt2 !== false) { From f9a2362032a382c5496d82286dccbaae64b1f6a6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:28:01 +0200 Subject: [PATCH 583/644] fixed typo --- libraries/dba/AbstractModelFactory.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 0eb75e4f56..a1fa1ddca6 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -787,9 +787,10 @@ public function getDB($test = false) { */ public function incrementJobCountAtomically($jobId, $resultCollection) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($resultCollection, true), FILE_APPEND); + $json = Factory::getJobFactory()->get($jobId)->getLogalyzerResults(); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($json, true), FILE_APPEND); $dbh = self::getDB(); - $dbh->beginTransaction(); + #$dbh->beginTransaction(); try { foreach ($resultCollection as $pattern) { $stmt1 = $dbh->prepare("SELECT @@ -837,7 +838,7 @@ public function incrementJobCountAtomically($jobId, $resultCollection) } } file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "created all queries\n", FILE_APPEND); - $dbh->commit(); + #$dbh->commit(); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "commited\n", FILE_APPEND); } From c0bfb0bfcbdd89765cbf2fc9dbcda9efa64e09b9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:41:57 +0200 Subject: [PATCH 584/644] changed json to be 'result':[{}] --- libraries/logalyzer.php | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c30a08404f..eb225bc3a1 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -77,10 +77,10 @@ public function examineEntireLog() { $this->createEmptyJobLogalyzerResults(); $hash = $this->calculateHash(); - foreach($this->data['pattern'] as $pattern) { - $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); + foreach($this->data['result'] as $pattern) { + $number = $this->countLogOccurances($pattern['result'], $this->log, $pattern['regex']); $found = false; - foreach($this->results['pattern'] as $result) { + foreach($this->results['result'] as $result) { //print_r($result); if(isset($result['logLevel'],$result['pattern'],$result['regex'],$result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $result['count'] += $number; @@ -90,7 +90,7 @@ public function examineEntireLog() { if(!$found) { $pattern['count'] = $number; //print_r($pattern); - $this->results['pattern'][] = $pattern; + $this->results['result'][] = $pattern; } } $this->results['hash'] = $hash; @@ -127,11 +127,11 @@ public function examineLogLine($logLine) { $hash = $this->calculateHash(); $resultCollection = []; $LOG_ERRORS_MAX = 10; // TODO change to constant from constants.php - foreach($this->data['pattern'] as $index => $pattern) { + foreach($this->data['result'] as $index => $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); - foreach($this->results['pattern'] as $result) { + foreach($this->results['result'] as $result) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { $isInResultSet = true; @@ -145,7 +145,7 @@ public function examineLogLine($logLine) { } if(!$isInResultSet) { $pattern['count'] = $number; - $this->results['pattern'][] = $pattern; + $this->results['result'][] = $pattern; if($this->results['hash'] === "" || $this->results['hash'] === null) { $this->results['hash'] = $hash; } @@ -191,7 +191,7 @@ private function logTime($start, $end) { */ private function createBasicPatterns() { $this->data['hash'] = ""; - $this->data['pattern'] = array(); + $this->data['result'] = array(); } /** @@ -206,10 +206,10 @@ public function getPatterns(string $logLevel, string $type) { $this->createBasicPatterns(); } if ($logLevel === 'all') { - return $this->data['pattern']; + return $this->data['result']; } else { $temp = []; - foreach ($this->data['pattern'] as $pattern) { + foreach ($this->data['result'] as $pattern) { if ($pattern['logLevel'] == $logLevel && $pattern['type'] == $type) { $temp[] = $pattern; } @@ -242,7 +242,7 @@ public function loadPatterns() { * @return void */ private function savePatterns() { - $this->data['hash'] = hash('sha1', json_encode($this->data['pattern'])); + $this->data['hash'] = hash('sha1', json_encode($this->data['result'])); $this->system->setLogalyzerPatterns(json_encode($this->data)); Factory::getSystemFactory()->update($this->system); } @@ -259,8 +259,8 @@ public function addKey(string $logLevel, string $pattern, string $regex, string } else { $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => $regex, 'type' => $type); - if(!in_array($array, $this->data['pattern'])) { - $this->data['pattern'][] = $array; + if(!in_array($array, $this->data['result'])) { + $this->data['result'][] = $array; $this->savePatterns(); } } @@ -278,16 +278,16 @@ public function removeKey(string $logLevel, string $pattern, string $type) { } else { $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => 'string', 'type' => $type); - if(in_array($array, $this->data['pattern'])) { - $index = array_search($array, $this->data['pattern']); - unset($this->data['pattern'][$index]); + if(in_array($array, $this->data['result'])) { + $index = array_search($array, $this->data['result']); + unset($this->data['result'][$index]); $this->savePatterns(); } else { $array['regex'] = 'regex'; - if(in_array($array, $this->data['pattern'])) { - $index = array_search($array, $this->data['pattern']); - unset($this->data['pattern'][$index]); + if(in_array($array, $this->data['result'])) { + $index = array_search($array, $this->data['result']); + unset($this->data['result'][$index]); $this->savePatterns(); } } @@ -300,13 +300,13 @@ public function removeKey(string $logLevel, string $pattern, string $type) { */ private function createEmptyJobLogalyzerResults() { $this->results['hash'] = ""; - $this->results['pattern'] = array(); + $this->results['result'] = array(); } /** * @return string */ function calculateHash() { - return hash('sha1', json_encode($this->data['pattern'])); + return hash('sha1', json_encode($this->data['result'])); } } From ea4ff5770164643a769cb243aabd70b80792db3c Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:45:57 +0200 Subject: [PATCH 585/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index a1fa1ddca6..baf473f45c 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -902,7 +902,7 @@ public function logalyzerUpdateHash($jobId, $hash) { public function getJobCountForLogLevel($job, $logLevel, $type) { if($job->getLogalyzerResults() != null) { $json = json_decode($job->getLogalyzerResults(), true); - $resultArray = $json['pattern']; + $resultArray = $json['result']; $count = 0; foreach ($resultArray as $element) { if ($type === 'negative' && $element['type'] === 'negative' && $element['logLevel'] === $logLevel) { From eefc5ba150867c7a02578c6ed17a797036e91ca9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:47:02 +0200 Subject: [PATCH 586/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index baf473f45c..57943a8f16 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -817,10 +817,10 @@ public function incrementJobCountAtomically($jobId, $resultCollection) SET logalyzerResults = JSON_SET( logalyzerResults, :index, - JSON_QUOTE(CAST(CAST( + CAST(CAST( JSON_UNQUOTE( JSON_EXTRACT(logalyzerResults, :index) - ) AS UNSIGNED) + :amount AS CHAR))) + ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); if ($stmt2 !== false) { From 6d76c0e74c50f26254e91c6f8b678aa76629f1ef Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:48:07 +0200 Subject: [PATCH 587/644] changed json to be 'result':[{}] --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index eb225bc3a1..5be233fd85 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -78,7 +78,7 @@ public function examineEntireLog() { $hash = $this->calculateHash(); foreach($this->data['result'] as $pattern) { - $number = $this->countLogOccurances($pattern['result'], $this->log, $pattern['regex']); + $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); $found = false; foreach($this->results['result'] as $result) { //print_r($result); From 071db29d37046fa8963ec13e7931dbf2bb1b998b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 01:56:44 +0200 Subject: [PATCH 588/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 57943a8f16..2d5c1e353f 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -816,10 +816,10 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $incrementQuery = "UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, - :index, + JSON_QUOTE(:index), CAST(CAST( JSON_UNQUOTE( - JSON_EXTRACT(logalyzerResults, :index) + JSON_EXTRACT(logalyzerResults, JSON_QUOTE(:index)) ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; $stmt2 = $dbh->prepare($incrementQuery); From a25873a7a5a8e6dcddf2d7c7e4da30c04b9a40bc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:03:07 +0200 Subject: [PATCH 589/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 32 +++++++++----------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 2d5c1e353f..baa05c3dca 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -813,34 +813,32 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $index = $helper->fetch(PDO::FETCH_ASSOC); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Index is ".$index['@index']."\n", FILE_APPEND); - $incrementQuery = "UPDATE Job - SET logalyzerResults = JSON_SET( - logalyzerResults, - JSON_QUOTE(:index), - CAST(CAST( - JSON_UNQUOTE( - JSON_EXTRACT(logalyzerResults, JSON_QUOTE(:index)) - ) AS UNSIGNED) + :amount AS CHAR)) - WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"; - $stmt2 = $dbh->prepare($incrementQuery); + $getValueQuery = "SELECT * WHERE jobId"; + + + $stmt2 = $dbh->prepare("UPDATE Job + SET logalyzerResults = JSON_SET( + logalyzerResults, + JSON_QUOTE(:index), + CAST(CAST( + JSON_UNQUOTE( + JSON_EXTRACT(logalyzerResults, JSON_QUOTE(:index)) + ) AS UNSIGNED) + :amount AS CHAR)) + WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); if ($stmt2 !== false) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 2: " . var_export($stmt2->queryString, true) . "\n", FILE_APPEND); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: index=" . $index['@index'] . ", amount=" . $pattern['count'] . ", jobId=" . $jobId . ", pattern=" . $pattern['pattern'] . "\n", FILE_APPEND); - } else { + } else { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare() for Query 2\n", FILE_APPEND); - } + } $stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); $stmt2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); $stmt2->bindParam(':amount', $pattern['count'], PDO::PARAM_INT); $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); if (!$stmt2->execute()) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); } } - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "created all queries\n", FILE_APPEND); - #$dbh->commit(); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "commited\n", FILE_APPEND); - } catch (PDOException $e) { $dbh->rollback(); From 7b7460d143f39f0dac9ce2b18e628e2ebc2a5e12 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:07:41 +0200 Subject: [PATCH 590/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 38 +++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index baa05c3dca..45e3735fb2 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -803,8 +803,8 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $stmt1->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 1: " . var_export($stmt1->queryString, true) . "\n", FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: pattern=" . $pattern['pattern'] . ", jobId=" . $jobId . "\n", FILE_APPEND); + #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 1: " . var_export($stmt1->queryString, true) . "\n", FILE_APPEND); + #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: pattern=" . $pattern['pattern'] . ", jobId=" . $jobId . "\n", FILE_APPEND); if (!$stmt1->execute()) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute() for Query 1\n", FILE_APPEND); @@ -813,8 +813,12 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $index = $helper->fetch(PDO::FETCH_ASSOC); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Index is ".$index['@index']."\n", FILE_APPEND); - $getValueQuery = "SELECT * WHERE jobId"; - + $checker = $dbh->prepare("SELECT * WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); + $checker->bindParam(':jobId', $jobId, PDO::PARAM_INT); + $checker->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); + $checker->execute(); + $fetch = $checker->fetch(PDO::FETCH_ASSOC); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($fetch, true)."\n", FILE_APPEND); $stmt2 = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( @@ -825,19 +829,19 @@ public function incrementJobCountAtomically($jobId, $resultCollection) JSON_EXTRACT(logalyzerResults, JSON_QUOTE(:index)) ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); - if ($stmt2 !== false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 2: " . var_export($stmt2->queryString, true) . "\n", FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: index=" . $index['@index'] . ", amount=" . $pattern['count'] . ", jobId=" . $jobId . ", pattern=" . $pattern['pattern'] . "\n", FILE_APPEND); - } else { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare() for Query 2\n", FILE_APPEND); - } - $stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); - $stmt2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); - $stmt2->bindParam(':amount', $pattern['count'], PDO::PARAM_INT); - $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); - if (!$stmt2->execute()) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); - } + #if ($stmt2 !== false) { + #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 2: " . var_export($stmt2->queryString, true) . "\n", FILE_APPEND); + #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: index=" . $index['@index'] . ", amount=" . $pattern['count'] . ", jobId=" . $jobId . ", pattern=" . $pattern['pattern'] . "\n", FILE_APPEND); + # } else { + #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare() for Query 2\n", FILE_APPEND); + # } + #$stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); + #$stmt2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); + #$stmt2->bindParam(':amount', $pattern['count'], PDO::PARAM_INT); + #$stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); + #if (!$stmt2->execute()) { + # file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); + #} } } catch (PDOException $e) { From 8e22f50eec3ba5c2173ba754240145395e0ee3fe Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:10:18 +0200 Subject: [PATCH 591/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 45e3735fb2..edbd08db6b 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -811,9 +811,9 @@ public function incrementJobCountAtomically($jobId, $resultCollection) } $helper = $dbh->query("SELECT @index"); $index = $helper->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "Index is ".$index['@index']."\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nIndex is ".$index['@index']."\n", FILE_APPEND); - $checker = $dbh->prepare("SELECT * WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); + $checker = $dbh->prepare("SELECT * FROM Job WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); $checker->bindParam(':jobId', $jobId, PDO::PARAM_INT); $checker->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); $checker->execute(); From b9d1396c0fa4acd73a815764ca3a947d788407fe Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:17:29 +0200 Subject: [PATCH 592/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index edbd08db6b..651e006a97 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -813,13 +813,23 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $index = $helper->fetch(PDO::FETCH_ASSOC); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nIndex is ".$index['@index']."\n", FILE_APPEND); - $checker = $dbh->prepare("SELECT * FROM Job WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); + $checker = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( + logalyzerResults, '$.result[0].count', 5) + WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); $checker->bindParam(':jobId', $jobId, PDO::PARAM_INT); $checker->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); $checker->execute(); $fetch = $checker->fetch(PDO::FETCH_ASSOC); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($fetch, true)."\n", FILE_APPEND); + $checker2 = $dbh->prepare("SELECT * FROM Job WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); + $checker2->bindParam(':jobId', $jobId, PDO::PARAM_INT); + $checker2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); + $checker2->execute(); + $fetch2 = $checker2->fetch(PDO::FETCH_ASSOC); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($fetch2, true)."\n", FILE_APPEND); + + $stmt2 = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, From 1097ad4a2269fb87c966f34db6c90a1f3eb5aaa5 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:22:54 +0200 Subject: [PATCH 593/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 651e006a97..1e9a6350ed 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -814,13 +814,11 @@ public function incrementJobCountAtomically($jobId, $resultCollection) file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nIndex is ".$index['@index']."\n", FILE_APPEND); $checker = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( - logalyzerResults, '$.result[0].count', 5) + logalyzerResults, '$.result[0].count', 66) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); $checker->bindParam(':jobId', $jobId, PDO::PARAM_INT); $checker->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); $checker->execute(); - $fetch = $checker->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($fetch, true)."\n", FILE_APPEND); $checker2 = $dbh->prepare("SELECT * FROM Job WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); $checker2->bindParam(':jobId', $jobId, PDO::PARAM_INT); From bbb0225cdba34276e9404ea884ec22188af81008 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:24:46 +0200 Subject: [PATCH 594/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 1e9a6350ed..60d8554aec 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -853,7 +853,7 @@ public function incrementJobCountAtomically($jobId, $resultCollection) } } catch (PDOException $e) { - $dbh->rollback(); + #$dbh->rollback(); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', $e->getMessage(), FILE_APPEND); } } From 2b8b6823ec4da4e799ab9a0c54f9446091343b1a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:26:06 +0200 Subject: [PATCH 595/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 60d8554aec..bdef144cb5 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -850,6 +850,7 @@ public function incrementJobCountAtomically($jobId, $resultCollection) #if (!$stmt2->execute()) { # file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); #} + Factory::getJobFactory()->update(Factory::getJobFactory()->get($jobId)); } } catch (PDOException $e) { From 722b29c1f2be6621a69f34075906a4830a35a59b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:26:56 +0200 Subject: [PATCH 596/644] changed json to be 'result':[{}] --- controllers/job.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/job.php b/controllers/job.php index 85d76c890f..18db34c839 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -148,7 +148,7 @@ public function detail() { $logalyzer->examineEntireLog(); } - + echo print_r($job->getLogalyzerResults(), true); $this->view->assign('logWarningCount', Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative')); $this->view->assign('logErrorCount', Factory::getJobFactory()->getJobCountForLogLevel($job, 'error', 'negative')); if($job->getStatus()==Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { From 1609cf22b6da4b12aad22be87e74faf4c50c03bc Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:29:47 +0200 Subject: [PATCH 597/644] changed json to be 'result':[{}] --- libraries/logalyzer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 5be233fd85..c2c49418bb 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -144,6 +144,8 @@ public function examineLogLine($logLine) { } } if(!$isInResultSet) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nATTENTION RESETTING VALUE\n", FILE_APPEND); + $pattern['count'] = $number; $this->results['result'][] = $pattern; if($this->results['hash'] === "" || $this->results['hash'] === null) { From 9548e7780a57ee7ee729dd3a6603c1523523a3db Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:35:32 +0200 Subject: [PATCH 598/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 3 +-- libraries/logalyzer.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index bdef144cb5..0fb9ab1100 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -790,7 +790,6 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $json = Factory::getJobFactory()->get($jobId)->getLogalyzerResults(); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($json, true), FILE_APPEND); $dbh = self::getDB(); - #$dbh->beginTransaction(); try { foreach ($resultCollection as $pattern) { $stmt1 = $dbh->prepare("SELECT @@ -850,7 +849,7 @@ public function incrementJobCountAtomically($jobId, $resultCollection) #if (!$stmt2->execute()) { # file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); #} - Factory::getJobFactory()->update(Factory::getJobFactory()->get($jobId)); + #Factory::getJobFactory()->update(Factory::getJobFactory()->get($jobId)); } } catch (PDOException $e) { diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index c2c49418bb..e0f2a9f72b 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -162,7 +162,7 @@ public function examineLogLine($logLine) { #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); - Factory::getJobFactory()->update($this->job); + #Factory::getJobFactory()->update($this->job); } /*$end = microtime(true); if($logLine == "SendMail\n") { From 0943a42660035d0d239b0a3431961d02a80b7410 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:42:07 +0200 Subject: [PATCH 599/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 0fb9ab1100..1583e6f23a 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -915,8 +915,9 @@ public function getJobCountForLogLevel($job, $logLevel, $type) { $resultArray = $json['result']; $count = 0; foreach ($resultArray as $element) { - if ($type === 'negative' && $element['type'] === 'negative' && $element['logLevel'] === $logLevel) { - $count += $element['count']; + if ($type === "negative" && $element["type"] === "negative" && $element["logLevel"] === $logLevel) { + echo $element["count"] . 'for logLevel ' . $logLevel . "\n"; + $count += $element["count"]; } } return $count; From 15b2b31ff1fc207c939e4189c9efa597ea330703 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:45:26 +0200 Subject: [PATCH 600/644] changed json to be 'result':[{}] --- controllers/job.php | 4 +++- libraries/dba/AbstractModelFactory.class.php | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 18db34c839..5c4e18abc7 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -149,7 +149,9 @@ public function detail() { } echo print_r($job->getLogalyzerResults(), true); - $this->view->assign('logWarningCount', Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative')); + $warnCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative'); + $this->view->assign('logWarningCount', $warnCount); + echo 'Warn count is: '. $warnCount; $this->view->assign('logErrorCount', Factory::getJobFactory()->getJobCountForLogLevel($job, 'error', 'negative')); if($job->getStatus()==Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { $this->view->assign('logContainsMandatory', 0); diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 1583e6f23a..2acdeea880 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -916,7 +916,6 @@ public function getJobCountForLogLevel($job, $logLevel, $type) { $count = 0; foreach ($resultArray as $element) { if ($type === "negative" && $element["type"] === "negative" && $element["logLevel"] === $logLevel) { - echo $element["count"] . 'for logLevel ' . $logLevel . "\n"; $count += $element["count"]; } } From cda9b1f12d68bb242f3bbf9ffab3cf24488e6329 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:46:16 +0200 Subject: [PATCH 601/644] changed json to be 'result':[{}] --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index a8704dd389..bd03715cc8 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -240,7 +240,7 @@ function updateProgress() { Errors: 10) { echo('> 10'); } elseif($data['logErrorCount'] >= 0) { echo($data['logErrorCount']); } ?>
- Warnings: 10) { echo('> 10'); } + Warnings: 10) { echo('> 10'); } elseif($data['logWarningCount'] >= 0) { echo($data['logWarningCount']);} ?>
From 55e54987629368e04e561ccd943ddc912d1417e1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:46:56 +0200 Subject: [PATCH 602/644] changed json to be 'result':[{}] --- controllers/job.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 5c4e18abc7..13bc56c932 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -148,10 +148,7 @@ public function detail() { $logalyzer->examineEntireLog(); } - echo print_r($job->getLogalyzerResults(), true); - $warnCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative'); - $this->view->assign('logWarningCount', $warnCount); - echo 'Warn count is: '. $warnCount; + $this->view->assign('logWarningCount', Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative')); $this->view->assign('logErrorCount', Factory::getJobFactory()->getJobCountForLogLevel($job, 'error', 'negative')); if($job->getStatus()==Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { $this->view->assign('logContainsMandatory', 0); From cb2f6c9334b9f5c1bbc4d647bed57a44c157324a Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:49:26 +0200 Subject: [PATCH 603/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 43 ++++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 2acdeea880..a859576a63 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -819,14 +819,6 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $checker->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); $checker->execute(); - $checker2 = $dbh->prepare("SELECT * FROM Job WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); - $checker2->bindParam(':jobId', $jobId, PDO::PARAM_INT); - $checker2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); - $checker2->execute(); - $fetch2 = $checker2->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($fetch2, true)."\n", FILE_APPEND); - - $stmt2 = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, @@ -836,20 +828,27 @@ public function incrementJobCountAtomically($jobId, $resultCollection) JSON_EXTRACT(logalyzerResults, JSON_QUOTE(:index)) ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); - #if ($stmt2 !== false) { - #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 2: " . var_export($stmt2->queryString, true) . "\n", FILE_APPEND); - #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: index=" . $index['@index'] . ", amount=" . $pattern['count'] . ", jobId=" . $jobId . ", pattern=" . $pattern['pattern'] . "\n", FILE_APPEND); - # } else { - #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare() for Query 2\n", FILE_APPEND); - # } - #$stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); - #$stmt2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); - #$stmt2->bindParam(':amount', $pattern['count'], PDO::PARAM_INT); - #$stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); - #if (!$stmt2->execute()) { - # file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); - #} - #Factory::getJobFactory()->update(Factory::getJobFactory()->get($jobId)); + if ($stmt2 !== false) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 2: " . var_export($stmt2->queryString, true) . "\n", FILE_APPEND); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: index=" . $index['@index'] . ", amount=" . $pattern['count'] . ", jobId=" . $jobId . ", pattern=" . $pattern['pattern'] . "\n", FILE_APPEND); + } else { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare() for Query 2\n", FILE_APPEND); + } + $stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); + $stmt2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); + $stmt2->bindParam(':amount', $pattern['count'], PDO::PARAM_INT); + $stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT); + if (!$stmt2->execute()) { + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); + } + + $checker2 = $dbh->prepare("SELECT * FROM Job WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); + $checker2->bindParam(':jobId', $jobId, PDO::PARAM_INT); + $checker2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); + $checker2->execute(); + $fetch2 = $checker2->fetch(PDO::FETCH_ASSOC); + file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($fetch2, true)."\n", FILE_APPEND); + } } catch (PDOException $e) { From 09a5eab5249078e71aa21a579b423bb4b6b8e797 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:50:30 +0200 Subject: [PATCH 604/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index a859576a63..375283342c 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -813,7 +813,7 @@ public function incrementJobCountAtomically($jobId, $resultCollection) file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nIndex is ".$index['@index']."\n", FILE_APPEND); $checker = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( - logalyzerResults, '$.result[0].count', 66) + logalyzerResults, '$.result[0].count', 7) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); $checker->bindParam(':jobId', $jobId, PDO::PARAM_INT); $checker->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); From cf99dcdfbf08e4be5e4011913e10488c41df294e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:52:46 +0200 Subject: [PATCH 605/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 375283342c..03318893a9 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -822,10 +822,10 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $stmt2 = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( logalyzerResults, - JSON_QUOTE(:index), + :index, CAST(CAST( JSON_UNQUOTE( - JSON_EXTRACT(logalyzerResults, JSON_QUOTE(:index)) + JSON_EXTRACT(logalyzerResults, :index) ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); if ($stmt2 !== false) { From a224741f9bbf04ca2809ce7fa383a466acfdb59e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:53:38 +0200 Subject: [PATCH 606/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 03318893a9..7c573b51c7 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -812,12 +812,12 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $index = $helper->fetch(PDO::FETCH_ASSOC); file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nIndex is ".$index['@index']."\n", FILE_APPEND); - $checker = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( - logalyzerResults, '$.result[0].count', 7) - WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); - $checker->bindParam(':jobId', $jobId, PDO::PARAM_INT); - $checker->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); - $checker->execute(); + #$checker = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( + # logalyzerResults, '$.result[0].count', 7) + # WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); + #$checker->bindParam(':jobId', $jobId, PDO::PARAM_INT); + #$checker->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); + #$checker->execute(); $stmt2 = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( From 1f113965151b4f9592b773972efab9d32d361c05 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 02:58:16 +0200 Subject: [PATCH 607/644] changed json to be 'result':[{}] --- libraries/dba/AbstractModelFactory.class.php | 32 +++++--------------- libraries/logalyzer.php | 12 +------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 7c573b51c7..9267148ed9 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -787,8 +787,6 @@ public function getDB($test = false) { */ public function incrementJobCountAtomically($jobId, $resultCollection) { - $json = Factory::getJobFactory()->get($jobId)->getLogalyzerResults(); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($json, true), FILE_APPEND); $dbh = self::getDB(); try { foreach ($resultCollection as $pattern) { @@ -802,22 +800,11 @@ public function incrementJobCountAtomically($jobId, $resultCollection) $stmt1->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); $stmt1->bindParam(':jobId', $jobId, PDO::PARAM_INT); - #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 1: " . var_export($stmt1->queryString, true) . "\n", FILE_APPEND); - #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: pattern=" . $pattern['pattern'] . ", jobId=" . $jobId . "\n", FILE_APPEND); - if (!$stmt1->execute()) { file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute() for Query 1\n", FILE_APPEND); } $helper = $dbh->query("SELECT @index"); $index = $helper->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nIndex is ".$index['@index']."\n", FILE_APPEND); - - #$checker = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( - # logalyzerResults, '$.result[0].count', 7) - # WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); - #$checker->bindParam(':jobId', $jobId, PDO::PARAM_INT); - #$checker->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); - #$checker->execute(); $stmt2 = $dbh->prepare("UPDATE Job SET logalyzerResults = JSON_SET( @@ -828,12 +815,6 @@ public function incrementJobCountAtomically($jobId, $resultCollection) JSON_EXTRACT(logalyzerResults, :index) ) AS UNSIGNED) + :amount AS CHAR)) WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); - if ($stmt2 !== false) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 2: " . var_export($stmt2->queryString, true) . "\n", FILE_APPEND); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: index=" . $index['@index'] . ", amount=" . $pattern['count'] . ", jobId=" . $jobId . ", pattern=" . $pattern['pattern'] . "\n", FILE_APPEND); - } else { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare() for Query 2\n", FILE_APPEND); - } $stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR); $stmt2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); $stmt2->bindParam(':amount', $pattern['count'], PDO::PARAM_INT); @@ -842,12 +823,13 @@ public function incrementJobCountAtomically($jobId, $resultCollection) file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND); } - $checker2 = $dbh->prepare("SELECT * FROM Job WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); - $checker2->bindParam(':jobId', $jobId, PDO::PARAM_INT); - $checker2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); - $checker2->execute(); - $fetch2 = $checker2->fetch(PDO::FETCH_ASSOC); - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($fetch2, true)."\n", FILE_APPEND); + # Used to query the database entry and append it to a log for debugging + #$checker2 = $dbh->prepare("SELECT * FROM Job WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;"); + #$checker2->bindParam(':jobId', $jobId, PDO::PARAM_INT); + #$checker2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR); + #$checker2->execute(); + #$fetch2 = $checker2->fetch(PDO::FETCH_ASSOC); + #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($fetch2, true)."\n", FILE_APPEND); } } diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index e0f2a9f72b..b9fac8b38e 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -126,7 +126,7 @@ public function examineLogLine($logLine) { } $hash = $this->calculateHash(); $resultCollection = []; - $LOG_ERRORS_MAX = 10; // TODO change to constant from constants.php + $LOG_ERRORS_MAX = 50; // TODO change to constant from constants.php foreach($this->data['result'] as $index => $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; @@ -138,31 +138,21 @@ public function examineLogLine($logLine) { if ($number >= 1) { $pattern['count'] = $number; $resultCollection[] = $pattern; - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nadded to resultCollection\n", FILE_APPEND); - } } } if(!$isInResultSet) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\nATTENTION RESETTING VALUE\n", FILE_APPEND); - $pattern['count'] = $number; $this->results['result'][] = $pattern; if($this->results['hash'] === "" || $this->results['hash'] === null) { $this->results['hash'] = $hash; } - #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); - $this->job->setLogalyzerResults(json_encode($this->results)); Factory::getJobFactory()->update($this->job); } } if(!empty($resultCollection)) { - file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', "\ntrying to increment using query given\n", FILE_APPEND); - #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($resultCollection, true), FILE_APPEND); - Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); - #Factory::getJobFactory()->update($this->job); } /*$end = microtime(true); if($logLine == "SendMail\n") { From 3744b94a058ec5b1ee27ccf27bc6ebff81e3ef1d Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 03:00:30 +0200 Subject: [PATCH 608/644] changed json to be 'result':[{}] --- libraries/logalyzer.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index b9fac8b38e..2f89adee13 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -110,13 +110,6 @@ public function examineLogLine($logLine) { if($json === null) { return; } - #$results = $this->job->getLogalyzerResults(); - #if(isset($results)) { - # $this->results = json_decode($results, true); - #} - #else { - # $this->createEmptyJobLogalyzerResults(); - #} $json = $this->job->getLogalyzerResults(); if($json === null) { $this->createEmptyJobLogalyzerResults(); @@ -130,7 +123,6 @@ public function examineLogLine($logLine) { foreach($this->data['result'] as $index => $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; - #file_put_contents(UPLOADED_DATA_PATH . 'log/' . $this->job->getId() . '.log', print_r($this->results, true), FILE_APPEND); foreach($this->results['result'] as $result) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { From 6452392a0f49f7167861d9d89c5b8ae7ad4c7420 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 03:07:47 +0200 Subject: [PATCH 609/644] small fixes --- libraries/dba/AbstractModelFactory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 9267148ed9..dddc777f02 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -927,7 +927,7 @@ public function checkAllPositiveJobPatterns($job) { $json = $job->getLogalyzerResults(); if ($json != null) { $data = json_decode($job->getLogalyzerResults(), true); - foreach ($data['pattern'] as $element) { + foreach ($data['result'] as $element) { if($element['type'] === 'positive' && $element['count'] <= 0) { return false; } From cef9b6c40471688182b0e32593f102821c63fa2e Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 03:10:06 +0200 Subject: [PATCH 610/644] small fixes --- libraries/dba/AbstractModelFactory.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index dddc777f02..07fe97d6c3 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -893,7 +893,16 @@ public function logalyzerUpdateHash($jobId, $hash) { public function getJobCountForLogLevel($job, $logLevel, $type) { if($job->getLogalyzerResults() != null) { $json = json_decode($job->getLogalyzerResults(), true); - $resultArray = $json['result']; + if(isset($json['result'])) { + $resultArray = $json['result']; + } + # An early version of this feature used the key 'pattern' which was changed before release. This is just a fallback + elseif(isset($json['pattern'])) { + $resultArray = $json['pattern']; + } + else { + return null; + } $count = 0; foreach ($resultArray as $element) { if ($type === "negative" && $element["type"] === "negative" && $element["logLevel"] === $logLevel) { From c9d55416563cfb6ee3096253096ebe53eacee982 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 03:11:48 +0200 Subject: [PATCH 611/644] small fixes --- libraries/dba/AbstractModelFactory.class.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 07fe97d6c3..34cf835595 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -936,12 +936,23 @@ public function checkAllPositiveJobPatterns($job) { $json = $job->getLogalyzerResults(); if ($json != null) { $data = json_decode($job->getLogalyzerResults(), true); - foreach ($data['result'] as $element) { - if($element['type'] === 'positive' && $element['count'] <= 0) { - return false; + if(isset($data['result'])) { + foreach ($data['result'] as $element) { + if ($element['type'] === 'positive' && $element['count'] <= 0) { + return false; + } } + return true; + } + # An early version used the key 'pattern' instead of 'results' this is only a fallback + elseif(isset($data['pattern'])) { + foreach ($data['pattern'] as $element) { + if ($element['type'] === 'positive' && $element['count'] <= 0) { + return false; + } + } + return true; } - return true; } return true; } From f953e9212507abca9ed98329e1d012044ce9d0af Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 03:20:28 +0200 Subject: [PATCH 612/644] small fixes --- views/admin/system.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/views/admin/system.php b/views/admin/system.php index 40e18ef262..3f1429def4 100644 --- a/views/admin/system.php +++ b/views/admin/system.php @@ -478,7 +478,8 @@
- +
@@ -491,7 +492,8 @@
- +

@@ -512,19 +514,21 @@
- -
-
- - + +
+
+ + Delete +
-
- +

@@ -545,7 +549,8 @@
- +
@@ -558,7 +563,8 @@
- +
From 962f8d030edd968e74d108e9dd9c81de6b825ebe Mon Sep 17 00:00:00 2001 From: PatrikB Date: Wed, 14 Aug 2024 03:22:47 +0200 Subject: [PATCH 613/644] small fixes --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 6b3c0e66dc..7e42b3e026 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -8,7 +8,7 @@ * Results are shown inside a job's detail page */ class Logalyzer_Library { - private DBA\Job $job; + private $job; private $system; private $log; private $data; From 32110f94672fc4083d64e18eca83be065474ae42 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Mon, 26 Aug 2024 19:32:11 +0200 Subject: [PATCH 614/644] Documented Logalyzer --- libraries/logalyzer.php | 201 ++++++++++++++++++++++++---------------- 1 file changed, 121 insertions(+), 80 deletions(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 7e42b3e026..2cbfbb5300 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -1,21 +1,56 @@ job = $job; @@ -25,26 +60,46 @@ public function __construct($job = null) { } } + + /** + * Returns the Job of this Logalyzer Instance, might return Null if no job has been defined + * @return Job|null + */ public function getJob() { return $this->job; } + /** + * Returns the System of this Logalyzer Instance + * @return DBA\System + */ public function getSystem() { return $this->system; } + + /** + * Select the desired system and fetch the stored patterns from the database + * @param DBA\System $system The system to fetch patterns from + * @return void + */ public function setSystemAndLoadPattern($system) { $this->system = $system; - //$this->createBasicPatterns(); - //$this->savePatterns(); $this->loadPatterns(); } + + /** + * Allows retroactively setting a Job for an existing Logalyzer object. + * @param DBA\Job $job The Job to analyze + * @return void + */ public function setJob($job) { $this->job = $job; } /** - * @param string $keyword - * @param string $target - * @param bool $regex - * @return int + * Searches the $keyword in the $target using an appropriate search function for the type defined by $regex + * @param string $keyword Pattern to be searched + * @param string $target Target text, such as a log file or log line + * @param string $regex Takes the form of 'string' or 'regex'. + * @return int Returns the amount of occurrences of $keyword in $target as an integer. */ public function countLogOccurances(string $keyword, string $target, string $regex) { if ($regex === 'regex') { @@ -57,13 +112,18 @@ public function countLogOccurances(string $keyword, string $target, string $rege } } + /** + * Checks the hash of a system's patterns and the patterns used to analyze a Job. + * Returns true if the hash values differ. + * @return bool + */ private function checkHashDifference() { $results = json_decode($this->job->getLogalyzerResults(), true); - return !($results['hash'] === hash('sha1', json_encode($this->data))); + return !($results['hash'] === hash('sha1', json_encode($this->system_pattern))); } /** - * Load and read the entire logfile counting the occurances of the pattern words and saving the result in the database + * Load and read the entire logfile counting the occurrences of the pattern, saving the result in the database * @return void */ public function examineEntireLog() { @@ -75,13 +135,12 @@ public function examineEntireLog() { $this->log = $log; } $this->createEmptyJobLogalyzerResults(); - $hash = $this->calculateHash(); + $hash = $this->calculateSystemHash(); - foreach($this->data['result'] as $pattern) { + foreach($this->system_pattern['result'] as $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $this->log, $pattern['regex']); $found = false; - foreach($this->results['result'] as $result) { - //print_r($result); + foreach($this->job_pattern['result'] as $result) { if(isset($result['logLevel'],$result['pattern'],$result['regex'],$result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type']) { $result['count'] += $number; $found = true; @@ -89,22 +148,20 @@ public function examineEntireLog() { } if(!$found) { $pattern['count'] = $number; - //print_r($pattern); - $this->results['result'][] = $pattern; + $this->job_pattern['result'][] = $pattern; } } - $this->results['hash'] = $hash; - $this->job->setLogalyzerResults(json_encode($this->results)); + $this->job_pattern['hash'] = $hash; + $this->job->setLogalyzerResults(json_encode($this->job_pattern)); Factory::getJobFactory()->update($this->job); } /** - * Reads a submitted logLine and updates the database object with a new result json object + * Reads a submitted log line and updates the database object with a new result json object * @param $logLine * @return void */ public function examineLogLine($logLine) { - #$start = microtime(true); // Load existing result set $json = $this->system->getLogalyzerPatterns(); if($json === null) { @@ -115,15 +172,15 @@ public function examineLogLine($logLine) { $this->createEmptyJobLogalyzerResults(); } else { - $this->results = json_decode($json, true); + $this->job_pattern = json_decode($json, true); } - $hash = $this->calculateHash(); + $hash = $this->calculateSystemHash(); $resultCollection = []; $LOG_ERRORS_MAX = 50; // TODO change to constant from constants.php - foreach($this->data['result'] as $index => $pattern) { + foreach($this->system_pattern['result'] as $index => $pattern) { $number = $this->countLogOccurances($pattern['pattern'], $logLine, $pattern['regex']); $isInResultSet = false; - foreach($this->results['result'] as $result) { + foreach($this->job_pattern['result'] as $result) { // Check if the result has been previously set in the job's result if (isset($result['logLevel'], $result['pattern'], $result['regex'], $result['type']) && $pattern['logLevel'] === $result['logLevel'] && $pattern['pattern'] === $result['pattern'] && $pattern['regex'] === $result['regex'] && $pattern['type'] === $result['type'] && $result['count'] < $LOG_ERRORS_MAX) { $isInResultSet = true; @@ -135,66 +192,45 @@ public function examineLogLine($logLine) { } if(!$isInResultSet) { $pattern['count'] = $number; - $this->results['result'][] = $pattern; - if($this->results['hash'] === "" || $this->results['hash'] === null) { - $this->results['hash'] = $hash; + $this->job_pattern['result'][] = $pattern; + if($this->job_pattern['hash'] === "" || $this->job_pattern['hash'] === null) { + $this->job_pattern['hash'] = $hash; } - $this->job->setLogalyzerResults(json_encode($this->results)); + $this->job->setLogalyzerResults(json_encode($this->job_pattern)); Factory::getJobFactory()->update($this->job); } } if(!empty($resultCollection)) { Factory::getJobFactory()->incrementJobCountAtomically($this->job->getId(), $resultCollection); } - /*$end = microtime(true); - if($logLine == "SendMail\n") { - $this->mailResults(); - } - else { - $this->logTime($start, $end); - }*/ - } - private function mailResults() { - $to = "p.buetler@stud.unibas.ch"; - $subj = "Eval Results"; - $from = 'chronos@stud.unibas.ch'; - $from_name = 'chronos'; - $path = UPLOADED_DATA_PATH . '/log/time.log'; - mail($to, $subj, file_get_contents($path)); - // Empty the file afterwards - file_put_contents($path, ""); - - } - private function logTime($start, $end) { - $path = UPLOADED_DATA_PATH . '/log/time.log'; - file_put_contents($path, round((($end-$start)*1000),4).",", FILE_APPEND); } + /** * Creates empty pattern for a system * @return void */ private function createBasicPatterns() { - $this->data['hash'] = ""; - $this->data['result'] = array(); + $this->system_pattern['hash'] = ""; + $this->system_pattern['result'] = array(); } /** - * Returns the arrays containing pattern + * Fetch a systems' pattern as an array * $identifier can be 'all', or the desired logLevel such as 'warn' or 'error' * @param string $logLevel * @param string $type 'regex' or 'string' * @return array */ public function getPatterns(string $logLevel, string $type) { - if ($this->data == null) { + if ($this->system_pattern == null) { $this->createBasicPatterns(); } if ($logLevel === 'all') { - return $this->data['result']; + return $this->system_pattern['result']; } else { $temp = []; - foreach ($this->data['result'] as $pattern) { + foreach ($this->system_pattern['result'] as $pattern) { if ($pattern['logLevel'] == $logLevel && $pattern['type'] == $type) { $temp[] = $pattern; } @@ -210,28 +246,28 @@ public function getPatterns(string $logLevel, string $type) { */ public function loadPatterns() { $patterns = $this->system->getLogalyzerPatterns(); - if ($patterns != null) { - $this->data = json_decode($patterns, true); + if (isset($patterns) && $patterns == null) { + $this->system_pattern = json_decode($patterns, true); } else { - // Initial load of patterns returned null + // No patterns have been created for this system yet $this->createBasicPatterns(); - # Saving here is unnecessary and causes server load for no reason - #$this->savePatterns(); } } /** - * Saves a modified pattern to the systems database table - * Is called when patterns changed + * Saves a modified pattern set to the systems database table + * Is called whenever patterns changed + * Hash value is updated * @return void */ private function savePatterns() { - $this->data['hash'] = hash('sha1', json_encode($this->data['result'])); - $this->system->setLogalyzerPatterns(json_encode($this->data)); + $this->system_pattern['hash'] = hash('sha1', json_encode($this->system_pattern['result'])); + $this->system->setLogalyzerPatterns(json_encode($this->system_pattern)); Factory::getSystemFactory()->update($this->system); } /** + * Adds a new pattern defined in the System UI and saves it to the System database table if it is no duplicate * @param string $logLevel * @param string $pattern 'the pattern string' * @param string $regex 'string' or 'regex' @@ -244,15 +280,17 @@ public function addKey(string $logLevel, string $pattern, string $regex, string } else { $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => $regex, 'type' => $type); - if(!in_array($array, $this->data['result'])) { - $this->data['result'][] = $array; + // Duplicate check + if(!in_array($array, $this->system_pattern['result'])) { + $this->system_pattern['result'][] = $array; $this->savePatterns(); } } } /** - * @param string $logLevel + * Search and drop the corresponding pattern for a System + * @param string $logLevel currently supports 'warn' and 'error' * @param string $pattern 'the pattern string' * @param string $type 'positive' or 'negative' * @return void @@ -263,16 +301,18 @@ public function removeKey(string $logLevel, string $pattern, string $type) { } else { $array = array('logLevel' => $logLevel, 'pattern' => $pattern, 'regex' => 'string', 'type' => $type); - if(in_array($array, $this->data['result'])) { - $index = array_search($array, $this->data['result']); - unset($this->data['result'][$index]); + // Check if it is a normal string + if(in_array($array, $this->system_pattern['result'])) { + $index = array_search($array, $this->system_pattern['result']); + unset($this->system_pattern['result'][$index]); $this->savePatterns(); } + // Check if it is a regex else { $array['regex'] = 'regex'; - if(in_array($array, $this->data['result'])) { - $index = array_search($array, $this->data['result']); - unset($this->data['result'][$index]); + if(in_array($array, $this->system_pattern['result'])) { + $index = array_search($array, $this->system_pattern['result']); + unset($this->system_pattern['result'][$index]); $this->savePatterns(); } } @@ -284,14 +324,15 @@ public function removeKey(string $logLevel, string $pattern, string $type) { * @return void */ private function createEmptyJobLogalyzerResults() { - $this->results['hash'] = ""; - $this->results['result'] = array(); + $this->job_pattern['hash'] = ""; + $this->job_pattern['result'] = array(); } /** + * Calculates the System hash on the fly * @return string */ - function calculateHash() { - return hash('sha1', json_encode($this->data['result'])); + function calculateSystemHash() { + return hash('sha1', json_encode($this->system_pattern['result'])); } } From 899797eb01b483ab19e776534a4e88909ab955fa Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 15:49:21 +0200 Subject: [PATCH 615/644] Documented Logalyzer --- controllers/evaluation.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/evaluation.php b/controllers/evaluation.php index 53f730933e..033c37c98d 100644 --- a/controllers/evaluation.php +++ b/controllers/evaluation.php @@ -131,12 +131,13 @@ public function detail() { Factory::getEvaluationFactory()->update($evaluation); } // Button press to reexamine entire log - // Button only shows up if the job examined using an outdated pattern (or none) + // Button shows up if the job was inspected using an outdated pattern if (!empty($this->post['recheck'])) { $job = Factory::getJobFactory()->get($this->post['jobId']); $logalyzer = new Logalyzer_Library($job); $logalyzer->examineEntireLog(); } + // Recheck all Jobs contained in an Evaluation if (!empty($this->post['recheckAll'])) { $qF = new QueryFilter(Job::EVALUATION_ID, $evaluation->getId(), "="); $jobs = Factory::getJobFactory()->filter([Factory::FILTER => $qF]); From b8efc03a44157e78810586907c40f59b05647235 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 15:50:37 +0200 Subject: [PATCH 616/644] Documented Logalyzer --- views/evaluation/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 2b1ca3a19e..8dad9ff617 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -234,9 +234,9 @@ function getLogalyzerResponses(evalId) { getDescription(); ?> getJobCountForLogLevel($job, 'error', 'negative')>=1) { ?> - + getJobCountForLogLevel($job, 'warn', 'negative')>=1) { ?> - + getStatus() == Define::JOB_STATUS_FINISHED || $job->getStatus() == Define::JOB_STATUS_FAILED) && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { ?> From 1b1c94288bb67c6a920c05ce5fdcbaff2ac35fe3 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 15:51:57 +0200 Subject: [PATCH 617/644] Documented Logalyzer --- views/evaluation/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/evaluation/detail.php b/views/evaluation/detail.php index 8dad9ff617..4b50fe46a5 100644 --- a/views/evaluation/detail.php +++ b/views/evaluation/detail.php @@ -265,7 +265,7 @@ function getLogalyzerResponses(evalId) {
- +
From 54d9b8005354f1cd8b791dc4483b2f12a84630c8 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 15:54:32 +0200 Subject: [PATCH 618/644] Documented Logalyzer --- controllers/job.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/job.php b/controllers/job.php index 13bc56c932..f384478c54 100644 --- a/controllers/job.php +++ b/controllers/job.php @@ -155,10 +155,10 @@ public function detail() { } $system = Factory::getSystemFactory()->get($job->getSystemId()); - // Shenanigans to normalize whitespaces and newlines + // Fetch a Job's Logalyzer results to check if it is up-to-date. $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); - $hash = $logalyzer->calculateHash(); + $hash = $logalyzer->calculateSystemHash(); $json = $job->getLogalyzerResults(); if($json != null) { $results = json_decode($json, true); From 30ca46dd1b5ef914228a7518a41a2eb340a1b339 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 16:08:11 +0200 Subject: [PATCH 619/644] Attempt to fetch results dynamically via Job API --- api/v1/job.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/v1/job.php b/api/v1/job.php index e7a28b63a7..11dc9a9a45 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -109,6 +109,9 @@ public function get() { } else { $data->log = $log; } + // Dynamically fetch Logalyzer results + $data->logErrorCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'error', 'negative'); + $data->logWarningCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative'); } $this->add($data); } From 7952ffe1c7652fe410c13f5d3383e256c5c9e367 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 16:16:16 +0200 Subject: [PATCH 620/644] Reverted attempts, creating new branch --- api/v1/job.php | 3 --- views/job/detail.php | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index 11dc9a9a45..e7a28b63a7 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -109,9 +109,6 @@ public function get() { } else { $data->log = $log; } - // Dynamically fetch Logalyzer results - $data->logErrorCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'error', 'negative'); - $data->logWarningCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative'); } $this->add($data); } diff --git a/views/job/detail.php b/views/job/detail.php index bd03715cc8..e7b5ecb43a 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -237,11 +237,11 @@ function updateProgress() {
- Errors: 10) { echo('> 10'); } - elseif($data['logErrorCount'] >= 0) { echo($data['logErrorCount']); } ?> + 10) { echo('> 10'); } + elseif($data['logErrorCount'] >= 0) { echo('Errors: ' . $data['logErrorCount']); } ?>
- Warnings: 10) { echo('> 10'); } - elseif($data['logWarningCount'] >= 0) { echo($data['logWarningCount']);} ?> + 10) { echo('> 10'); } + elseif($data['logWarningCount'] >= 0) { echo('Warnings: ' . $data['logWarningCount']);} ?>

From 9f94773492fc9b1d0985f3604f8582f1c6bf06bb Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 16:21:17 +0200 Subject: [PATCH 621/644] Dynamically fetch data using api --- api/v1/job.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/api/v1/job.php b/api/v1/job.php index e7a28b63a7..6bbdf61a1a 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -110,6 +110,23 @@ public function get() { $data->log = $log; } } + // Dynamically fetch Logalyzer results + $data->logErrorCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'error', 'negative'); + $data->logWarningCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative'); + if($job->getStatus()==Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { + $data->logContainsMandatory=0; + } + #$system = Factory::getSystemFactory()->get($job->getSystemId()); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystemAndLoadPattern($system); + $hash = $logalyzer->calculateSystemHash(); + $json = $job->getLogalyzerResults(); + if($json != null) { + $results = json_decode($json, true); + if (!isset($results['hash']) || $results['hash'] != $hash) { + $data->usedOutdatedPattern = true; + } + } $this->add($data); } From 29d380c3e2408dc8a678c88bd0a1a53f16065cf1 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 16:26:46 +0200 Subject: [PATCH 622/644] Dynamically fetch data using api --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index e7b5ecb43a..37c546cd2f 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -237,10 +237,10 @@ function updateProgress() {
- 10) { echo('> 10'); } + 10) { echo('Errors: < 10'); } elseif($data['logErrorCount'] >= 0) { echo('Errors: ' . $data['logErrorCount']); } ?>
- 10) { echo('> 10'); } + 10) { echo('Warnings: < 10'); } elseif($data['logWarningCount'] >= 0) { echo('Warnings: ' . $data['logWarningCount']);} ?>
From f2628236c7b6e6fc76a8ffdaa8cbb8e5bcc2c95b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 16:49:06 +0200 Subject: [PATCH 623/644] debug --- libraries/logalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/logalyzer.php b/libraries/logalyzer.php index 2cbfbb5300..746fcb0526 100644 --- a/libraries/logalyzer.php +++ b/libraries/logalyzer.php @@ -246,7 +246,7 @@ public function getPatterns(string $logLevel, string $type) { */ public function loadPatterns() { $patterns = $this->system->getLogalyzerPatterns(); - if (isset($patterns) && $patterns == null) { + if (isset($patterns) && $patterns != null) { $this->system_pattern = json_decode($patterns, true); } else { From b4b43697050b5a30b0e01a88915757919611f6f6 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 16:53:39 +0200 Subject: [PATCH 624/644] Dynamic fetching --- libraries/dba/AbstractModelFactory.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 34cf835595..7349a7cbda 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -896,12 +896,12 @@ public function getJobCountForLogLevel($job, $logLevel, $type) { if(isset($json['result'])) { $resultArray = $json['result']; } - # An early version of this feature used the key 'pattern' which was changed before release. This is just a fallback + # An early version of this feature used an array key 'pattern', which was changed before release. This is just a fallback elseif(isset($json['pattern'])) { $resultArray = $json['pattern']; } else { - return null; + return -1; } $count = 0; foreach ($resultArray as $element) { @@ -912,7 +912,7 @@ public function getJobCountForLogLevel($job, $logLevel, $type) { return $count; } else { - return null; + return -1; } } public function getJobHash($job) { From 2cd8a34da56c803e99fa4d43ba80ff1579ac80ea Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 16:58:18 +0200 Subject: [PATCH 625/644] Dynamic fetching --- views/job/detail.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 37c546cd2f..6619cdfe8d 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -96,6 +96,8 @@ function updateAll() { $('#progress').width(obj.response.progress + '%'); $('#log').html(ansi_up.ansi_to_html(obj.response.log).replace(/\\r\\n/g, '\\n').replace(/\\n/g, '
')); $('#log').scrollTop($('#log')[0].scrollHeight); + $('#errors') = obj.response.errors; + $('#warnings') = obj.response.warnings; }); } @@ -104,6 +106,8 @@ function updateProgress() { $.get('/api/v1/job/withLog=0/id=' + id, function(data, status) { var obj = JSON.parse(data); $('#progress').width(obj.response.progress + '%'); + $('#errors') = obj.response.errors; + $('#warnings') = obj.response.warnings; }); } @@ -237,12 +241,14 @@ function updateProgress() {
- 10) { echo('Errors: < 10'); } - elseif($data['logErrorCount'] >= 0) { echo('Errors: ' . $data['logErrorCount']); } ?> -
- 10) { echo('Warnings: < 10'); } - elseif($data['logWarningCount'] >= 0) { echo('Warnings: ' . $data['logWarningCount']);} ?> + Errors:
+
+
+
+ Warnings: +
+

From ea728f88d603b4629b100d4738fee7a009f44408 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 17:00:33 +0200 Subject: [PATCH 626/644] Dynamic fetching --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 6619cdfe8d..512d22b99f 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -96,8 +96,8 @@ function updateAll() { $('#progress').width(obj.response.progress + '%'); $('#log').html(ansi_up.ansi_to_html(obj.response.log).replace(/\\r\\n/g, '\\n').replace(/\\n/g, '
')); $('#log').scrollTop($('#log')[0].scrollHeight); - $('#errors') = obj.response.errors; - $('#warnings') = obj.response.warnings; + $('#errors') = obj.response.logErrorCount; + $('#warnings') = obj.response.logWarningCount; }); } From 654758f01007c42497a11e5746b2db092edeeb74 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 17:03:09 +0200 Subject: [PATCH 627/644] Dynamic fetching --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 512d22b99f..0cd9aab0d9 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -96,8 +96,8 @@ function updateAll() { $('#progress').width(obj.response.progress + '%'); $('#log').html(ansi_up.ansi_to_html(obj.response.log).replace(/\\r\\n/g, '\\n').replace(/\\n/g, '
')); $('#log').scrollTop($('#log')[0].scrollHeight); - $('#errors') = obj.response.logErrorCount; - $('#warnings') = obj.response.logWarningCount; + $('#errors').text(obj.response.logErrorCount); + $('#warnings').text(obj.response.logWarningCount); }); } From f671050fee3936ca239da88bb651d2853f8a9e53 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 17:03:37 +0200 Subject: [PATCH 628/644] Dynamic fetching --- views/job/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 0cd9aab0d9..0526649586 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -106,8 +106,8 @@ function updateProgress() { $.get('/api/v1/job/withLog=0/id=' + id, function(data, status) { var obj = JSON.parse(data); $('#progress').width(obj.response.progress + '%'); - $('#errors') = obj.response.errors; - $('#warnings') = obj.response.warnings; + $('#errors').text(obj.response.logErrorCount); + $('#warnings').text(obj.response.logWarningCount); }); } From 3f652c248a98dd7f7b7d35eafab3ed11effc1edd Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 17:05:21 +0200 Subject: [PATCH 629/644] Dynamic fetching --- libraries/dba/AbstractModelFactory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/dba/AbstractModelFactory.class.php b/libraries/dba/AbstractModelFactory.class.php index 7349a7cbda..c48c3b97ca 100755 --- a/libraries/dba/AbstractModelFactory.class.php +++ b/libraries/dba/AbstractModelFactory.class.php @@ -901,7 +901,7 @@ public function getJobCountForLogLevel($job, $logLevel, $type) { $resultArray = $json['pattern']; } else { - return -1; + return 0; } $count = 0; foreach ($resultArray as $element) { @@ -912,7 +912,7 @@ public function getJobCountForLogLevel($job, $logLevel, $type) { return $count; } else { - return -1; + return 0; } } public function getJobHash($job) { From f60cf46d184d7da75b6062ac298eb1ff6f91b665 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 17:07:11 +0200 Subject: [PATCH 630/644] Dynamic fetching --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 0526649586..1a21df794c 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -221,7 +221,7 @@ function updateProgress() {
From acaeabde76c9804a0ba617c3e8f0369cb4efea97 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 17:07:28 +0200 Subject: [PATCH 631/644] Dynamic fetching --- api/v1/job.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/api/v1/job.php b/api/v1/job.php index 6bbdf61a1a..522d88445c 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -109,22 +109,22 @@ public function get() { } else { $data->log = $log; } - } - // Dynamically fetch Logalyzer results - $data->logErrorCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'error', 'negative'); - $data->logWarningCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative'); - if($job->getStatus()==Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { - $data->logContainsMandatory=0; - } - #$system = Factory::getSystemFactory()->get($job->getSystemId()); - $logalyzer = new Logalyzer_Library(); - $logalyzer->setSystemAndLoadPattern($system); - $hash = $logalyzer->calculateSystemHash(); - $json = $job->getLogalyzerResults(); - if($json != null) { - $results = json_decode($json, true); - if (!isset($results['hash']) || $results['hash'] != $hash) { - $data->usedOutdatedPattern = true; + // Dynamically fetch Logalyzer results + $data->logErrorCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'error', 'negative'); + $data->logWarningCount = Factory::getJobFactory()->getJobCountForLogLevel($job, 'warn', 'negative'); + if($job->getStatus()==Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { + $data->logContainsMandatory=0; + } + #$system = Factory::getSystemFactory()->get($job->getSystemId()); + $logalyzer = new Logalyzer_Library(); + $logalyzer->setSystemAndLoadPattern($system); + $hash = $logalyzer->calculateSystemHash(); + $json = $job->getLogalyzerResults(); + if($json != null) { + $results = json_decode($json, true); + if (!isset($results['hash']) || $results['hash'] != $hash) { + $data->usedOutdatedPattern = true; + } } } $this->add($data); From 22e6cfb56c4939d21a40dc3228779a621f558100 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 17:15:14 +0200 Subject: [PATCH 632/644] Dynamic fetching --- views/job/detail.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 1a21df794c..04b1059945 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -98,6 +98,14 @@ function updateAll() { $('#log').scrollTop($('#log')[0].scrollHeight); $('#errors').text(obj.response.logErrorCount); $('#warnings').text(obj.response.logWarningCount); + if (obj.response.logErrorCount >= 1) { + document.getElementById('logErrorBanner').style.display = 'block'; + } elseif (obj.response.logWarningCount >= 1) { + document.getElementById('logWarningBanner').style.display = 'block'; + } + if (obj.response.logContainsMandatory == 0) { + document.getElementById('logMandatoryBanner').style.display = 'block'; + } }); } @@ -106,8 +114,6 @@ function updateProgress() { $.get('/api/v1/job/withLog=0/id=' + id, function(data, status) { var obj = JSON.parse(data); $('#progress').width(obj.response.progress + '%'); - $('#errors').text(obj.response.logErrorCount); - $('#warnings').text(obj.response.logWarningCount); }); } From 7c418275cda6d3e172e8a7ef10ef1b4c269abec9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 17:15:58 +0200 Subject: [PATCH 633/644] Dynamic fetching --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 04b1059945..9c1ad12cff 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -100,7 +100,7 @@ function updateAll() { $('#warnings').text(obj.response.logWarningCount); if (obj.response.logErrorCount >= 1) { document.getElementById('logErrorBanner').style.display = 'block'; - } elseif (obj.response.logWarningCount >= 1) { + } else if (obj.response.logWarningCount >= 1) { document.getElementById('logWarningBanner').style.display = 'block'; } if (obj.response.logContainsMandatory == 0) { From c044f50cecafe7808a4e7fee2f3c8decd0fa0ae0 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Tue, 27 Aug 2024 17:18:25 +0200 Subject: [PATCH 634/644] Dynamic fetching --- views/job/detail.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/views/job/detail.php b/views/job/detail.php index 9c1ad12cff..a739388a35 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -98,6 +98,7 @@ function updateAll() { $('#log').scrollTop($('#log')[0].scrollHeight); $('#errors').text(obj.response.logErrorCount); $('#warnings').text(obj.response.logWarningCount); + if (obj.response.logErrorCount >= 1) { document.getElementById('logErrorBanner').style.display = 'block'; } else if (obj.response.logWarningCount >= 1) { @@ -105,6 +106,9 @@ function updateAll() { } if (obj.response.logContainsMandatory == 0) { document.getElementById('logMandatoryBanner').style.display = 'block'; + } + if (obj.response.usedOutdatedPatterns == true) { + document.getElementById('logOutdatedBanner').style.display = 'block'; } }); } From 234a7ecb5fe1b6212b81975e858d92f1c01106b9 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 31 Aug 2024 13:47:06 +0200 Subject: [PATCH 635/644] Dynamic fetching --- api/v1/job.php | 1 - 1 file changed, 1 deletion(-) diff --git a/api/v1/job.php b/api/v1/job.php index 522d88445c..13a5fe9d70 100644 --- a/api/v1/job.php +++ b/api/v1/job.php @@ -115,7 +115,6 @@ public function get() { if($job->getStatus()==Define::JOB_STATUS_FINISHED && !Factory::getJobFactory()->checkAllPositiveJobPatterns($job)) { $data->logContainsMandatory=0; } - #$system = Factory::getSystemFactory()->get($job->getSystemId()); $logalyzer = new Logalyzer_Library(); $logalyzer->setSystemAndLoadPattern($system); $hash = $logalyzer->calculateSystemHash(); From a7a54b2edb8ccac81d81316188165e165c9bb403 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 7 Sep 2024 23:14:35 +0200 Subject: [PATCH 636/644] Some fixes --- views/job/detail.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index a739388a35..a293d9d721 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -267,12 +267,11 @@ function updateProgress() {

Outdated pattern used, use 'Recheck'

- = 1) { ?> -
+ - = 1) { ?> + = 1) { ?>
×

Log contains Warnings

From dfd3eacaa16b427ee7551eb287870465ac82ed47 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 7 Sep 2024 23:17:51 +0200 Subject: [PATCH 637/644] Some fixes --- views/job/detail.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index a293d9d721..a68e83cbe7 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -261,22 +261,18 @@ function updateProgress() {

- -
+ - - = 1) { ?>
×

Log contains Warnings

-
× From b382dab62514e775317031f51fb21f0f44667bc2 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 7 Sep 2024 23:19:54 +0200 Subject: [PATCH 638/644] Some fixes --- views/job/detail.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index a68e83cbe7..387e9b8b04 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -101,7 +101,8 @@ function updateAll() { if (obj.response.logErrorCount >= 1) { document.getElementById('logErrorBanner').style.display = 'block'; - } else if (obj.response.logWarningCount >= 1) { + } + if (obj.response.logWarningCount >= 1 && obj.response.logErrorCount < 1) { document.getElementById('logWarningBanner').style.display = 'block'; } if (obj.response.logContainsMandatory == 0) { @@ -269,16 +270,14 @@ function updateProgress() { ×

Log contains Errors

-
+ - -
+ -
From 988e06cd7339ebcfab2557cf1fe4a46425083c25 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 7 Sep 2024 23:23:35 +0200 Subject: [PATCH 639/644] Some fixes --- views/job/detail.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 387e9b8b04..7627a607f3 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -99,12 +99,13 @@ function updateAll() { $('#errors').text(obj.response.logErrorCount); $('#warnings').text(obj.response.logWarningCount); - if (obj.response.logErrorCount >= 1) { - document.getElementById('logErrorBanner').style.display = 'block'; - } if (obj.response.logWarningCount >= 1 && obj.response.logErrorCount < 1) { document.getElementById('logWarningBanner').style.display = 'block'; } + if (obj.response.logErrorCount >= 1) { + document.getElementById('logWarningBanner').style.display = 'none'; + document.getElementById('logErrorBanner').style.display = 'block'; + } if (obj.response.logContainsMandatory == 0) { document.getElementById('logMandatoryBanner').style.display = 'block'; } From 9fc70b7b08f57ae7f369f1abed7d77a10186e44b Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 7 Sep 2024 23:25:51 +0200 Subject: [PATCH 640/644] Some fixes --- views/job/detail.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index 7627a607f3..db1f343ca1 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -108,9 +108,6 @@ function updateAll() { } if (obj.response.logContainsMandatory == 0) { document.getElementById('logMandatoryBanner').style.display = 'block'; - } - if (obj.response.usedOutdatedPatterns == true) { - document.getElementById('logOutdatedBanner').style.display = 'block'; } }); } @@ -275,10 +272,12 @@ function updateProgress() { ×

Log contains Warnings

-
From 683afdf6c95049c1044f505fc77ad66c3fd35e22 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 7 Sep 2024 23:26:28 +0200 Subject: [PATCH 641/644] Some fixes --- views/job/detail.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/job/detail.php b/views/job/detail.php index db1f343ca1..81aef393bd 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -260,10 +260,12 @@ function updateProgress() {

+ + - -
+ -
From f3e4919f2093ef3a6dbd77756e068598d054a644 Mon Sep 17 00:00:00 2001 From: PatrikB Date: Sat, 7 Sep 2024 23:35:17 +0200 Subject: [PATCH 642/644] Some fixes --- views/job/detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/job/detail.php b/views/job/detail.php index 81aef393bd..398c40cb05 100644 --- a/views/job/detail.php +++ b/views/job/detail.php @@ -261,7 +261,7 @@ function updateProgress() {
-