mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-03 11:47:38 +02:00
CS fixes
This commit is contained in:
11
.php_cs
11
.php_cs
@@ -24,14 +24,13 @@ return PhpCsFixer\Config::create()
|
|||||||
'@PSR2' => true,
|
'@PSR2' => true,
|
||||||
// some rules disabled as long as 1.x branch is maintained
|
// some rules disabled as long as 1.x branch is maintained
|
||||||
'binary_operator_spaces' => array(
|
'binary_operator_spaces' => array(
|
||||||
'align_double_arrow' => null,
|
'default' => null,
|
||||||
'align_equals' => null,
|
|
||||||
),
|
),
|
||||||
'blank_line_before_return' => true,
|
'blank_line_before_statement' => ['statements' => ['continue', 'declare', 'return', 'throw', 'try']],
|
||||||
'cast_spaces' => true,
|
'cast_spaces' => ['space' => 'single'],
|
||||||
'header_comment' => array('header' => $header),
|
'header_comment' => ['header' => $header],
|
||||||
'include' => true,
|
'include' => true,
|
||||||
'method_separation' => true,
|
'class_attributes_separation' => ['elements' => ['method']],
|
||||||
'no_blank_lines_after_class_opening' => true,
|
'no_blank_lines_after_class_opening' => true,
|
||||||
'no_blank_lines_after_phpdoc' => true,
|
'no_blank_lines_after_phpdoc' => true,
|
||||||
'no_empty_statement' => true,
|
'no_empty_statement' => true,
|
||||||
|
@@ -141,7 +141,8 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
|
|||||||
if (empty($context) && empty($extra)) {
|
if (empty($context) && empty($extra)) {
|
||||||
$script[] = static::call_array('log', static::handleStyles($record['formatted']));
|
$script[] = static::call_array('log', static::handleStyles($record['formatted']));
|
||||||
} else {
|
} else {
|
||||||
$script = array_merge($script,
|
$script = array_merge(
|
||||||
|
$script,
|
||||||
[static::call_array('groupCollapsed', static::handleStyles($record['formatted']))],
|
[static::call_array('groupCollapsed', static::handleStyles($record['formatted']))],
|
||||||
$context,
|
$context,
|
||||||
$extra,
|
$extra,
|
||||||
|
@@ -24,7 +24,6 @@ use Monolog\Logger;
|
|||||||
*/
|
*/
|
||||||
class ChromePHPHandler extends AbstractProcessingHandler
|
class ChromePHPHandler extends AbstractProcessingHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
use WebRequestRecognizerTrait;
|
use WebRequestRecognizerTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -46,7 +46,8 @@ class CubeHandler extends AbstractProcessingHandler
|
|||||||
if (!in_array($urlInfo['scheme'], $this->acceptedSchemes)) {
|
if (!in_array($urlInfo['scheme'], $this->acceptedSchemes)) {
|
||||||
throw new \UnexpectedValueException(
|
throw new \UnexpectedValueException(
|
||||||
'Invalid protocol (' . $urlInfo['scheme'] . ').'
|
'Invalid protocol (' . $urlInfo['scheme'] . ').'
|
||||||
. ' Valid options are ' . implode(', ', $this->acceptedSchemes));
|
. ' Valid options are ' . implode(', ', $this->acceptedSchemes)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->scheme = $urlInfo['scheme'];
|
$this->scheme = $urlInfo['scheme'];
|
||||||
|
@@ -81,6 +81,7 @@ class ElasticSearchHandler extends AbstractProcessingHandler
|
|||||||
if ($formatter instanceof ElasticaFormatter) {
|
if ($formatter instanceof ElasticaFormatter) {
|
||||||
return parent::setFormatter($formatter);
|
return parent::setFormatter($formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException('ElasticSearchHandler is only compatible with ElasticaFormatter');
|
throw new \InvalidArgumentException('ElasticSearchHandler is only compatible with ElasticaFormatter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,6 +40,7 @@ class ErrorLogHandler extends AbstractProcessingHandler
|
|||||||
|
|
||||||
if (false === in_array($messageType, self::getAvailableTypes(), true)) {
|
if (false === in_array($messageType, self::getAvailableTypes(), true)) {
|
||||||
$message = sprintf('The given message type "%s" is not supported', print_r($messageType, true));
|
$message = sprintf('The given message type "%s" is not supported', print_r($messageType, true));
|
||||||
|
|
||||||
throw new \InvalidArgumentException($message);
|
throw new \InvalidArgumentException($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +74,7 @@ class ErrorLogHandler extends AbstractProcessingHandler
|
|||||||
{
|
{
|
||||||
if (!$this->expandNewlines) {
|
if (!$this->expandNewlines) {
|
||||||
error_log((string) $record['formatted'], $this->messageType);
|
error_log((string) $record['formatted'], $this->messageType);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,6 @@ use Monolog\Formatter\FormatterInterface;
|
|||||||
*/
|
*/
|
||||||
class FirePHPHandler extends AbstractProcessingHandler
|
class FirePHPHandler extends AbstractProcessingHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
use WebRequestRecognizerTrait;
|
use WebRequestRecognizerTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -90,7 +90,7 @@ class SlackWebhookHandler extends AbstractProcessingHandler
|
|||||||
CURLOPT_POST => true,
|
CURLOPT_POST => true,
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
|
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
|
||||||
CURLOPT_POSTFIELDS => $postString
|
CURLOPT_POSTFIELDS => $postString,
|
||||||
);
|
);
|
||||||
if (defined('CURLOPT_SAFE_UPLOAD')) {
|
if (defined('CURLOPT_SAFE_UPLOAD')) {
|
||||||
$options[CURLOPT_SAFE_UPLOAD] = true;
|
$options[CURLOPT_SAFE_UPLOAD] = true;
|
||||||
|
@@ -21,7 +21,6 @@ use Monolog\Logger;
|
|||||||
*/
|
*/
|
||||||
class SqsHandler extends AbstractProcessingHandler
|
class SqsHandler extends AbstractProcessingHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
/** 256 KB in bytes - maximum message size in SQS */
|
/** 256 KB in bytes - maximum message size in SQS */
|
||||||
const MAX_MESSAGE_SIZE = 262144;
|
const MAX_MESSAGE_SIZE = 262144;
|
||||||
/** 100 KB in bytes - head message size for new error log */
|
/** 100 KB in bytes - head message size for new error log */
|
||||||
|
@@ -106,6 +106,7 @@ class StreamHandler extends AbstractProcessingHandler
|
|||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
if (!is_resource($this->stream)) {
|
if (!is_resource($this->stream)) {
|
||||||
$this->stream = null;
|
$this->stream = null;
|
||||||
|
|
||||||
throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url));
|
throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -101,6 +101,7 @@ class TestHandler extends AbstractProcessingHandler
|
|||||||
if (isset($record['context']) && $rec['context'] !== $record['context']) {
|
if (isset($record['context']) && $rec['context'] !== $record['context']) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}, $level);
|
}, $level);
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,18 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Monolog package.
|
||||||
|
*
|
||||||
|
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Monolog\Handler;
|
namespace Monolog\Handler;
|
||||||
|
|
||||||
trait WebRequestRecognizerTrait
|
trait WebRequestRecognizerTrait
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if PHP's serving a web request
|
* Checks if PHP's serving a web request
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
namespace Monolog\Processor;
|
namespace Monolog\Processor;
|
||||||
|
|
||||||
use Monolog\Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects value of gethostname in all records
|
* Injects value of gethostname in all records
|
||||||
*/
|
*/
|
||||||
|
@@ -65,11 +65,13 @@ class IntrospectionProcessor
|
|||||||
foreach ($this->skipClassesPartials as $part) {
|
foreach ($this->skipClassesPartials as $part) {
|
||||||
if (strpos($trace[$i]['class'], $part) !== false) {
|
if (strpos($trace[$i]['class'], $part) !== false) {
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (in_array($trace[$i]['function'], $this->skipFunctions)) {
|
} elseif (in_array($trace[$i]['function'], $this->skipFunctions)) {
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -234,7 +234,7 @@ class GelfMessageFormatterTest extends \PHPUnit\Framework\TestCase
|
|||||||
'context' => array('exception' => str_repeat(' ', 32767 * 2)),
|
'context' => array('exception' => str_repeat(' ', 32767 * 2)),
|
||||||
'datetime' => new \DateTime("@0"),
|
'datetime' => new \DateTime("@0"),
|
||||||
'extra' => array('key' => str_repeat(' ', 32767 * 2)),
|
'extra' => array('key' => str_repeat(' ', 32767 * 2)),
|
||||||
'message' => 'log'
|
'message' => 'log',
|
||||||
);
|
);
|
||||||
$message = $formatter->format($record);
|
$message = $formatter->format($record);
|
||||||
$messageArray = $message->toArray();
|
$messageArray = $message->toArray();
|
||||||
|
@@ -183,6 +183,7 @@ class ElasticSearchHandlerTest extends TestCase
|
|||||||
|
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
$handler = new ElasticSearchHandler($client, $this->options);
|
$handler = new ElasticSearchHandler($client, $this->options);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$handler->handleBatch([$msg]);
|
$handler->handleBatch([$msg]);
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
|
@@ -146,7 +146,10 @@ class FilterHandlerTest extends TestCase
|
|||||||
$handler = new FilterHandler(
|
$handler = new FilterHandler(
|
||||||
function ($record, $handler) use ($test) {
|
function ($record, $handler) use ($test) {
|
||||||
return $test;
|
return $test;
|
||||||
}, Logger::INFO, Logger::NOTICE, false
|
},
|
||||||
|
Logger::INFO,
|
||||||
|
Logger::NOTICE,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||||
$handler->handle($this->getRecord(Logger::INFO));
|
$handler->handle($this->getRecord(Logger::INFO));
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the Monolog package.
|
* This file is part of the Monolog package.
|
||||||
@@ -62,7 +62,6 @@ class InsightOpsHandlerTest extends TestCase
|
|||||||
->setConstructorArgs($args)
|
->setConstructorArgs($args)
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
|
||||||
$reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
|
$reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
|
||||||
$reflectionProperty->setAccessible(true);
|
$reflectionProperty->setAccessible(true);
|
||||||
$reflectionProperty->setValue($this->handler, 'localhost:1234');
|
$reflectionProperty->setValue($this->handler, 'localhost:1234');
|
||||||
|
@@ -59,7 +59,7 @@ class RollbarHandlerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$config = array(
|
$config = array(
|
||||||
'access_token' => 'ad865e76e7fb496fab096ac07b1dbabb',
|
'access_token' => 'ad865e76e7fb496fab096ac07b1dbabb',
|
||||||
'environment' => 'test'
|
'environment' => 'test',
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->rollbarLogger = $this->getMockBuilder(RollbarLogger::class)
|
$this->rollbarLogger = $this->getMockBuilder(RollbarLogger::class)
|
||||||
|
@@ -216,7 +216,6 @@ class RotatingFileHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function rotationWhenSimilarFilesExistTests()
|
public function rotationWhenSimilarFilesExistTests()
|
||||||
{
|
{
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'Rotation is triggered when the file of the current day is not present but similar exists'
|
'Rotation is triggered when the file of the current day is not present but similar exists'
|
||||||
=> array(RotatingFileHandler::FILE_PER_DAY),
|
=> array(RotatingFileHandler::FILE_PER_DAY),
|
||||||
|
@@ -54,7 +54,8 @@ class TestHandlerTest extends TestCase
|
|||||||
$this->assertEquals([$record], $records);
|
$this->assertEquals([$record], $records);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHandlerAssertEmptyContext() {
|
public function testHandlerAssertEmptyContext()
|
||||||
|
{
|
||||||
$handler = new TestHandler;
|
$handler = new TestHandler;
|
||||||
$record = $this->getRecord(Logger::WARNING, 'test', []);
|
$record = $this->getRecord(Logger::WARNING, 'test', []);
|
||||||
$this->assertFalse($handler->hasWarning([
|
$this->assertFalse($handler->hasWarning([
|
||||||
@@ -71,18 +72,19 @@ class TestHandlerTest extends TestCase
|
|||||||
$this->assertFalse($handler->hasWarning([
|
$this->assertFalse($handler->hasWarning([
|
||||||
'message' => 'test',
|
'message' => 'test',
|
||||||
'context' => [
|
'context' => [
|
||||||
'foo' => 'bar'
|
'foo' => 'bar',
|
||||||
],
|
],
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHandlerAssertNonEmptyContext() {
|
public function testHandlerAssertNonEmptyContext()
|
||||||
|
{
|
||||||
$handler = new TestHandler;
|
$handler = new TestHandler;
|
||||||
$record = $this->getRecord(Logger::WARNING, 'test', ['foo' => 'bar']);
|
$record = $this->getRecord(Logger::WARNING, 'test', ['foo' => 'bar']);
|
||||||
$this->assertFalse($handler->hasWarning([
|
$this->assertFalse($handler->hasWarning([
|
||||||
'message' => 'test',
|
'message' => 'test',
|
||||||
'context' => [
|
'context' => [
|
||||||
'foo' => 'bar'
|
'foo' => 'bar',
|
||||||
],
|
],
|
||||||
]));
|
]));
|
||||||
|
|
||||||
@@ -91,7 +93,7 @@ class TestHandlerTest extends TestCase
|
|||||||
$this->assertTrue($handler->hasWarning([
|
$this->assertTrue($handler->hasWarning([
|
||||||
'message' => 'test',
|
'message' => 'test',
|
||||||
'context' => [
|
'context' => [
|
||||||
'foo' => 'bar'
|
'foo' => 'bar',
|
||||||
],
|
],
|
||||||
]));
|
]));
|
||||||
$this->assertFalse($handler->hasWarning([
|
$this->assertFalse($handler->hasWarning([
|
||||||
|
Reference in New Issue
Block a user