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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2 into ZF2-377
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-mabe committed Jul 17, 2012
6 parents c655082 + 97a9134 + 4d4dd8b + dbb18b2 + 80367df + 98d5255 commit d8cde75
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
6 changes: 5 additions & 1 deletion src/Filter/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Zend\Log\Filter;

use Zend\Log\Exception;
use Zend\Stdlib\ErrorHandler;

/**
* @category Zend
Expand All @@ -35,7 +36,10 @@ class Regex implements FilterInterface
*/
public function __construct($regex)
{
if (@preg_match($regex, '') === false) {
ErrorHandler::start(E_WARNING);
$result = preg_match($regex, '');
ErrorHandler::stop();
if ($result === false) {
throw new Exception\InvalidArgumentException(sprintf(
'Invalid regular expression "%s"',
$regex
Expand Down
6 changes: 5 additions & 1 deletion src/Writer/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Zend\Log\Exception;
use Zend\Log\Formatter\Simple as SimpleFormatter;
use Zend\Stdlib\ErrorHandler;

/**
* @category Zend
Expand Down Expand Up @@ -87,7 +88,10 @@ protected function doWrite(array $event)
{
$line = $this->formatter->format($event);

if (false === @fwrite($this->stream, $line)) {
ErrorHandler::start(E_WARNING);
$result = fwrite($this->stream, $line);
ErrorHandler::stop();
if (false === $result) {
throw new Exception\RuntimeException("Unable to write to stream");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/Syslog.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function setFacility($facility)

if (!in_array($facility, $this->validFacilities)) {
throw new Exception\InvalidArgumentException(
'Invalid log facility provided; please see http://php.net/openlog for a list of valid facility values'
'Invalid log facility provided; please see http://php.net/openlog for a list of valid facility values'
);
}

Expand Down
20 changes: 10 additions & 10 deletions test/Formatter/SimpleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testDefaultFormat()
$this->assertContains((string)$fields['priority'], $line);
}

function testComplexValues()
public function testComplexValues()
{
$fields = array('timestamp' => 0,
'priority' => 42,
Expand Down Expand Up @@ -90,15 +90,15 @@ function testComplexValues()
*/
public function testDefaultFormatShouldDisplayExtraInformations()
{
$message = 'custom message';
$exception = new \RuntimeException($message);
$event = array(
'timestamp' => date('c'),
'message' => 'Application error',
'priority' => 2,
'priorityName' => 'CRIT',
'info' => $exception,
);
$message = 'custom message';
$exception = new \RuntimeException($message);
$event = array(
'timestamp' => date('c'),
'message' => 'Application error',
'priority' => 2,
'priorityName' => 'CRIT',
'info' => $exception,
);

$formatter = new Simple();
$output = $formatter->format($event);
Expand Down
2 changes: 1 addition & 1 deletion test/Writer/DbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function testShutdownRemovesReferenceToDatabaseInstance()
*/
public function testThrowStrictSetFormatter()
{
$this->setExpectedException('PHPUnit_Framework_Error');
$this->setExpectedException('PHPUnit_Framework_Error');
$this->writer->setFormatter(new \StdClass());
}
}

0 comments on commit d8cde75

Please sign in to comment.