Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/Elastic/Monolog/Formatter/ElasticCommonSchemaFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,7 @@ protected function normalize(mixed $data, int $depth = 0): mixed
return parent::normalize($data, $depth);
}

/**
* {@inheritdoc}
*
* @link https://www.elastic.co/guide/en/ecs/1.1/ecs-log.html
* @link https://www.elastic.co/guide/en/ecs/1.1/ecs-base.html
* @link https://www.elastic.co/guide/en/ecs/current/ecs-tracing.html
*/
public function format(LogRecord $record): string
public function formatAsArray(LogRecord $record): array
{
$inRecord = $this->normalize($record->toArray());

Expand Down Expand Up @@ -129,7 +122,19 @@ public function format(LogRecord $record): string
$outRecord['tags'] = $this->normalize($this->tags);
}

return $this->toJson($outRecord) . "\n";
return $outRecord;
}

/**
* {@inheritdoc}
*
* @link https://www.elastic.co/guide/en/ecs/1.1/ecs-log.html
* @link https://www.elastic.co/guide/en/ecs/1.1/ecs-base.html
* @link https://www.elastic.co/guide/en/ecs/current/ecs-tracing.html
*/
public function format(LogRecord $record)
{
return $this->toJson($this->formatAsArray($record)) . "\n";
}

private function formatContext(array $inContext, array &$outRecord): void
Expand Down