1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-06 13:16:39 +02:00

Merge branch '1.x'

This commit is contained in:
Jordi Boggiano
2017-06-18 23:46:31 +02:00
4 changed files with 53 additions and 26 deletions

View File

@@ -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(null, 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()