OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
/
vendor
/
monolog
/
monolog
/
tests
/
Monolog
/
Formatter
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
π
..
-
08/12/2024 10:36:02 AM
rwxr-xr-x
π
ChromePHPFormatterTest.php
3.76 KB
08/12/2024 10:35:58 AM
rw-r--r--
π
ElasticaFormatterTest.php
2.35 KB
08/12/2024 10:35:58 AM
rw-r--r--
π
ElasticsearchFormatterTest.php
2.07 KB
08/12/2024 10:35:58 AM
rw-r--r--
π
FlowdockFormatterTest.php
1.57 KB
08/12/2024 10:35:58 AM
rw-r--r--
π
FluentdFormatterTest.php
1.82 KB
08/12/2024 10:35:58 AM
rw-r--r--
π
GelfMessageFormatterTest.php
8.06 KB
08/12/2024 10:35:58 AM
rw-r--r--
π
GoogleCloudLoggingFormatterTest.php
1.79 KB
08/12/2024 10:35:58 AM
rw-r--r--
π
JsonFormatterTest.php
13.27 KB
08/12/2024 10:35:58 AM
rw-r--r--
π
LineFormatterTest.php
13.3 KB
08/12/2024 10:35:59 AM
rw-r--r--
π
LogglyFormatterTest.php
1.33 KB
08/12/2024 10:35:59 AM
rw-r--r--
π
LogmaticFormatterTest.php
1.09 KB
08/12/2024 10:35:59 AM
rw-r--r--
π
LogstashFormatterTest.php
5.84 KB
08/12/2024 10:35:59 AM
rw-r--r--
π
MongoDBFormatterTest.php
9.54 KB
08/12/2024 10:35:59 AM
rw-r--r--
π
NormalizerFormatterTest.php
15.87 KB
08/12/2024 10:35:59 AM
rw-r--r--
π
ScalarFormatterTest.php
3.11 KB
08/12/2024 10:35:59 AM
rw-r--r--
π
SyslogFormatterTest.php
3.57 KB
08/12/2024 10:35:59 AM
rw-r--r--
π
WildfireFormatterTest.php
3.57 KB
08/12/2024 10:35:59 AM
rw-r--r--
Editing: LogstashFormatterTest.php
Close
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Formatter; use Monolog\Level; use Monolog\Test\TestCase; class LogstashFormatterTest extends TestCase { /** * @covers Monolog\Formatter\LogstashFormatter::format */ public function testDefaultFormatterV1() { $formatter = new LogstashFormatter('test', 'hostname'); $record = $this->getRecord( Level::Error, 'log', channel: 'meh', datetime: new \DateTimeImmutable("@0"), ); $message = json_decode($formatter->format($record), true); $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']); $this->assertEquals("1", $message['@version']); $this->assertEquals('log', $message['message']); $this->assertEquals('meh', $message['channel']); $this->assertEquals(Level::Error->getName(), $message['level']); $this->assertEquals(Level::Error->value, $message['monolog_level']); $this->assertEquals('test', $message['type']); $this->assertEquals('hostname', $message['host']); $formatter = new LogstashFormatter('mysystem'); $message = json_decode($formatter->format($record), true); $this->assertEquals('mysystem', $message['type']); } /** * @covers Monolog\Formatter\LogstashFormatter::format */ public function testFormatWithFileAndLineV1() { $formatter = new LogstashFormatter('test'); $record = $this->getRecord( Level::Error, 'log', channel: 'meh', context: ['from' => 'logger'], datetime: new \DateTimeImmutable("@0"), extra: ['file' => 'test', 'line' => 14], ); $message = json_decode($formatter->format($record), true); $this->assertEquals('test', $message['extra']['file']); $this->assertEquals(14, $message['extra']['line']); } /** * @covers Monolog\Formatter\LogstashFormatter::format */ public function testFormatWithContextV1() { $formatter = new LogstashFormatter('test'); $record = $this->getRecord( Level::Error, 'log', channel: 'meh', context: ['from' => 'logger'], datetime: new \DateTimeImmutable("@0"), extra: ['key' => 'pair'], ); $message = json_decode($formatter->format($record), true); $this->assertArrayHasKey('context', $message); $this->assertArrayHasKey('from', $message['context']); $this->assertEquals('logger', $message['context']['from']); // Test with extraPrefix $formatter = new LogstashFormatter('test', null, 'extra', 'CTX'); $message = json_decode($formatter->format($record), true); $this->assertArrayHasKey('CTX', $message); $this->assertArrayHasKey('from', $message['CTX']); $this->assertEquals('logger', $message['CTX']['from']); } /** * @covers Monolog\Formatter\LogstashFormatter::format */ public function testFormatWithExtraV1() { $formatter = new LogstashFormatter('test'); $record = $this->getRecord( Level::Error, 'log', channel: 'meh', context: ['from' => 'logger'], datetime: new \DateTimeImmutable("@0"), extra: ['key' => 'pair'], ); $message = json_decode($formatter->format($record), true); $this->assertArrayHasKey('extra', $message); $this->assertArrayHasKey('key', $message['extra']); $this->assertEquals('pair', $message['extra']['key']); // Test with extraPrefix $formatter = new LogstashFormatter('test', null, 'EXTRA'); $message = json_decode($formatter->format($record), true); $this->assertArrayHasKey('EXTRA', $message); $this->assertArrayHasKey('key', $message['EXTRA']); $this->assertEquals('pair', $message['EXTRA']['key']); } public function testFormatWithApplicationNameV1() { $formatter = new LogstashFormatter('app', 'test'); $record = $this->getRecord( Level::Error, 'log', channel: 'meh', context: ['from' => 'logger'], datetime: new \DateTimeImmutable("@0"), extra: ['key' => 'pair'], ); $message = json_decode($formatter->format($record), true); $this->assertArrayHasKey('type', $message); $this->assertEquals('app', $message['type']); } public function testFormatWithLatin9Data() { $formatter = new LogstashFormatter('test', 'hostname'); $record = $this->getRecord( Level::Error, 'log', channel: 'Β―\_(γ)_/Β―', datetime: new \DateTimeImmutable("@0"), extra: [ 'user_agent' => "\xD6WN; FBCR/OrangeEspa\xF1a; Vers\xE3o/4.0; F\xE4rist", ], ); $message = json_decode($formatter->format($record), true); $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']); $this->assertEquals('log', $message['message']); $this->assertEquals('Β―\_(γ)_/Β―', $message['channel']); $this->assertEquals('ERROR', $message['level']); $this->assertEquals('test', $message['type']); $this->assertEquals('hostname', $message['host']); $this->assertEquals('οΏ½WN; FBCR/OrangeEspaοΏ½a; VersοΏ½o/4.0; FοΏ½rist', $message['extra']['user_agent']); } }