◆ isLegacy()
Monolog\Formatter\GelfMessageFormatterTest::isLegacy |
( |
| ) |
|
|
private |
◆ setUp()
Monolog\Formatter\GelfMessageFormatterTest::setUp |
( |
| ) |
|
Definition at line 18 of file GelfMessageFormatterTest.php.
20 if (!class_exists(
'\Gelf\Message')) {
21 $this->markTestSkipped(
"graylog2/gelf-php or mlehner/gelf-php is not installed");
◆ testDefaultFormatter()
Monolog\Formatter\GelfMessageFormatterTest::testDefaultFormatter |
( |
| ) |
|
Monolog::format
Definition at line 28 of file GelfMessageFormatterTest.php.
References $message, Monolog\Logger\ERROR, and Monolog\Formatter\GelfMessageFormatterTest\isLegacy().
30 $formatter =
new GelfMessageFormatter();
33 'level_name' =>
'ERROR',
41 $message = $formatter->format($record);
43 $this->assertInstanceOf(
'Gelf\Message',
$message);
44 $this->assertEquals(0,
$message->getTimestamp());
45 $this->assertEquals(
'log',
$message->getShortMessage());
46 $this->assertEquals(
'meh',
$message->getFacility());
47 $this->assertEquals(null,
$message->getLine());
48 $this->assertEquals(null,
$message->getFile());
50 $this->assertNotEmpty(
$message->getHost());
52 $formatter =
new GelfMessageFormatter(
'mysystem');
54 $message = $formatter->format($record);
56 $this->assertInstanceOf(
'Gelf\Message',
$message);
57 $this->assertEquals(
'mysystem',
$message->getHost());
const ERROR
Runtime errors.
catch(Exception $e) $message
◆ testFormatInvalidFails()
Monolog\Formatter\GelfMessageFormatterTest::testFormatInvalidFails |
( |
| ) |
|
◆ testFormatWithContext()
Monolog\Formatter\GelfMessageFormatterTest::testFormatWithContext |
( |
| ) |
|
Monolog::format
Definition at line 101 of file GelfMessageFormatterTest.php.
References $message, and Monolog\Logger\ERROR.
103 $formatter =
new GelfMessageFormatter();
106 'level_name' =>
'ERROR',
108 'context' => array(
'from' =>
'logger'),
110 'extra' => array(
'key' =>
'pair'),
114 $message = $formatter->format($record);
116 $this->assertInstanceOf(
'Gelf\Message',
$message);
118 $message_array =
$message->toArray();
120 $this->assertArrayHasKey(
'_ctxt_from', $message_array);
121 $this->assertEquals(
'logger', $message_array[
'_ctxt_from']);
124 $formatter =
new GelfMessageFormatter(null, null,
'CTX');
125 $message = $formatter->format($record);
127 $this->assertInstanceOf(
'Gelf\Message',
$message);
129 $message_array =
$message->toArray();
131 $this->assertArrayHasKey(
'_CTXfrom', $message_array);
132 $this->assertEquals(
'logger', $message_array[
'_CTXfrom']);
const ERROR
Runtime errors.
catch(Exception $e) $message
◆ testFormatWithContextContainingException()
Monolog\Formatter\GelfMessageFormatterTest::testFormatWithContextContainingException |
( |
| ) |
|
Monolog::format
Definition at line 138 of file GelfMessageFormatterTest.php.
References $message, and Monolog\Logger\ERROR.
140 $formatter =
new GelfMessageFormatter();
143 'level_name' =>
'ERROR',
145 'context' => array(
'from' =>
'logger',
'exception' => array(
146 'class' =>
'\Exception',
147 'file' =>
'/some/file/in/dir.php:56',
148 'trace' => array(
'/some/file/1.php:23',
'/some/file/2.php:3'),
155 $message = $formatter->format($record);
157 $this->assertInstanceOf(
'Gelf\Message',
$message);
159 $this->assertEquals(
"/some/file/in/dir.php",
$message->getFile());
160 $this->assertEquals(
"56",
$message->getLine());
const ERROR
Runtime errors.
catch(Exception $e) $message
◆ testFormatWithExtra()
Monolog\Formatter\GelfMessageFormatterTest::testFormatWithExtra |
( |
| ) |
|
Monolog::format
Definition at line 166 of file GelfMessageFormatterTest.php.
References $message, and Monolog\Logger\ERROR.
168 $formatter =
new GelfMessageFormatter();
171 'level_name' =>
'ERROR',
173 'context' => array(
'from' =>
'logger'),
175 'extra' => array(
'key' =>
'pair'),
179 $message = $formatter->format($record);
181 $this->assertInstanceOf(
'Gelf\Message',
$message);
183 $message_array =
$message->toArray();
185 $this->assertArrayHasKey(
'_key', $message_array);
186 $this->assertEquals(
'pair', $message_array[
'_key']);
189 $formatter =
new GelfMessageFormatter(null,
'EXT');
190 $message = $formatter->format($record);
192 $this->assertInstanceOf(
'Gelf\Message',
$message);
194 $message_array =
$message->toArray();
196 $this->assertArrayHasKey(
'_EXTkey', $message_array);
197 $this->assertEquals(
'pair', $message_array[
'_EXTkey']);
const ERROR
Runtime errors.
catch(Exception $e) $message
◆ testFormatWithFileAndLine()
Monolog\Formatter\GelfMessageFormatterTest::testFormatWithFileAndLine |
( |
| ) |
|
Monolog::format
Definition at line 63 of file GelfMessageFormatterTest.php.
References $message, and Monolog\Logger\ERROR.
65 $formatter =
new GelfMessageFormatter();
68 'level_name' =>
'ERROR',
70 'context' => array(
'from' =>
'logger'),
72 'extra' => array(
'file' =>
'test',
'line' => 14),
76 $message = $formatter->format($record);
78 $this->assertInstanceOf(
'Gelf\Message',
$message);
79 $this->assertEquals(
'test',
$message->getFile());
80 $this->assertEquals(14,
$message->getLine());
const ERROR
Runtime errors.
catch(Exception $e) $message
◆ testFormatWithLargeData()
Monolog\Formatter\GelfMessageFormatterTest::testFormatWithLargeData |
( |
| ) |
|
Definition at line 200 of file GelfMessageFormatterTest.php.
References $key, $message, and Monolog\Logger\ERROR.
202 $formatter =
new GelfMessageFormatter();
205 'level_name' =>
'ERROR',
207 'context' => array(
'exception' => str_repeat(
' ', 32767)),
209 'extra' => array(
'key' => str_repeat(
' ', 32767)),
212 $message = $formatter->format($record);
213 $messageArray =
$message->toArray();
218 foreach ($messageArray as
$key => $value) {
219 if (!in_array(
$key, array(
'level',
'timestamp'))) {
220 $length += strlen($value);
224 $this->assertLessThanOrEqual(65792, $length,
'The message length is no longer than the maximum allowed length');
const ERROR
Runtime errors.
catch(Exception $e) $message
◆ testFormatWithUnlimitedLength()
Monolog\Formatter\GelfMessageFormatterTest::testFormatWithUnlimitedLength |
( |
| ) |
|
Definition at line 227 of file GelfMessageFormatterTest.php.
References $key, $message, and Monolog\Logger\ERROR.
229 $formatter =
new GelfMessageFormatter(
'LONG_SYSTEM_NAME', null,
'ctxt_', PHP_INT_MAX);
232 'level_name' =>
'ERROR',
234 'context' => array(
'exception' => str_repeat(
' ', 32767 * 2)),
236 'extra' => array(
'key' => str_repeat(
' ', 32767 * 2)),
239 $message = $formatter->format($record);
240 $messageArray =
$message->toArray();
245 foreach ($messageArray as
$key => $value) {
246 if (!in_array(
$key, array(
'level',
'timestamp'))) {
247 $length += strlen($value);
251 $this->assertGreaterThanOrEqual(131289, $length,
'The message should not be truncated');
const ERROR
Runtime errors.
catch(Exception $e) $message
The documentation for this class was generated from the following file: