diff --git a/config-templates/config.php b/config-templates/config.php index f76724ef981d8cfa945a599417a2aeaf318b74c3..98c303bf48e63e189a837880a07da701aa7e7ebf 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -302,7 +302,7 @@ $config = [ * are: * * - %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 * about the format. * @@ -322,7 +322,7 @@ $config = [ * - %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. diff --git a/docs/simplesamlphp-upgrade-notes-2.0.md b/docs/simplesamlphp-upgrade-notes-2.0.md index 45a8e8d7ebe0d3de12337d9bd3c0c6b9bad975e9..1749e288e7d7f4d515e0af235edf8a09e1bdc2b6 100644 --- a/docs/simplesamlphp-upgrade-notes-2.0.md +++ b/docs/simplesamlphp-upgrade-notes-2.0.md @@ -34,7 +34,10 @@ Configuration changes --------------------- 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 -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: - languages[priorities] diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php index 7bff0cb2e1d337e590cbd3211e7a44fdd895c7d0..c390ca82e94d2194bd95886ad619cd2d02d1be6e 100644 --- a/lib/SimpleSAML/Logger.php +++ b/lib/SimpleSAML/Logger.php @@ -91,7 +91,7 @@ class Logger * general the options are: * * - %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 * about the format. * @@ -113,7 +113,7 @@ class Logger * * @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. diff --git a/lib/SimpleSAML/Logger/FileLoggingHandler.php b/lib/SimpleSAML/Logger/FileLoggingHandler.php index 44b3dcbf2e97bf9ef77de73008593f9e3331d8c8..c636c7d9479a24474f84f3689d7c48f3879c9061 100644 --- a/lib/SimpleSAML/Logger/FileLoggingHandler.php +++ b/lib/SimpleSAML/Logger/FileLoggingHandler.php @@ -112,13 +112,13 @@ class FileLoggingHandler implements LoggingHandlerInterface $matches = []; if (preg_match('/%date(?:\{([^\}]+)\})?/', $this->format, $matches)) { - $format = "%b %d %H:%M:%S"; + $format = "M j H:i:s"; if (isset($matches[1])) { $format = $matches[1]; } array_push($formats, $matches[0]); - array_push($replacements, strftime($format)); + array_push($replacements, date($format)); } $string = str_replace($formats, $replacements, $string);