1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-21 04:11:47 +02:00

Merge branch '1.x'

This commit is contained in:
Jordi Boggiano
2016-04-10 12:50:34 +01:00
4 changed files with 38 additions and 4 deletions

View File

@@ -211,8 +211,20 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
);
$message = $formatter->format($record);
$messageArray = $message->toArray();
$this->assertLessThanOrEqual(32766, strlen($messageArray['_key']));
$this->assertLessThanOrEqual(32766, strlen($messageArray['_ctxt_exception']));
// 200 for padding + metadata
$length = 200;
foreach ($messageArray as $key => $value) {
if (!in_array($key, array('level', 'timestamp'))) {
$length += strlen($value);
}
}
// 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');
}
private function isLegacy()

View File

@@ -150,6 +150,16 @@ class HipChatHandlerTest extends TestCase
$this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content);
}
public function testWriteTruncatesLongMessage()
{
$this->createHandler();
$this->handler->handle($this->getRecord(Logger::CRITICAL, str_repeat('abcde', 2000)));
fseek($this->res, 0);
$content = fread($this->res, 12000);
$this->assertRegexp('/message='.str_repeat('abcde', 1900).'\+%5Btruncated%5D/', $content);
}
/**
* @dataProvider provideLevelColors
*/