mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-05 12:47:39 +02:00
Minor CS fixes, updated changelog
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
handle the given log level
|
||||
* Added ChromePHPHandler
|
||||
* Added MongoDBHandler
|
||||
* Added SocketHandler (for use with syslog-ng for example)
|
||||
* Added NormalizerFormatter
|
||||
* Added the possibility to change the activation strategy of the FingersCrossedHandler
|
||||
* Added possibility to show microseconds in logs
|
||||
|
@@ -21,7 +21,6 @@ use Monolog\Logger;
|
||||
*/
|
||||
class SocketHandler extends AbstractProcessingHandler
|
||||
{
|
||||
|
||||
private $connectionString;
|
||||
private $connectionTimeout;
|
||||
private $resource;
|
||||
@@ -61,10 +60,9 @@ class SocketHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
if ($this->isPersistent()) {
|
||||
return;
|
||||
if (!$this->isPersistent()) {
|
||||
$this->closeSocket();
|
||||
}
|
||||
$this->closeSocket();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,11 +162,11 @@ class SocketHandler extends AbstractProcessingHandler
|
||||
public function isConnected()
|
||||
{
|
||||
return is_resource($this->resource)
|
||||
&& !feof($this->resource); // on TCP - other party can close connection.
|
||||
&& !feof($this->resource); // on TCP - other party can close connection.
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow mock
|
||||
* Wrapper to allow mocking
|
||||
*/
|
||||
protected function pfsockopen()
|
||||
{
|
||||
@@ -176,7 +174,7 @@ class SocketHandler extends AbstractProcessingHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow mock
|
||||
* Wrapper to allow mocking
|
||||
*/
|
||||
protected function fsockopen()
|
||||
{
|
||||
@@ -184,15 +182,15 @@ class SocketHandler extends AbstractProcessingHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow mock
|
||||
* Wrapper to allow mocking
|
||||
*/
|
||||
protected function stream_set_timeout()
|
||||
protected function streamSetTimeout()
|
||||
{
|
||||
return stream_set_timeout($this->resource, $this->timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow mock
|
||||
* Wrapper to allow mocking
|
||||
*/
|
||||
protected function fwrite($data)
|
||||
{
|
||||
@@ -200,9 +198,9 @@ class SocketHandler extends AbstractProcessingHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow mock
|
||||
* Wrapper to allow mocking
|
||||
*/
|
||||
protected function stream_get_meta_data()
|
||||
protected function streamGetMetadata()
|
||||
{
|
||||
return stream_get_meta_data($this->resource);
|
||||
}
|
||||
@@ -246,7 +244,7 @@ class SocketHandler extends AbstractProcessingHandler
|
||||
|
||||
private function setSocketTimeout()
|
||||
{
|
||||
if (!$this->stream_set_timeout()) {
|
||||
if (!$this->streamSetTimeout()) {
|
||||
throw new \UnexpectedValueException("Failed setting timeout with stream_set_timeout()");
|
||||
}
|
||||
}
|
||||
@@ -261,7 +259,7 @@ class SocketHandler extends AbstractProcessingHandler
|
||||
throw new \RuntimeException("Could not write to socket");
|
||||
}
|
||||
$sent += $chunk;
|
||||
$socketInfo = $this->stream_get_meta_data();
|
||||
$socketInfo = $this->streamGetMetadata();
|
||||
if ($socketInfo['timed_out']) {
|
||||
throw new \RuntimeException("Write timed-out");
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ use Monolog\Logger;
|
||||
*/
|
||||
class SocketHandlerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Monolog\Handler\SocketHandler
|
||||
*/
|
||||
@@ -107,9 +106,9 @@ class SocketHandlerTest extends TestCase
|
||||
*/
|
||||
public function testExceptionIsThrownIfCannotSetTimeout()
|
||||
{
|
||||
$this->setMockHandler(array('stream_set_timeout'));
|
||||
$this->setMockHandler(array('streamSetTimeout'));
|
||||
$this->handler->expects($this->once())
|
||||
->method('stream_set_timeout')
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(false));
|
||||
$this->writeRecord('Hello world');
|
||||
}
|
||||
@@ -142,7 +141,7 @@ class SocketHandlerTest extends TestCase
|
||||
*/
|
||||
public function testWriteFailsIfStreamTimesOut()
|
||||
{
|
||||
$this->setMockHandler(array('fwrite', 'stream_get_meta_data'));
|
||||
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
||||
|
||||
$callback = function($arg)
|
||||
{
|
||||
@@ -157,7 +156,7 @@ class SocketHandlerTest extends TestCase
|
||||
->method('fwrite')
|
||||
->will($this->returnCallback($callback));
|
||||
$this->handler->expects($this->exactly(1))
|
||||
->method('stream_get_meta_data')
|
||||
->method('streamGetMetadata')
|
||||
->will($this->returnValue(array('timed_out' => true)));
|
||||
|
||||
|
||||
@@ -169,7 +168,7 @@ class SocketHandlerTest extends TestCase
|
||||
*/
|
||||
public function testWriteFailsOnIncompleteWrite()
|
||||
{
|
||||
$this->setMockHandler(array('fwrite', 'stream_get_meta_data'));
|
||||
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
||||
|
||||
$res = $this->res;
|
||||
$callback = function($string) use ($res)
|
||||
@@ -182,7 +181,7 @@ class SocketHandlerTest extends TestCase
|
||||
->method('fwrite')
|
||||
->will($this->returnCallback($callback));
|
||||
$this->handler->expects($this->exactly(1))
|
||||
->method('stream_get_meta_data')
|
||||
->method('streamGetMetadata')
|
||||
->will($this->returnValue(array('timed_out' => false)));
|
||||
|
||||
$this->writeRecord('Hello world');
|
||||
@@ -252,7 +251,7 @@ class SocketHandlerTest extends TestCase
|
||||
{
|
||||
$this->res = fopen('php://memory', 'a');
|
||||
|
||||
$defaultMethods = array('fsockopen', 'pfsockopen', 'stream_set_timeout');
|
||||
$defaultMethods = array('fsockopen', 'pfsockopen', 'streamSetTimeout');
|
||||
$newMethods = array_diff($methods, $defaultMethods);
|
||||
|
||||
$finalMethods = array_merge($defaultMethods, $newMethods);
|
||||
@@ -273,9 +272,9 @@ class SocketHandlerTest extends TestCase
|
||||
->will($this->returnValue($this->res));
|
||||
}
|
||||
|
||||
if (!in_array('stream_set_timeout', $methods)) {
|
||||
if (!in_array('streamSetTimeout', $methods)) {
|
||||
$this->handler->expects($this->any())
|
||||
->method('stream_set_timeout')
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(true));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user