Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop' of git://github.com/zendframework/zf2 into hot…
Browse files Browse the repository at this point in the history
…fix/cache-empty-namespace
  • Loading branch information
Show file tree
Hide file tree
Showing 47 changed files with 1,985 additions and 101 deletions.
10 changes: 9 additions & 1 deletion src/Formatter/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,18 @@ class Base implements FormatterInterface
* Class constructor
*
* @see http://php.net/manual/en/function.date.php
* @param null|string $dateTimeFormat Format for DateTime objects
* @param null|string|array|Traversable $dateTimeFormat Format for DateTime objects
*/
public function __construct($dateTimeFormat = null)
{
if ($dateTimeFormat instanceof Traversable) {
$dateTimeFormat = iterator_to_array($dateTimeFormat);
}

if (is_array($dateTimeFormat)) {
$dateTimeFormat = isset($dateTimeFormat['dateTimeFormat'])? $dateTimeFormat['dateTimeFormat'] : null;
}

if (null !== $dateTimeFormat) {
$this->dateTimeFormat = $dateTimeFormat;
}
Expand Down
51 changes: 51 additions & 0 deletions src/Formatter/ChromePhp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Log
*/

namespace Zend\Log\Formatter;

/**
* @category Zend
* @package Zend_Log
* @subpackage Formatter
*/
class ChromePhp implements FormatterInterface
{
/**
* Formats the given event data into a single line to be written by the writer.
*
* @param array $event The event data which should be formatted.
* @return string
*/
public function format($event)
{
return $event['message'];
}

/**
* This method is implemented for FormatterInterface but not used.
*
* @return string
*/
public function getDateTimeFormat()
{
return '';
}

/**
* This method is implemented for FormatterInterface but not used.
*
* @param string $dateTimeFormat
* @return FormatterInterface
*/
public function setDateTimeFormat($dateTimeFormat)
{
return $this;
}
}
9 changes: 9 additions & 0 deletions src/Formatter/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Zend\Log\Formatter;

use DateTime;
use Traversable;

/**
* @category Zend
Expand All @@ -35,6 +36,14 @@ class Db implements FormatterInterface
*/
public function __construct($dateTimeFormat = null)
{
if ($dateTimeFormat instanceof Traversable) {
$dateTimeFormat = iterator_to_array($dateTimeFormat);
}

if (is_array($dateTimeFormat)) {
$dateTimeFormat = isset($dateTimeFormat['dateTimeFormat'])? $dateTimeFormat['dateTimeFormat'] : null;
}

if (null !== $dateTimeFormat) {
$this->setDateTimeFormat($dateTimeFormat);
}
Expand Down
16 changes: 12 additions & 4 deletions src/Formatter/FirePhp.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ class FirePhp implements FormatterInterface
/**
* Formats the given event data into a single line to be written by the writer.
*
* @param array $event The event data which should be formatted.
* @return string
* @param array $event The event data which should be formatted.
* @return array line message and optionally label if 'extra' data exists.
*/
public function format($event)
{
return $event['message'];
$label = null;
if ( !empty($event['extra']) ) {
$line = $event['extra'];
$label = $event['message'];
} else {
$line = $event['message'];
}

return array($line, $label);
}

/**
Expand All @@ -41,7 +49,7 @@ public function getDateTimeFormat()
/**
* This method is implemented for FormatterInterface but not used.
*
* @param string $dateTimeFormat
* @param string $dateTimeFormat
* @return FormatterInterface
*/
public function setDateTimeFormat($dateTimeFormat)
Expand Down
10 changes: 10 additions & 0 deletions src/Formatter/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Zend\Log\Formatter;

use Traversable;
use Zend\Log\Exception;

/**
Expand Down Expand Up @@ -38,6 +39,15 @@ class Simple extends Base
*/
public function __construct($format = null, $dateTimeFormat = null)
{
if ($format instanceof Traversable) {
$format = iterator_to_array($format);
}

if (is_array($format)) {
$dateTimeFormat = isset($format['dateTimeFormat'])? $format['dateTimeFormat'] : null;
$format = isset($format['format'])? $format['format'] : null;
}

if (isset($format) && !is_string($format)) {
throw new Exception\InvalidArgumentException('Format must be a string');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Formatter/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function format($event)
} elseif ($key == "extra" && empty($value)) {
continue;
}
$elt->appendChild(new DOMElement($key, (string)$value));
$elt->appendChild(new DOMElement($key, (string) $value));
}
}

Expand Down
Loading

0 comments on commit 7ad896f

Please sign in to comment.