-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log overview and background work #176
Conversation
Thank you for this draft. I reviewed the code and have some suggestions:
|
libraries/logalyzer.php
Outdated
$this->job = $job; | ||
$this->system = new System($this->job->getSystemId()); | ||
$path = UPLOADED_DATA_PATH . '/log/' . $job->getId() . '.log'; | ||
$log = Util::readFileContents($path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong. Do not read the whole file in the constructor, move to readEntireLog.
controllers/evaluation.php
Outdated
$logUtil = new Logalyzer_Library($subJob); | ||
$logUtil->examineLogAndSetAlert(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an artifact, do not analyze all jobs again every time.
libraries/logalyzer.php
Outdated
// 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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not update the Hash every time you initialize the Logalyzer Lib. Set hash when creating job (or even better when writing the first log line, thus when creating the log file) and after checking the entire file.
libraries/logalyzer.php
Outdated
} | ||
public function examineEntireLog() { | ||
// Check if there have been changes to the log | ||
if ($this->checkHashDifference()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
libraries/logalyzer.php
Outdated
$warningCount = 0; | ||
$errorCount = 0; | ||
foreach ($this->warningKeys as $key) { | ||
if(str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store info whether it is a regex in the json.
libraries/logalyzer.php
Outdated
// Log is reexamined using up-to-date keys, save new hash. | ||
$this->job->setLogalyzerCountWarnings($warningCount); | ||
$this->job->setLogalyzerCountErrors($errorCount); | ||
$this->calculateAndSetHash(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calculate in the beginning.
libraries/logalyzer.php
Outdated
public function examineLogLine($logLine) { | ||
if($this->job->getLogalyzerCountWarnings <= 10) { | ||
foreach ($this->warningKeys as $key) { | ||
if (str_starts_with($key, "/") || str_starts_with($key, "#") || str_starts_with($key, "~")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above, store in json
libraries/logalyzer.php
Outdated
} | ||
} | ||
public function examineLogLine($logLine) { | ||
if($this->job->getLogalyzerCountWarnings <= 10) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number, take from settings / config.
libraries/logalyzer.php
Outdated
* @param string $key name of new keyword | ||
* @return void | ||
*/ | ||
public function addKey(string $identifier, string $key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addPattern
libraries/logalyzer.php
Outdated
} | ||
|
||
/** | ||
* @param string $identifier add $key as warning or error? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logLevel
libraries/logalyzer.php
Outdated
* @param string $key name of keyword to be deleted | ||
* @return void | ||
*/ | ||
public function removeKey(string $identifier, string $key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removePattern
Add Column to Job: `logalyzerResults` json Remove Column of Job: 'logalyzerCountError' 'logalyzerCountWarning' 'logalyzerContainsMandatory'
Add Column to Job: `logalyzerResults` json Remove Column of Job: 'logalyzerCountError' 'logalyzerCountWarning' 'logalyzerContainsMandatory'
Job log overview fix
Not intended to be merged. It is in a working, but not very useful state.
Many of the fixed values such as 'thresholdError' will be modifiable for each system in the future.
Added functionality to search a log for keywords, count occurances. These features will be expanded upon
Feedback is welcome