1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-08 06:06:40 +02:00
This commit is contained in:
Jordi Boggiano
2015-07-14 10:25:17 +01:00
parent cf6fa57dd4
commit ca1376bd61
20 changed files with 42 additions and 41 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@ composer.phar
phpunit.xml phpunit.xml
composer.lock composer.lock
.DS_Store .DS_Store
.php_cs.cache

View File

@@ -33,7 +33,6 @@ class Util
{ {
while ($retries--) { while ($retries--) {
if (curl_exec($ch) === false) { if (curl_exec($ch) === false) {
if (false === in_array(curl_errno($ch), self::$retriableErrorCodes, true) || !$retries) { if (false === in_array(curl_errno($ch), self::$retriableErrorCodes, true) || !$retries) {
if ($closeAfterDone) { if ($closeAfterDone) {
curl_close($ch); curl_close($ch);

View File

@@ -240,4 +240,3 @@ class PHPConsoleHandler extends AbstractProcessingHandler
return new LineFormatter('%message%'); return new LineFormatter('%message%');
} }
} }

View File

@@ -167,7 +167,6 @@ class RavenHandler extends AbstractProcessingHandler
if ($previousUserContext !== false) { if ($previousUserContext !== false) {
$this->ravenClient->user_context($previousUserContext); $this->ravenClient->user_context($previousUserContext);
} }
} }
/** /**

View File

@@ -56,8 +56,7 @@ class RedisHandler extends AbstractProcessingHandler
*/ */
protected function write(array $record) protected function write(array $record)
{ {
if ($this->capSize) if ($this->capSize) {
{
$this->writeCapped($record); $this->writeCapped($record);
} else { } else {
$this->redisClient->rpush($this->redisKey, $record["formatted"]); $this->redisClient->rpush($this->redisKey, $record["formatted"]);

View File

@@ -219,6 +219,7 @@ class SlackHandler extends SocketHandler
if ($this->iconEmoji) { if ($this->iconEmoji) {
$dataArray['icon_emoji'] = ":{$this->iconEmoji}:"; $dataArray['icon_emoji'] = ":{$this->iconEmoji}:";
} }
return $dataArray; return $dataArray;
} }

View File

@@ -11,8 +11,6 @@
namespace Monolog\Handler; namespace Monolog\Handler;
use Monolog\Logger;
/** /**
* Used for testing purposes. * Used for testing purposes.
* *
@@ -133,7 +131,6 @@ class TestHandler extends AbstractProcessingHandler
$this->records[] = $record; $this->records[] = $record;
} }
public function __call($method, $args) public function __call($method, $args)
{ {
if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
@@ -141,6 +138,7 @@ class TestHandler extends AbstractProcessingHandler
$level = constant('Monolog\Logger::' . strtoupper($matches[2])); $level = constant('Monolog\Logger::' . strtoupper($matches[2]));
if (method_exists($this, $genericMethod)) { if (method_exists($this, $genericMethod)) {
$args[] = $level; $args[] = $level;
return call_user_func_array(array($this, $genericMethod), $args); return call_user_func_array(array($this, $genericMethod), $args);
} }
} }

View File

@@ -157,6 +157,7 @@ class Logger implements LoggerInterface
public function pushHandler(HandlerInterface $handler) public function pushHandler(HandlerInterface $handler)
{ {
array_unshift($this->handlers, $handler); array_unshift($this->handlers, $handler);
return $this; return $this;
} }
@@ -194,6 +195,7 @@ class Logger implements LoggerInterface
throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given'); throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given');
} }
array_unshift($this->processors, $callback); array_unshift($this->processors, $callback);
return $this; return $this;
} }

View File

@@ -47,7 +47,8 @@ class HipChatHandlerTest extends TestCase
return $content; return $content;
} }
public function testWriteV2() { public function testWriteV2()
{
$this->createHandler('myToken', 'room1', 'Monolog', false, 'hipchat.foo.bar', 'v2'); $this->createHandler('myToken', 'room1', 'Monolog', false, 'hipchat.foo.bar', 'v2');
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
fseek($this->res, 0); fseek($this->res, 0);
@@ -58,7 +59,8 @@ class HipChatHandlerTest extends TestCase
return $content; return $content;
} }
public function testWriteV2Notify() { public function testWriteV2Notify()
{
$this->createHandler('myToken', 'room1', 'Monolog', true, 'hipchat.foo.bar', 'v2'); $this->createHandler('myToken', 'room1', 'Monolog', true, 'hipchat.foo.bar', 'v2');
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
fseek($this->res, 0); fseek($this->res, 0);
@@ -69,7 +71,8 @@ class HipChatHandlerTest extends TestCase
return $content; return $content;
} }
public function testRoomSpaces() { public function testRoomSpaces()
{
$this->createHandler('myToken', 'room name', 'Monolog', false, 'hipchat.foo.bar', 'v2'); $this->createHandler('myToken', 'room name', 'Monolog', false, 'hipchat.foo.bar', 'v2');
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
fseek($this->res, 0); fseek($this->res, 0);
@@ -233,7 +236,8 @@ class HipChatHandlerTest extends TestCase
$hipChatHandler = new \Monolog\Handler\HipChatHandler('token', 'room', 'SixteenCharsHere'); $hipChatHandler = new \Monolog\Handler\HipChatHandler('token', 'room', 'SixteenCharsHere');
} }
public function testCreateWithTooLongNameV2() { public function testCreateWithTooLongNameV2()
{
// creating a handler with too long of a name but using the v2 api doesn't matter. // creating a handler with too long of a name but using the v2 api doesn't matter.
$hipChatHandler = new \Monolog\Handler\HipChatHandler('token', 'room', 'SixteenCharsHere', false, Logger::CRITICAL, true, true, 'test', 'api.hipchat.com', 'v2'); $hipChatHandler = new \Monolog\Handler\HipChatHandler('token', 'room', 'SixteenCharsHere', false, Logger::CRITICAL, true, true, 'test', 'api.hipchat.com', 'v2');
} }

View File

@@ -11,7 +11,6 @@
namespace Monolog; namespace Monolog;
class RegistryTest extends \PHPUnit_Framework_TestCase class RegistryTest extends \PHPUnit_Framework_TestCase
{ {
protected function setUp() protected function setUp()