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

Commit

Permalink
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 39 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.4-dev",
"dev-develop": "2.5-dev"
"dev-master": "2.1-dev",
"dev-develop": "2.2-dev"
}
},
"autoload-dev": {
Expand Down
1 change: 1 addition & 0 deletions src/Filter/SuppressFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Zend\Log\Filter;

use Traversable;
use Zend\Log\Exception;

class SuppressFilter implements FilterInterface
Expand Down
16 changes: 8 additions & 8 deletions src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ public function __construct(array $options = null)
}

if (is_array($options)) {
if (isset($options['writers']) && is_array($options['writers'])) {
foreach ($options['writers'] as $writer) {

if(isset($options['writers']) && is_array($options['writers'])) {
foreach($options['writers'] as $writer) {

if(!isset($writer['name'])) {
if (!isset($writer['name'])) {
throw new Exception\InvalidArgumentException('Options must contain a name for the writer');
}

Expand All @@ -147,11 +146,11 @@ public function __construct(array $options = null)
}
}

if(isset($options['exceptionhandler']) && $options['exceptionhandler'] === true) {
if (isset($options['exceptionhandler']) && $options['exceptionhandler'] === true) {
self::registerExceptionHandler($this);
}

if(isset($options['errorhandler']) && $options['errorhandler'] === true) {
if (isset($options['errorhandler']) && $options['errorhandler'] === true) {
self::registerErrorHandler($this);
}

Expand Down Expand Up @@ -238,7 +237,8 @@ public function addWriter($writer, $priority = 1, array $options = null)
$writer = $this->writerPlugin($writer, $options);
} elseif (!$writer instanceof Writer\WriterInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'Writer must implement Zend\Log\Writer; received "%s"',
'Writer must implement %s\Writer\WriterInterface; received "%s"',
__NAMESPACE__,
is_object($writer) ? get_class($writer) : gettype($writer)
));
}
Expand Down Expand Up @@ -410,7 +410,7 @@ public function log($priority, $message, $extra = array())
'extra' => $extra
);

foreach($this->processors->toArray() as $processor) {
foreach ($this->processors->toArray() as $processor) {
$event = $processor->process($event);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Processor/ProcessorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface ProcessorInterface
* Processes a log message before it is given to the writers
*
* @param array $event
* @return WriterInterface
* @return array
*/
public function process(array $event);

Expand Down
30 changes: 15 additions & 15 deletions src/Writer/AbstractWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class AbstractWriter implements WriterInterface
/**
* Formats the log message before writing
*
* @var Formatter
* @var Formatter\FormatterInterface
*/
protected $formatter;

Expand Down Expand Up @@ -77,17 +77,16 @@ public function __construct($options = null)
}

if (is_array($options)) {

if(isset($options['filters'])) {
if (isset($options['filters'])) {
$filters = $options['filters'];
if(is_string($filters) || $filters instanceof Filter\FilterInterface) {
if (is_string($filters) || $filters instanceof Filter\FilterInterface) {
$this->addFilter($filters);
} elseif(is_array($filters)) {
foreach($filters as $filter) {
if(is_string($filter) || $filter instanceof Filter\FilterInterface) {
} elseif (is_array($filters)) {
foreach ($filters as $filter) {
if (is_string($filter) || $filter instanceof Filter\FilterInterface) {
$this->addFilter($filter);
} elseif(is_array($filter)) {
if(!isset($filter['name'])) {
} elseif (is_array($filter)) {
if (!isset($filter['name'])) {
throw new Exception\InvalidArgumentException('Options must contain a name for the filter');
}
$filterOptions = (isset($filter['options'])) ? $filter['options'] : null;
Expand All @@ -97,12 +96,12 @@ public function __construct($options = null)
}
}

if(isset($options['formatter'])) {
if (isset($options['formatter'])) {
$formatter = $options['formatter'];
if(is_string($formatter) || $formatter instanceof Formatter\FormatterInterface) {
if (is_string($formatter) || $formatter instanceof Formatter\FormatterInterface) {
$this->setFormatter($formatter);
} elseif(is_array($formatter)) {
if(!isset($formatter['name'])) {
} else if(is_array($formatter)) {
if (!isset($formatter['name'])) {
throw new Exception\InvalidArgumentException('Options must contain a name for the formatter');
}
$formatterOptions = (isset($formatter['options'])) ? $formatter['options'] : null;
Expand Down Expand Up @@ -132,7 +131,7 @@ public function addFilter($filter, array $options = null)

if (!$filter instanceof Filter\FilterInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'Writer must implement %s\Filter\FilterInterface; received "%s"',
'Filter must implement %s\Filter\FilterInterface; received "%s"',
__NAMESPACE__,
is_object($filter) ? get_class($filter) : gettype($filter)
));
Expand Down Expand Up @@ -285,6 +284,7 @@ public function write(array $event)
* Set a new formatter for this writer
*
* @param string|Formatter\FormatterInterface $formatter
* @param array|null $options
* @return self
* @throws Exception\InvalidArgumentException
*/
Expand All @@ -309,7 +309,7 @@ public function setFormatter($formatter, array $options = null)
/**
* Set convert write errors to exception flag
*
* @param bool $ignoreWriteErrors
* @param bool $convertErrors
*/
public function setConvertWriteErrorsToExceptions($convertErrors)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/ChromePhp.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct($instance = null)
$instance = isset($instance['instance']) ? $instance['instance'] : null;
}

if(!($instance instanceof ChromePhpInterface || $instance === null)) {
if (!($instance instanceof ChromePhpInterface || $instance === null)) {
throw new Exception\InvalidArgumentException('You must pass a valid Zend\Log\Writer\ChromePhp\ChromePhpInterface');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Writer/ChromePhp/ChromePhpBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function info($line)
*/
public function trace($line)
{
ChromePhp::error($line);
ChromePhp::log($line);
}

/**
Expand Down
13 changes: 7 additions & 6 deletions src/Writer/FingersCrossed.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ public function __construct($writer, $filterOrPriority = null, $bufferSize = 0)
}

/**
* Set a new formatter for this writer
* Set a new writer
*
* @param string|Formatter\FormatterInterface $formatter
* @param string|WriterInterface $writer
* @param array|null $options
* @return self
* @throws Exception\InvalidArgumentException
*/
Expand All @@ -114,7 +115,7 @@ public function setWriter($writer, array $options = null)

if (!$writer instanceof WriterInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'Formatter must implement %s\Formatter\FormatterInterface; received "%s"',
'Writer must implement %s\WriterInterface; received "%s"',
__NAMESPACE__,
is_object($writer) ? get_class($writer) : gettype($writer)
));
Expand All @@ -141,7 +142,7 @@ public function getWriterPluginManager()
* Set writer plugin manager
*
* @param string|WriterPluginManager $plugins
* @return Logger
* @return FingersCrossed
* @throws Exception\InvalidArgumentException
*/
public function setWriterPluginManager($plugins)
Expand All @@ -166,7 +167,7 @@ public function setWriterPluginManager($plugins)
*
* @param string $name
* @param array|null $options
* @return Writer\WriterInterface
* @return WriterInterface
*/
public function writerPlugin($name, array $options = null)
{
Expand Down Expand Up @@ -243,7 +244,7 @@ public function reset()
* Stub in accordance to parent method signature.
* Fomatters must be set on the wrapped writer.
*
* @param string|Formatter\FormatterInterface $formatter
* @param string|FormatterInterface $formatter
* @return WriterInterface
*/
public function setFormatter($formatter)
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function __construct($mail, Transport\TransportInterface $transport = nul
}
$this->setTransport($transport);

if($this->formatter === null) {
if ($this->formatter === null) {
$this->formatter = new SimpleFormatter();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Writer/MongoDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __construct($mongo, $database = null, $collection = null, array
/**
* This writer does not support formatting.
*
* @param string|Zend\Log\Formatter\FormatterInterface $formatter
* @param string|FormatterInterface $formatter
* @return WriterInterface
*/
public function setFormatter($formatter)
Expand All @@ -100,7 +100,7 @@ public function setFormatter($formatter)
*
* @param array $event Event data
* @return void
* @throws Zend\Log\Exception\RuntimeException
* @throws Exception\RuntimeException
*/
protected function doWrite(array $event)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function __construct($streamOrUrl, $mode = null, $logSeparator = null)
$this->setLogSeparator($logSeparator);
}

if($this->formatter === null) {
if ($this->formatter === null) {
$this->formatter = new SimpleFormatter();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/Syslog.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function __construct($params = null)
$this->initializeSyslog();
}

if($this->formatter === null) {
if ($this->formatter === null) {
$this->setFormatter(new SimpleFormatter('%message%'));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Writer/ZendMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ZendMonitor extends AbstractWriter
/**
* Constructor
*
* @param array|\Traversable|null $options
* @return ZendMonitor
*/
public function __construct($options = null)
Expand Down

0 comments on commit beb6598

Please sign in to comment.