Skip to content

Commit

Permalink
SubmitLog : Fix date format for non event logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMis committed Apr 16, 2024
1 parent 549d664 commit 20dca7f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/Xmds/Soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ protected function doSubmitLog($serverKey, $hardwareKey, $logXml)
}

// Adjust the date according to the display timezone
$date = $this->adjustDisplayLogDate($date);
$date = $this->adjustDisplayLogDate($date, DateFormatHelper::getSystemFormat());

// Get the date and the message (all log types have these)
foreach ($node->childNodes as $nodeElements) {
Expand Down Expand Up @@ -3042,9 +3042,10 @@ protected function setDateFilters()
* Adjust the log date according to the Display timezone.
* Return current date if we fail.
* @param string $date
* @param string $format
* @return string
*/
protected function adjustDisplayLogDate(string $date): string
protected function adjustDisplayLogDate(string $date, string $format): string
{
// Get the display timezone to use when adjusting log dates.
$defaultTimeZone = $this->getConfig()->getSetting('defaultTimezone');
Expand All @@ -3061,21 +3062,21 @@ protected function adjustDisplayLogDate(string $date): string
DateFormatHelper::getSystemFormat(),
$date
);
$date = $date->format('U');
$date = $date->format($format);
} catch (\Exception $e) {
// Protect against the date format being unreadable
$this->getLog()->debug('Date format unreadable on log message: ' . $date);

// Use now instead
$date = Carbon::now()->format('U');
$date = Carbon::now()->format($format);
}

return $date;
}

private function createDisplayAlert(\DomElement $alertNode)
{
$date = $this->adjustDisplayLogDate($alertNode->getAttribute('date'));
$date = $this->adjustDisplayLogDate($alertNode->getAttribute('date'), 'U');
$eventType = '';
$refId = '';
$detail = '';
Expand Down

0 comments on commit 20dca7f

Please sign in to comment.