[Legacy] Update install logger format

This commit is contained in:
Clemente Raposo 2025-01-27 16:48:17 +00:00 committed by Jack Anderson
parent 86182c7983
commit c8cca0ac99
2 changed files with 44 additions and 4 deletions

View file

@ -81,7 +81,7 @@ class SugarLogger implements LoggerTemplate
"%m_%Y" => "Month_Year",
"%d_%m" => "Day_Month",
"%m_%d_%y" => "Month_Day_Year",
);
);
/**
* Let's us know if we've initialized the logger file
@ -246,14 +246,14 @@ class SugarLogger implements LoggerTemplate
IntlDateFormatter::MEDIUM,
$timezone,
IntlDateFormatter::GREGORIAN,
"EEE MMM d yyyy 'at' HH:mm:ss",
$this->getDateFormatString(),
);
//write out to the file including the time in the dateFormat the process id , the user id , and the log level as well as the message
fwrite(
$this->fp,
$format->format(time()) . ' [' . getmypid() . '][' . $userID . '][' . strtoupper($level) . '] ' . $message . "\n"
);
$this->formatLog($format, $userID, $level, $message)
);
}
/**
@ -319,4 +319,24 @@ class SugarLogger implements LoggerTemplate
$this->fp = false;
}
}
/**
* @return string
*/
protected function getDateFormatString(): string
{
return "EEE MMM d yyyy 'at' HH:mm:ss";
}
/**
* @param IntlDateFormatter $format
* @param string $userID
* @param $level
* @param mixed $message
* @return string
*/
protected function formatLog(IntlDateFormatter $format, string $userID, $level, mixed $message): string
{
return $format->format(time()) . ' [' . getmypid() . '][' . $userID . '][' . strtoupper($level) . '] ' . $message . "\n";
}
}

View file

@ -53,4 +53,24 @@ class InstallLogger extends SugarLogger
$this->_doInitialization();
InstallLoggerManager::setLogger('default', 'InstallLogger');
}
/**
* @return string
*/
protected function getDateFormatString(): string
{
return "[YYYY-MM-DD HH:mm:ss]";
}
/**
* @param IntlDateFormatter $format
* @param string $userID
* @param $level
* @param mixed $message
* @return string
*/
protected function formatLog(IntlDateFormatter $format, string $userID, $level, mixed $message): string
{
return $format->format(time()) . ' install.' . strtoupper($level) . ': ' . $message . "\n";
}
}