13 $formatter =
new LogstashFormatter(
'app',
'system',
null,
null, LogstashFormatter::V1 );
14 $formatted = json_decode( $formatter->format( $record ),
true );
15 foreach ( $expected
as $key =>
$value ) {
16 $this->assertArrayHasKey( $key, $formatted );
17 $this->assertSame(
$value, $formatted[$key] );
19 foreach ( $notExpected
as $key ) {
20 $this->assertArrayNotHasKey( $key, $formatted );
27 [
'extra' => [
'foo' => 1 ],
'context' => [
'bar' => 2 ] ],
28 [
'foo' => 1,
'bar' => 2 ],
29 [
'logstash_formatter_key_conflict' ],
32 [
'extra' => [
'url' => 1 ],
'context' => [
'url' => 2 ] ],
33 [
'url' => 1,
'c_url' => 2,
'logstash_formatter_key_conflict' => [
'url' ] ],
37 [
'channel' =>
'x',
'context' => [
'channel' =>
'y' ] ],
38 [
'channel' =>
'x',
'c_channel' =>
'y',
39 'logstash_formatter_key_conflict' => [
'channel' ] ],
46 $formatter =
new LogstashFormatter(
'app',
'system',
null,
'ctx_', LogstashFormatter::V1 );
47 $record = [
'extra' => [
'url' => 1 ],
'context' => [
'url' => 2 ] ];
48 $formatted = json_decode( $formatter->format( $record ),
true );
49 $this->assertArrayHasKey(
'url', $formatted );
50 $this->assertSame( 1, $formatted[
'url'] );
51 $this->assertArrayHasKey(
'ctx_url', $formatted );
52 $this->assertSame( 2, $formatted[
'ctx_url'] );
53 $this->assertArrayNotHasKey(
'c_url', $formatted );