Skip to content

Commit

Permalink
[#13438] - Corrections to the Json formatter; Added date format for it
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed Dec 7, 2018
1 parent aa2cd09 commit 19167c1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 78 deletions.
23 changes: 21 additions & 2 deletions phalcon/logger/formatter/json.zep
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -41,8 +60,8 @@ class Json extends AbstractFormatter
[
"type" : item->getName(),
"message" : message,
"timestamp" : item->getTime()
"timestamp" : date(this->dateFormat, item->getTime())
]
) . PHP_EOL;
);
}
}
3 changes: 1 addition & 2 deletions phalcon/logger/formatter/line.zep
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use Phalcon\Logger\Item;
*/
class Line extends AbstractFormatter
{

/**
* Default date format
*
Expand All @@ -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;
Expand Down
37 changes: 0 additions & 37 deletions tests/unit/Logger/Formatter/AbstractFormatter/FormatCest.php

This file was deleted.

37 changes: 0 additions & 37 deletions tests/unit/Logger/Formatter/AbstractFormatter/InterpolateCest.php

This file was deleted.

0 comments on commit 19167c1

Please sign in to comment.