cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

\Phalcon\Logger\Formatter\Line and $dateFormat

Open iforp opened this issue 13 years ago • 2 comments

The documentation says:

Class Phalcon\Logger\Formatter\Line

Methods public __construct ([string $format], [string $dateFormat])

But the second parameter isn't works correctly

$logger  = new \Phalcon\Logger\Adapter\Stream('php://output');
$formatter = new \Phalcon\Logger\Formatter\Line("%date%", 'Y-m-d');
$logger->setFormatter($formatter);
$logger->error('message');
// %28pm28Europe/Moscow%

// expected: 2013-02-28

Other cases

$formatter = new \Phalcon\Logger\Formatter\Line("string", 'Y-m-d');
// string

$formatter = new \Phalcon\Logger\Formatter\Line("%date%-string", 'Y-m-d');
// %28pm28Europe/Moscow%-4428Thu, 28 Feb 2013 16:16:44 +04001624-string

$formatter = new \Phalcon\Logger\Formatter\Line("%date%", true);
// %28pm28Europe/Moscow%

$formatter = new \Phalcon\Logger\Formatter\Line("%date%", false);
// %28pm28Europe/Moscow%

$formatter = new \Phalcon\Logger\Formatter\Line("%date%", null);
// Thu, 28 Feb 13 16:16:44 +0400

iforp avatar Feb 28 '13 12:02 iforp

@Agent-J

You can always use the

$formatter->setFormat('Y-m-d');

Could you be so kind as to create failing tests and submit a pull request for the 1.0.0 branch so that we can fix this?

Thanks!!!

niden avatar Mar 02 '13 17:03 niden

This is fixed in the 1.0.0 branch

ghost avatar Mar 03 '13 15:03 ghost