diff --git a/phalcon/logger/formatter/json.zep b/phalcon/logger/formatter/json.zep index 352a25fd6fe..6a1ab5fc285 100644 --- a/phalcon/logger/formatter/json.zep +++ b/phalcon/logger/formatter/json.zep @@ -20,6 +20,25 @@ use Phalcon\Logger\Item; */ class Json extends AbstractFormatter { + /** + * Default date format + * + * @var string + */ + protected dateFormat = "D, d M y H:i:s O" { get, set }; + + /** + * Phalcon\Logger\Formatter\Json construct + * + * @param string dateFormat + */ + public function __construct(string dateFormat = "") -> void + { + if dateFormat { + let this->dateFormat = dateFormat; + } + } + /** * Applies a format to a message before sent it to the internal log * @@ -41,8 +60,8 @@ class Json extends AbstractFormatter [ "type" : item->getName(), "message" : message, - "timestamp" : item->getTime() + "timestamp" : date(this->dateFormat, item->getTime()) ] - ) . PHP_EOL; + ); } } diff --git a/phalcon/logger/formatter/line.zep b/phalcon/logger/formatter/line.zep index bf622b6d1c0..ae64d708006 100644 --- a/phalcon/logger/formatter/line.zep +++ b/phalcon/logger/formatter/line.zep @@ -20,7 +20,6 @@ use Phalcon\Logger\Item; */ class Line extends AbstractFormatter { - /** * Default date format * @@ -41,7 +40,7 @@ class Line extends AbstractFormatter * @param string format * @param string dateFormat */ - public function __construct(format = null, dateFormat = null) + public function __construct(string format = "", string dateFormat = "") -> void { if format { let this->format = format; diff --git a/tests/unit/Logger/Formatter/AbstractFormatter/FormatCest.php b/tests/unit/Logger/Formatter/AbstractFormatter/FormatCest.php deleted file mode 100644 index 0ca36574f6e..00000000000 --- a/tests/unit/Logger/Formatter/AbstractFormatter/FormatCest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Unit\Logger\Formatter\AbstractFormatter; - -use UnitTester; - -/** - * Class FormatCest - * - * @package Phalcon\Test\Unit\Logger - */ -class FormatCest -{ - /** - * Tests Phalcon\Logger\Formatter\AbstractFormatter :: format() - * - * @param UnitTester $I - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function loggerFormatterAbstractformatterFormat(UnitTester $I) - { - $I->wantToTest("Logger\Formatter\AbstractFormatter - format()"); - $I->skipTest("Need implementation"); - } -} diff --git a/tests/unit/Logger/Formatter/AbstractFormatter/InterpolateCest.php b/tests/unit/Logger/Formatter/AbstractFormatter/InterpolateCest.php deleted file mode 100644 index c7c0b719b5f..00000000000 --- a/tests/unit/Logger/Formatter/AbstractFormatter/InterpolateCest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Unit\Logger\Formatter\AbstractFormatter; - -use UnitTester; - -/** - * Class InterpolateCest - * - * @package Phalcon\Test\Unit\Logger - */ -class InterpolateCest -{ - /** - * Tests Phalcon\Logger\Formatter\AbstractFormatter :: interpolate() - * - * @param UnitTester $I - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function loggerFormatterAbstractformatterInterpolate(UnitTester $I) - { - $I->wantToTest("Logger\Formatter\AbstractFormatter - interpolate()"); - $I->skipTest("Need implementation"); - } -}