return new MockResponse();
};
$handler =
new ElasticsearchLogstashHandler('http://es:9200', 'log',
new MockHttpClient($responseFactory));
$handler->
setFormatter($this->
getDefaultFormatter());
$records =
[ RecordFactory::
create(Logger::INFO, 'My info message', 'app', datetime:
new \
DateTimeImmutable('2020-01-01T00:00:00+01:00'
)),
RecordFactory::
create(Logger::WARNING, 'My second message', 'php', datetime:
new \
DateTimeImmutable('2020-01-01T00:00:01+01:00'
)),
];
$handler->
handleBatch($records);
$this->
assertSame(1,
$callCount);
} private function getDefaultFormatter(): FormatterInterface
{ // Monolog 1.X
if (\
defined(LogstashFormatter::
class.'::V1'
)) { return new LogstashFormatter('application', 'my hostname', null, 'ctxt_', LogstashFormatter::V1
);
}