Skip to content
Snippets Groups Projects
Commit dfbb7e65 authored by Thijs Kinkhorst's avatar Thijs Kinkhorst
Browse files

Change logging date formatting string from strftime() to date().

strftime is deprecated and will be removed in PHP 9. SSP 2.0 is our
chance to change this format as it's exposed to installers of SSP.

The approch is to keep it simple and just change the format to PHP's
built in date() function which remains supported. Also we do not try
to localize the logging date/timestamps anymore. This matches the syslog
approach that this format tried to mimic. We are using the day without
leading zeroes now also to be a bit closer to how syslog does it.
parent 05f4997e
Branches
Tags
No related merge requests found
...@@ -302,7 +302,7 @@ $config = [ ...@@ -302,7 +302,7 @@ $config = [
* are: * are:
* *
* - %date{<format>}: the date and time, with its format specified inside the brackets. See the PHP documentation * - %date{<format>}: the date and time, with its format specified inside the brackets. See the PHP documentation
* of the strftime() function for more information on the format. If the brackets are omitted, the standard * of the date() function for more information on the format. If the brackets are omitted, the standard
* format is applied. This can be useful if you just want to control the placement of the date, but don't care * format is applied. This can be useful if you just want to control the placement of the date, but don't care
* about the format. * about the format.
* *
...@@ -322,7 +322,7 @@ $config = [ ...@@ -322,7 +322,7 @@ $config = [
* - %msg: the message to be logged. * - %msg: the message to be logged.
* *
*/ */
//'logging.format' => '%date{%b %d %H:%M:%S} %process %level %stat[%trackid] %msg', //'logging.format' => '%date{M j H:i:s} %process %level %stat[%trackid] %msg',
/* /*
* Choose which facility should be used when logging with syslog. * Choose which facility should be used when logging with syslog.
......
...@@ -34,7 +34,10 @@ Configuration changes ...@@ -34,7 +34,10 @@ Configuration changes
--------------------- ---------------------
Quite some options have been changed or removed. We recommend to start with a fresh Quite some options have been changed or removed. We recommend to start with a fresh
template from `config-templates/` and migrate the settings you require to the new template from `config-templates/` and migrate the settings you require to the new
config file= manualy. config file manualy.
The date formatting when specifying a custom logging string has been changed from PHP's
deprecated `strftime()` format to PHP's `date()` format.
Configuration options that have been removed: Configuration options that have been removed:
- languages[priorities] - languages[priorities]
......
...@@ -91,7 +91,7 @@ class Logger ...@@ -91,7 +91,7 @@ class Logger
* general the options are: * general the options are:
* *
* - %date{<format>}: the date and time, with its format specified inside the brackets. See the PHP documentation * - %date{<format>}: the date and time, with its format specified inside the brackets. See the PHP documentation
* of the strftime() function for more information on the format. If the brackets are omitted, the standard * of the date() function for more information on the format. If the brackets are omitted, the standard
* format is applied. This can be useful if you just want to control the placement of the date, but don't care * format is applied. This can be useful if you just want to control the placement of the date, but don't care
* about the format. * about the format.
* *
...@@ -113,7 +113,7 @@ class Logger ...@@ -113,7 +113,7 @@ class Logger
* *
* @var string The format of the log line. * @var string The format of the log line.
*/ */
private static string $format = '%date{%b %d %H:%M:%S} %process %level %stat[%trackid] %msg'; private static string $format = '%date{M j H:i:s} %process %level %stat[%trackid] %msg';
/** /**
* This variable tells if we have a shutdown function registered or not. * This variable tells if we have a shutdown function registered or not.
......
...@@ -112,13 +112,13 @@ class FileLoggingHandler implements LoggingHandlerInterface ...@@ -112,13 +112,13 @@ class FileLoggingHandler implements LoggingHandlerInterface
$matches = []; $matches = [];
if (preg_match('/%date(?:\{([^\}]+)\})?/', $this->format, $matches)) { if (preg_match('/%date(?:\{([^\}]+)\})?/', $this->format, $matches)) {
$format = "%b %d %H:%M:%S"; $format = "M j H:i:s";
if (isset($matches[1])) { if (isset($matches[1])) {
$format = $matches[1]; $format = $matches[1];
} }
array_push($formats, $matches[0]); array_push($formats, $matches[0]);
array_push($replacements, strftime($format)); array_push($replacements, date($format));
} }
$string = str_replace($formats, $replacements, $string); $string = str_replace($formats, $replacements, $string);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment