Definition at line 16 of file LogstashFormatterTest.php.
◆ tearDown()
Monolog\Formatter\LogstashFormatterTest::tearDown |
( |
| ) |
|
Definition at line 18 of file LogstashFormatterTest.php.
20 \PHPUnit_Framework_Error_Warning::$enabled =
true;
22 return parent::tearDown();
◆ testDefaultFormatter()
Monolog\Formatter\LogstashFormatterTest::testDefaultFormatter |
( |
| ) |
|
Monologformat
Definition at line 28 of file LogstashFormatterTest.php.
References $message, array, and Monolog\Logger\ERROR.
30 $formatter =
new LogstashFormatter(
'test',
'hostname');
33 'level_name' =>
'ERROR',
41 $message = json_decode($formatter->format($record),
true);
43 $this->assertEquals(
"1970-01-01T00:00:00.000000+00:00",
$message[
'@timestamp']);
44 $this->assertEquals(
'log',
$message[
'@message']);
45 $this->assertEquals(
'meh',
$message[
'@fields'][
'channel']);
46 $this->assertContains(
'meh',
$message[
'@tags']);
48 $this->assertEquals(
'test',
$message[
'@type']);
49 $this->assertEquals(
'hostname',
$message[
'@source']);
51 $formatter =
new LogstashFormatter(
'mysystem');
53 $message = json_decode($formatter->format($record),
true);
55 $this->assertEquals(
'mysystem',
$message[
'@type']);
const ERROR
Runtime errors.
catch(Exception $e) $message
Create styles array
The data for the language used.
◆ testDefaultFormatterV1()
Monolog\Formatter\LogstashFormatterTest::testDefaultFormatterV1 |
( |
| ) |
|
Monologformat
Definition at line 168 of file LogstashFormatterTest.php.
References $message, array, Monolog\Logger\ERROR, and Monolog\Formatter\LogstashFormatter\V1.
173 'level_name' =>
'ERROR',
175 'context' =>
array(),
181 $message = json_decode($formatter->format($record),
true);
183 $this->assertEquals(
"1970-01-01T00:00:00.000000+00:00",
$message[
'@timestamp']);
184 $this->assertEquals(
"1",
$message[
'@version']);
185 $this->assertEquals(
'log',
$message[
'message']);
186 $this->assertEquals(
'meh',
$message[
'channel']);
187 $this->assertEquals(
'ERROR',
$message[
'level']);
188 $this->assertEquals(
'test',
$message[
'type']);
189 $this->assertEquals(
'hostname',
$message[
'host']);
193 $message = json_decode($formatter->format($record),
true);
195 $this->assertEquals(
'mysystem',
$message[
'type']);
const ERROR
Runtime errors.
catch(Exception $e) $message
Create styles array
The data for the language used.
◆ testFormatWithApplicationName()
Monolog\Formatter\LogstashFormatterTest::testFormatWithApplicationName |
( |
| ) |
|
Definition at line 146 of file LogstashFormatterTest.php.
References $message, array, and Monolog\Logger\ERROR.
148 $formatter =
new LogstashFormatter(
'app',
'test');
151 'level_name' =>
'ERROR',
153 'context' =>
array(
'from' =>
'logger'),
155 'extra' =>
array(
'key' =>
'pair'),
159 $message = json_decode($formatter->format($record),
true);
161 $this->assertArrayHasKey(
'@type',
$message);
162 $this->assertEquals(
'app',
$message[
'@type']);
const ERROR
Runtime errors.
catch(Exception $e) $message
Create styles array
The data for the language used.
◆ testFormatWithApplicationNameV1()
Monolog\Formatter\LogstashFormatterTest::testFormatWithApplicationNameV1 |
( |
| ) |
|
◆ testFormatWithContext()
Monolog\Formatter\LogstashFormatterTest::testFormatWithContext |
( |
| ) |
|
Monologformat
Definition at line 83 of file LogstashFormatterTest.php.
References $message, array, and Monolog\Logger\ERROR.
85 $formatter =
new LogstashFormatter(
'test');
88 'level_name' =>
'ERROR',
90 'context' =>
array(
'from' =>
'logger'),
92 'extra' =>
array(
'key' =>
'pair'),
96 $message = json_decode($formatter->format($record),
true);
98 $message_array =
$message[
'@fields'];
100 $this->assertArrayHasKey(
'ctxt_from', $message_array);
101 $this->assertEquals(
'logger', $message_array[
'ctxt_from']);
104 $formatter =
new LogstashFormatter(
'test', null, null,
'CTX');
105 $message = json_decode($formatter->format($record),
true);
107 $message_array =
$message[
'@fields'];
109 $this->assertArrayHasKey(
'CTXfrom', $message_array);
110 $this->assertEquals(
'logger', $message_array[
'CTXfrom']);
const ERROR
Runtime errors.
catch(Exception $e) $message
Create styles array
The data for the language used.
◆ testFormatWithContextV1()
Monolog\Formatter\LogstashFormatterTest::testFormatWithContextV1 |
( |
| ) |
|
Monologformat
Definition at line 223 of file LogstashFormatterTest.php.
References $message, array, Monolog\Logger\ERROR, and Monolog\Formatter\LogstashFormatter\V1.
228 'level_name' =>
'ERROR',
230 'context' =>
array(
'from' =>
'logger'),
232 'extra' =>
array(
'key' =>
'pair'),
236 $message = json_decode($formatter->format($record),
true);
238 $this->assertArrayHasKey(
'ctxt_from',
$message);
239 $this->assertEquals(
'logger',
$message[
'ctxt_from']);
243 $message = json_decode($formatter->format($record),
true);
245 $this->assertArrayHasKey(
'CTXfrom',
$message);
246 $this->assertEquals(
'logger',
$message[
'CTXfrom']);
const ERROR
Runtime errors.
catch(Exception $e) $message
Create styles array
The data for the language used.
◆ testFormatWithExtra()
Monolog\Formatter\LogstashFormatterTest::testFormatWithExtra |
( |
| ) |
|
Monologformat
Definition at line 116 of file LogstashFormatterTest.php.
References $message, array, and Monolog\Logger\ERROR.
118 $formatter =
new LogstashFormatter(
'test');
121 'level_name' =>
'ERROR',
123 'context' =>
array(
'from' =>
'logger'),
125 'extra' =>
array(
'key' =>
'pair'),
129 $message = json_decode($formatter->format($record),
true);
131 $message_array =
$message[
'@fields'];
133 $this->assertArrayHasKey(
'key', $message_array);
134 $this->assertEquals(
'pair', $message_array[
'key']);
137 $formatter =
new LogstashFormatter(
'test', null,
'EXT');
138 $message = json_decode($formatter->format($record),
true);
140 $message_array =
$message[
'@fields'];
142 $this->assertArrayHasKey(
'EXTkey', $message_array);
143 $this->assertEquals(
'pair', $message_array[
'EXTkey']);
const ERROR
Runtime errors.
catch(Exception $e) $message
Create styles array
The data for the language used.
◆ testFormatWithExtraV1()
Monolog\Formatter\LogstashFormatterTest::testFormatWithExtraV1 |
( |
| ) |
|
Monologformat
Definition at line 252 of file LogstashFormatterTest.php.
References $message, array, Monolog\Logger\ERROR, and Monolog\Formatter\LogstashFormatter\V1.
257 'level_name' =>
'ERROR',
259 'context' =>
array(
'from' =>
'logger'),
261 'extra' =>
array(
'key' =>
'pair'),
265 $message = json_decode($formatter->format($record),
true);
267 $this->assertArrayHasKey(
'key',
$message);
268 $this->assertEquals(
'pair',
$message[
'key']);
272 $message = json_decode($formatter->format($record),
true);
274 $this->assertArrayHasKey(
'EXTkey',
$message);
275 $this->assertEquals(
'pair',
$message[
'EXTkey']);
const ERROR
Runtime errors.
catch(Exception $e) $message
Create styles array
The data for the language used.
◆ testFormatWithFileAndLine()
Monolog\Formatter\LogstashFormatterTest::testFormatWithFileAndLine |
( |
| ) |
|
Monologformat
Definition at line 61 of file LogstashFormatterTest.php.
References $message, array, and Monolog\Logger\ERROR.
63 $formatter =
new LogstashFormatter(
'test');
66 'level_name' =>
'ERROR',
68 'context' =>
array(
'from' =>
'logger'),
70 'extra' =>
array(
'file' =>
'test',
'line' => 14),
74 $message = json_decode($formatter->format($record),
true);
76 $this->assertEquals(
'test',
$message[
'@fields'][
'file']);
77 $this->assertEquals(14,
$message[
'@fields'][
'line']);
const ERROR
Runtime errors.
catch(Exception $e) $message
Create styles array
The data for the language used.
◆ testFormatWithFileAndLineV1()
Monolog\Formatter\LogstashFormatterTest::testFormatWithFileAndLineV1 |
( |
| ) |
|
Monologformat
Definition at line 201 of file LogstashFormatterTest.php.
References $message, array, Monolog\Logger\ERROR, and Monolog\Formatter\LogstashFormatter\V1.
206 'level_name' =>
'ERROR',
208 'context' =>
array(
'from' =>
'logger'),
210 'extra' =>
array(
'file' =>
'test',
'line' => 14),
214 $message = json_decode($formatter->format($record),
true);
216 $this->assertEquals(
'test',
$message[
'file']);
217 $this->assertEquals(14,
$message[
'line']);
const ERROR
Runtime errors.
catch(Exception $e) $message
Create styles array
The data for the language used.
◆ testFormatWithLatin9Data()
Monolog\Formatter\LogstashFormatterTest::testFormatWithLatin9Data |
( |
| ) |
|
Definition at line 297 of file LogstashFormatterTest.php.
References $message, array, and Monolog\Logger\ERROR.
299 if (version_compare(PHP_VERSION,
'5.5.0',
'<')) {
301 \PHPUnit_Framework_Error_Warning::$enabled =
false;
303 $formatter =
new LogstashFormatter(
'test',
'hostname');
306 'level_name' =>
'ERROR',
307 'channel' =>
'¯\_(ツ)_/¯',
308 'context' =>
array(),
311 'user_agent' =>
"\xD6WN; FBCR/OrangeEspa\xF1a; Vers\xE3o/4.0; F\xE4rist",
316 $message = json_decode($formatter->format($record),
true);
318 $this->assertEquals(
"1970-01-01T00:00:00.000000+00:00",
$message[
'@timestamp']);
319 $this->assertEquals(
'log',
$message[
'@message']);
320 $this->assertEquals(
'¯\_(ツ)_/¯',
$message[
'@fields'][
'channel']);
321 $this->assertContains(
'¯\_(ツ)_/¯',
$message[
'@tags']);
323 $this->assertEquals(
'test',
$message[
'@type']);
324 $this->assertEquals(
'hostname',
$message[
'@source']);
325 if (version_compare(PHP_VERSION,
'5.5.0',
'>=')) {
326 $this->assertEquals(
'ÖWN; FBCR/OrangeEspaña; Versão/4.0; Färist',
$message[
'@fields'][
'user_agent']);
330 $this->assertEquals(null,
$message[
'@fields'][
'user_agent']);
const ERROR
Runtime errors.
catch(Exception $e) $message
Create styles array
The data for the language used.
The documentation for this class was generated from the following file: