Mise à jour des librairies vendor
This commit is contained in:
9
vendor/monolog/monolog/CHANGELOG.md
vendored
9
vendor/monolog/monolog/CHANGELOG.md
vendored
@@ -1,3 +1,12 @@
|
||||
### 1.23.0 (2017-06-19)
|
||||
|
||||
* Improved SyslogUdpHandler's support for RFC5424 and added optional `$ident` argument
|
||||
* Fixed GelfHandler truncation to be per field and not per message
|
||||
* Fixed compatibility issue with PHP <5.3.6
|
||||
* Fixed support for headless Chrome in ChromePHPHandler
|
||||
* Fixed support for latest Aws SDK in DynamoDbHandler
|
||||
* Fixed support for SwiftMailer 6.0+ in SwiftMailerHandler
|
||||
|
||||
### 1.22.1 (2017-03-13)
|
||||
|
||||
* Fixed lots of minor issues in the new Slack integrations
|
||||
|
||||
2
vendor/monolog/monolog/composer.json
vendored
2
vendor/monolog/monolog/composer.json
vendored
@@ -24,7 +24,7 @@
|
||||
"doctrine/couchdb": "~1.0@dev",
|
||||
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
|
||||
"php-amqplib/php-amqplib": "~2.4",
|
||||
"swiftmailer/swiftmailer": "~5.3",
|
||||
"swiftmailer/swiftmailer": "^5.3|^6.0",
|
||||
"php-console/php-console": "^3.1.3",
|
||||
"phpunit/phpunit-mock-objects": "2.3.0",
|
||||
"jakub-onderka/php-parallel-lint": "0.9"
|
||||
|
||||
@@ -22,7 +22,7 @@ use Gelf\Message;
|
||||
*/
|
||||
class GelfMessageFormatter extends NormalizerFormatter
|
||||
{
|
||||
const MAX_LENGTH = 32766;
|
||||
const DEFAULT_MAX_LENGTH = 32766;
|
||||
|
||||
/**
|
||||
* @var string the name of the system for the Gelf log message
|
||||
@@ -39,6 +39,11 @@ class GelfMessageFormatter extends NormalizerFormatter
|
||||
*/
|
||||
protected $contextPrefix;
|
||||
|
||||
/**
|
||||
* @var int max length per field
|
||||
*/
|
||||
protected $maxLength;
|
||||
|
||||
/**
|
||||
* Translates Monolog log levels to Graylog2 log priorities.
|
||||
*/
|
||||
@@ -53,7 +58,7 @@ class GelfMessageFormatter extends NormalizerFormatter
|
||||
Logger::EMERGENCY => 0,
|
||||
);
|
||||
|
||||
public function __construct($systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_')
|
||||
public function __construct($systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $maxLength = null)
|
||||
{
|
||||
parent::__construct('U.u');
|
||||
|
||||
@@ -61,6 +66,7 @@ class GelfMessageFormatter extends NormalizerFormatter
|
||||
|
||||
$this->extraPrefix = $extraPrefix;
|
||||
$this->contextPrefix = $contextPrefix;
|
||||
$this->maxLength = is_null($maxLength) ? self::DEFAULT_MAX_LENGTH : $maxLength;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,35 +87,30 @@ class GelfMessageFormatter extends NormalizerFormatter
|
||||
->setHost($this->systemName)
|
||||
->setLevel($this->logLevels[$record['level']]);
|
||||
|
||||
// start count with message length + system name length + 200 for padding / metadata
|
||||
// message length + system name length + 200 for padding / metadata
|
||||
$len = 200 + strlen((string) $record['message']) + strlen($this->systemName);
|
||||
|
||||
if ($len > self::MAX_LENGTH) {
|
||||
$message->setShortMessage(substr($record['message'], 0, self::MAX_LENGTH - 200));
|
||||
|
||||
return $message;
|
||||
if ($len > $this->maxLength) {
|
||||
$message->setShortMessage(substr($record['message'], 0, $this->maxLength));
|
||||
}
|
||||
|
||||
if (isset($record['channel'])) {
|
||||
$message->setFacility($record['channel']);
|
||||
$len += strlen($record['channel']);
|
||||
}
|
||||
if (isset($record['extra']['line'])) {
|
||||
$message->setLine($record['extra']['line']);
|
||||
$len += 10;
|
||||
unset($record['extra']['line']);
|
||||
}
|
||||
if (isset($record['extra']['file'])) {
|
||||
$message->setFile($record['extra']['file']);
|
||||
$len += strlen($record['extra']['file']);
|
||||
unset($record['extra']['file']);
|
||||
}
|
||||
|
||||
foreach ($record['extra'] as $key => $val) {
|
||||
$val = is_scalar($val) || null === $val ? $val : $this->toJson($val);
|
||||
$len += strlen($this->extraPrefix . $key . $val);
|
||||
if ($len > self::MAX_LENGTH) {
|
||||
$message->setAdditional($this->extraPrefix . $key, substr($val, 0, self::MAX_LENGTH - $len));
|
||||
$len = strlen($this->extraPrefix . $key . $val);
|
||||
if ($len > $this->maxLength) {
|
||||
$message->setAdditional($this->extraPrefix . $key, substr($val, 0, $this->maxLength));
|
||||
break;
|
||||
}
|
||||
$message->setAdditional($this->extraPrefix . $key, $val);
|
||||
@@ -117,9 +118,9 @@ class GelfMessageFormatter extends NormalizerFormatter
|
||||
|
||||
foreach ($record['context'] as $key => $val) {
|
||||
$val = is_scalar($val) || null === $val ? $val : $this->toJson($val);
|
||||
$len += strlen($this->contextPrefix . $key . $val);
|
||||
if ($len > self::MAX_LENGTH) {
|
||||
$message->setAdditional($this->contextPrefix . $key, substr($val, 0, self::MAX_LENGTH - $len));
|
||||
$len = strlen($this->contextPrefix . $key . $val);
|
||||
if ($len > $this->maxLength) {
|
||||
$message->setAdditional($this->contextPrefix . $key, substr($val, 0, $this->maxLength));
|
||||
break;
|
||||
}
|
||||
$message->setAdditional($this->contextPrefix . $key, $val);
|
||||
|
||||
@@ -28,6 +28,7 @@ class JsonFormatter extends NormalizerFormatter
|
||||
|
||||
protected $batchMode;
|
||||
protected $appendNewline;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
@@ -35,6 +36,7 @@ class JsonFormatter extends NormalizerFormatter
|
||||
|
||||
/**
|
||||
* @param int $batchMode
|
||||
* @param bool $appendNewline
|
||||
*/
|
||||
public function __construct($batchMode = self::BATCH_MODE_JSON, $appendNewline = true)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
|
||||
/**
|
||||
* Regular expression to detect supported browsers (matches any Chrome, or Firefox 43+)
|
||||
*/
|
||||
const USER_AGENT_REGEX = '{\b(?:Chrome/\d+(?:\.\d+)*|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}';
|
||||
const USER_AGENT_REGEX = '{\b(?:Chrome/\d+(?:\.\d+)*|HeadlessChrome|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}';
|
||||
|
||||
protected static $initialized = false;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Aws\Common\Aws;
|
||||
use Aws\Sdk;
|
||||
use Aws\DynamoDb\DynamoDbClient;
|
||||
use Aws\DynamoDb\Marshaler;
|
||||
use Monolog\Formatter\ScalarFormatter;
|
||||
@@ -55,7 +55,7 @@ class DynamoDbHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
public function __construct(DynamoDbClient $client, $table, $level = Logger::DEBUG, $bubble = true)
|
||||
{
|
||||
if (defined('Aws\Common\Aws::VERSION') && version_compare(Aws::VERSION, '3.0', '>=')) {
|
||||
if (defined('Aws\Sdk::VERSION') && version_compare(Sdk::VERSION, '3.0', '>=')) {
|
||||
$this->version = 3;
|
||||
$this->marshaler = new Marshaler;
|
||||
} else {
|
||||
|
||||
@@ -16,15 +16,17 @@ use Monolog\Formatter\FormatterInterface;
|
||||
/**
|
||||
* This simple wrapper class can be used to extend handlers functionality.
|
||||
*
|
||||
* Example: A filtering handle. Inherit from this class, override isHandling() like this
|
||||
* Example: A custom filtering that can be applied to any handler.
|
||||
*
|
||||
* public function isHandling(array $record)
|
||||
* {
|
||||
* if ($record meets certain conditions) {
|
||||
* return false;
|
||||
* }
|
||||
* return $this->handler->isHandling($record);
|
||||
* }
|
||||
* Inherit from this class and override handle() like this:
|
||||
*
|
||||
* public function handle(array $record)
|
||||
* {
|
||||
* if ($record meets certain conditions) {
|
||||
* return false;
|
||||
* }
|
||||
* return $this->handler->handle($record);
|
||||
* }
|
||||
*
|
||||
* @author Alexey Karapetov <alexey@karapetov.com>
|
||||
*/
|
||||
|
||||
@@ -97,6 +97,7 @@ class RollbarHandler extends AbstractProcessingHandler
|
||||
));
|
||||
|
||||
if (isset($context['exception']) && $context['exception'] instanceof Exception) {
|
||||
$payload['level'] = $context['level'];
|
||||
$exception = $context['exception'];
|
||||
unset($context['exception']);
|
||||
|
||||
|
||||
@@ -144,6 +144,17 @@ class SlackHandler extends SocketHandler
|
||||
protected function write(array $record)
|
||||
{
|
||||
parent::write($record);
|
||||
$this->finalizeWrite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the request by reading some bytes and then closing the socket
|
||||
*
|
||||
* If we do not read some but close the socket too early, slack sometimes
|
||||
* drops the request entirely.
|
||||
*/
|
||||
protected function finalizeWrite()
|
||||
{
|
||||
$res = $this->getResource();
|
||||
if (is_resource($res)) {
|
||||
@fread($res, 2048);
|
||||
|
||||
@@ -81,13 +81,18 @@ class SlackWebhookHandler extends AbstractProcessingHandler
|
||||
$postString = json_encode($postData);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $this->webhookUrl);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$options = array(
|
||||
CURLOPT_URL => $this->webhookUrl,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
|
||||
CURLOPT_POSTFIELDS => $postString
|
||||
);
|
||||
if (defined('CURLOPT_SAFE_UPLOAD')) {
|
||||
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
|
||||
$options[CURLOPT_SAFE_UPLOAD] = true;
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, array('payload' => $postString));
|
||||
|
||||
curl_setopt_array($ch, $options);
|
||||
|
||||
Curl\Util::execute($ch);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Swift;
|
||||
|
||||
/**
|
||||
* SwiftMailerHandler uses Swift_Mailer to send the emails
|
||||
@@ -73,7 +74,11 @@ class SwiftMailerHandler extends MailHandler
|
||||
}
|
||||
|
||||
$message->setBody($content);
|
||||
$message->setDate(time());
|
||||
if (version_compare(Swift::VERSION, '6.0.0', '>=')) {
|
||||
$message->setDate(new \DateTimeImmutable());
|
||||
} else {
|
||||
$message->setDate(time());
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ use Monolog\Handler\SyslogUdp\UdpSocket;
|
||||
class SyslogUdpHandler extends AbstractSyslogHandler
|
||||
{
|
||||
protected $socket;
|
||||
protected $ident;
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
@@ -29,11 +30,14 @@ class SyslogUdpHandler extends AbstractSyslogHandler
|
||||
* @param mixed $facility
|
||||
* @param int $level The minimum logging level at which this handler will be triggered
|
||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||
* @param string $ident Program name or tag for each log message.
|
||||
*/
|
||||
public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
|
||||
public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $ident = 'php')
|
||||
{
|
||||
parent::__construct($facility, $level, $bubble);
|
||||
|
||||
$this->ident = $ident;
|
||||
|
||||
$this->socket = new UdpSocket($host, $port ?: 514);
|
||||
}
|
||||
|
||||
@@ -69,7 +73,24 @@ class SyslogUdpHandler extends AbstractSyslogHandler
|
||||
{
|
||||
$priority = $severity + $this->facility;
|
||||
|
||||
return "<$priority>1 ";
|
||||
if (!$pid = getmypid()) {
|
||||
$pid = '-';
|
||||
}
|
||||
|
||||
if (!$hostname = gethostname()) {
|
||||
$hostname = '-';
|
||||
}
|
||||
|
||||
return "<$priority>1 " .
|
||||
$this->getDateTime() . " " .
|
||||
$hostname . " " .
|
||||
$this->ident . " " .
|
||||
$pid . " - - ";
|
||||
}
|
||||
|
||||
protected function getDateTime()
|
||||
{
|
||||
return date(\DateTime::RFC3339);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,7 +55,12 @@ class IntrospectionProcessor
|
||||
return $record;
|
||||
}
|
||||
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
/*
|
||||
* http://php.net/manual/en/function.debug-backtrace.php
|
||||
* As of 5.3.6, DEBUG_BACKTRACE_IGNORE_ARGS option was added.
|
||||
* Any version less than 5.3.6 must use the DEBUG_BACKTRACE_IGNORE_ARGS constant value '2'.
|
||||
*/
|
||||
$trace = debug_backtrace((PHP_VERSION_ID < 50306) ? 2 : DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
|
||||
// skip first since it's always the current method
|
||||
array_shift($trace);
|
||||
|
||||
@@ -221,10 +221,34 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
// in graylog2/gelf-php before 1.4.1 empty strings are filtered and won't be included in the message
|
||||
// though it should be sufficient to ensure that the entire message length does not exceed the maximum
|
||||
// length being allowed
|
||||
$this->assertLessThanOrEqual(32766, $length, 'The message length is no longer than the maximum allowed length');
|
||||
$this->assertLessThanOrEqual(65792, $length, 'The message length is no longer than the maximum allowed length');
|
||||
}
|
||||
|
||||
public function testFormatWithUnlimitedLength()
|
||||
{
|
||||
$formatter = new GelfMessageFormatter('LONG_SYSTEM_NAME', null, 'ctxt_', PHP_INT_MAX);
|
||||
$record = array(
|
||||
'level' => Logger::ERROR,
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('exception' => str_repeat(' ', 32767 * 2)),
|
||||
'datetime' => new \DateTime("@0"),
|
||||
'extra' => array('key' => str_repeat(' ', 32767 * 2)),
|
||||
'message' => 'log'
|
||||
);
|
||||
$message = $formatter->format($record);
|
||||
$messageArray = $message->toArray();
|
||||
|
||||
// 200 for padding + metadata
|
||||
$length = 200;
|
||||
|
||||
foreach ($messageArray as $key => $value) {
|
||||
if (!in_array($key, array('level', 'timestamp'))) {
|
||||
$length += strlen($value);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertGreaterThanOrEqual(131289, $length, 'The message should not be truncated');
|
||||
}
|
||||
|
||||
private function isLegacy()
|
||||
|
||||
@@ -25,8 +25,13 @@ class ChromePHPHandlerTest extends TestCase
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; Chrome/1.0';
|
||||
}
|
||||
|
||||
public function testHeaders()
|
||||
/**
|
||||
* @dataProvider agentsProvider
|
||||
*/
|
||||
public function testHeaders($agent)
|
||||
{
|
||||
$_SERVER['HTTP_USER_AGENT'] = $agent;
|
||||
|
||||
$handler = new TestChromePHPHandler();
|
||||
$handler->setFormatter($this->getIdentityFormatter());
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
@@ -47,6 +52,16 @@ class ChromePHPHandlerTest extends TestCase
|
||||
$this->assertEquals($expected, $handler->getHeaders());
|
||||
}
|
||||
|
||||
public static function agentsProvider()
|
||||
{
|
||||
return array(
|
||||
array('Monolog Test; Chrome/1.0'),
|
||||
array('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'),
|
||||
array('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/56.0.2924.76 Chrome/56.0.2924.76 Safari/537.36'),
|
||||
array('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome Safari/537.36'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testHeadersOverflow()
|
||||
{
|
||||
$handler = new TestChromePHPHandler();
|
||||
|
||||
@@ -52,13 +52,20 @@ class DynamoDbHandlerTest extends TestCase
|
||||
$handler = new DynamoDbHandler($this->client, 'foo');
|
||||
$handler->setFormatter($formatter);
|
||||
|
||||
$isV3 = defined('Aws\Sdk::VERSION') && version_compare(\Aws\Sdk::VERSION, '3.0', '>=');
|
||||
if ($isV3) {
|
||||
$expFormatted = array('foo' => array('N' => 1), 'bar' => array('N' => 2));
|
||||
} else {
|
||||
$expFormatted = $formatted;
|
||||
}
|
||||
|
||||
$formatter
|
||||
->expects($this->once())
|
||||
->method('format')
|
||||
->with($record)
|
||||
->will($this->returnValue($formatted));
|
||||
$this->client
|
||||
->expects($this->once())
|
||||
->expects($isV3 ? $this->never() : $this->once())
|
||||
->method('formatAttributes')
|
||||
->with($this->isType('array'))
|
||||
->will($this->returnValue($formatted));
|
||||
@@ -67,7 +74,7 @@ class DynamoDbHandlerTest extends TestCase
|
||||
->method('__call')
|
||||
->with('putItem', array(array(
|
||||
'TableName' => 'foo',
|
||||
'Item' => $formatted,
|
||||
'Item' => $expFormatted,
|
||||
)));
|
||||
|
||||
$handler->handle($record);
|
||||
|
||||
@@ -111,10 +111,10 @@ class RotatingFileHandlerTest extends TestCase
|
||||
return $now + 86400 * $ago;
|
||||
};
|
||||
$monthCallback = function($ago) {
|
||||
return gmmktime(0, 0, 0, date('n') + $ago, date('d'), date('Y'));
|
||||
return gmmktime(0, 0, 0, date('n') + $ago, 1, date('Y'));
|
||||
};
|
||||
$yearCallback = function($ago) {
|
||||
return gmmktime(0, 0, 0, date('n'), date('d'), date('Y') + $ago);
|
||||
return gmmktime(0, 0, 0, 1, 1, date('Y') + $ago);
|
||||
};
|
||||
|
||||
return array(
|
||||
|
||||
@@ -98,7 +98,7 @@ class SwiftMailerHandlerTest extends TestCase
|
||||
|
||||
public function testMessageHaveUniqueId()
|
||||
{
|
||||
$messageTemplate = \Swift_Message::newInstance();
|
||||
$messageTemplate = new \Swift_Message();
|
||||
$handler = new SwiftMailerHandler($this->mailer, $messageTemplate);
|
||||
|
||||
$method = new \ReflectionMethod('Monolog\Handler\SwiftMailerHandler', 'buildMessage');
|
||||
|
||||
@@ -28,16 +28,27 @@ class SyslogUdpHandlerTest extends TestCase
|
||||
|
||||
public function testWeSplitIntoLines()
|
||||
{
|
||||
$handler = new SyslogUdpHandler("127.0.0.1", 514, "authpriv");
|
||||
$time = '2014-01-07T12:34';
|
||||
$pid = getmypid();
|
||||
$host = gethostname();
|
||||
|
||||
$handler = $this->getMockBuilder('\Monolog\Handler\SyslogUdpHandler')
|
||||
->setConstructorArgs(array("127.0.0.1", 514, "authpriv"))
|
||||
->setMethods(array('getDateTime'))
|
||||
->getMock();
|
||||
|
||||
$handler->method('getDateTime')
|
||||
->willReturn($time);
|
||||
|
||||
$handler->setFormatter(new \Monolog\Formatter\ChromePHPFormatter());
|
||||
|
||||
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
|
||||
$socket->expects($this->at(0))
|
||||
->method('write')
|
||||
->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 ");
|
||||
->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 $time $host php $pid - - ");
|
||||
$socket->expects($this->at(1))
|
||||
->method('write')
|
||||
->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 ");
|
||||
->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 $time $host php $pid - - ");
|
||||
|
||||
$handler->setSocket($socket);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user