1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-08 14:16:42 +02:00

Allow other separators for the date format in RotatingFileHandler

This commit is contained in:
Jordi Boggiano
2016-07-29 04:03:22 +02:00
parent 55841909e2
commit a6ecf50e74

View File

@@ -68,11 +68,12 @@ class RotatingFileHandler extends StreamHandler
public function setFilenameFormat($filenameFormat, $dateFormat) public function setFilenameFormat($filenameFormat, $dateFormat)
{ {
if (!in_array($dateFormat, array(self::FILE_PER_DAY, self::FILE_PER_MONTH, self::FILE_PER_YEAR))) { if (!preg_match('{^Y(([/_.-]m)([/_.-]d)?)?$}', $dateFormat)) {
trigger_error( trigger_error(
'Invalid date format - format should be one of '. 'Invalid date format - format must be one of '.
'RotatingFileHandler::FILE_PER_DAY, RotatingFileHandler::FILE_PER_MONTH '. 'RotatingFileHandler::FILE_PER_DAY ("Y-m-d"), RotatingFileHandler::FILE_PER_MONTH ("Y-m")'.
'or RotatingFileHandler::FILE_PER_YEAR.', 'or RotatingFileHandler::FILE_PER_YEAR ("Y"), or you can set one of the '.
'date formats using slashes, underscores and/or dots instead of dashes.',
E_USER_DEPRECATED E_USER_DEPRECATED
); );
} }