1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-01 19:00:20 +02:00

Change datetime format from ISO 8601 to ATOM in ElasticsearchFormatter and related tests (#1942)

This commit is contained in:
Rajmund
2025-03-15 14:23:08 +01:00
committed by GitHub
parent c8bbe52af5
commit 45b5e0e33e
3 changed files with 3 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ class ElasticsearchFormatter extends NormalizerFormatter
public function __construct(string $index, string $type) public function __construct(string $index, string $type)
{ {
// Elasticsearch requires an ISO 8601 format date with optional millisecond precision. // Elasticsearch requires an ISO 8601 format date with optional millisecond precision.
parent::__construct(DateTimeInterface::ISO8601); parent::__construct(DateTimeInterface::ATOM);
$this->index = $index; $this->index = $index;
$this->type = $type; $this->type = $type;

View File

@@ -167,7 +167,7 @@ class ElasticaHandlerTest extends TestCase
$msg = $this->getRecord(Level::Error, 'log', context: ['foo' => 7, 'bar', 'class' => new \stdClass], datetime: new \DateTimeImmutable("@0")); $msg = $this->getRecord(Level::Error, 'log', context: ['foo' => 7, 'bar', 'class' => new \stdClass], datetime: new \DateTimeImmutable("@0"));
$expected = (array) $msg; $expected = (array) $msg;
$expected['datetime'] = $msg['datetime']->format(\DateTime::ISO8601); $expected['datetime'] = $msg['datetime']->format(\DateTime::ATOM);
$expected['context'] = [ $expected['context'] = [
'class' => '[object] (stdClass: {})', 'class' => '[object] (stdClass: {})',
'foo' => 7, 'foo' => 7,

View File

@@ -138,7 +138,7 @@ class ElasticsearchHandlerTest extends TestCase
$msg = $this->getRecord(Level::Error, 'log', context: ['foo' => 7, 'bar', 'class' => new \stdClass], datetime: new \DateTimeImmutable("@0")); $msg = $this->getRecord(Level::Error, 'log', context: ['foo' => 7, 'bar', 'class' => new \stdClass], datetime: new \DateTimeImmutable("@0"));
$expected = $msg->toArray(); $expected = $msg->toArray();
$expected['datetime'] = $msg['datetime']->format(\DateTime::ISO8601); $expected['datetime'] = $msg['datetime']->format(\DateTime::ATOM);
$expected['context'] = [ $expected['context'] = [
'class' => ["stdClass" => []], 'class' => ["stdClass" => []],
'foo' => 7, 'foo' => 7,