From 1c9c3676e6901c14e6bfdcb379faf4e455c22f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=93=D0=B2=D0=BE=D0=B7?= =?UTF-8?q?=D0=B4=D1=8C?= Date: Thu, 10 Dec 2020 14:51:46 +0600 Subject: [PATCH] Added support for working with BufferHandler (#1481) * Added support for working with BufferHandler Added `handleBatch` method for TelegramBotHandler and fixed `write` method. This is necessary to work with BufferHandler, OverflowHandler etc. --- src/Monolog/Handler/TelegramBotHandler.php | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Monolog/Handler/TelegramBotHandler.php b/src/Monolog/Handler/TelegramBotHandler.php index bec080b8..025c89e3 100644 --- a/src/Monolog/Handler/TelegramBotHandler.php +++ b/src/Monolog/Handler/TelegramBotHandler.php @@ -120,6 +120,30 @@ class TelegramBotHandler extends AbstractProcessingHandler return $this; } + /** + * {@inheritdoc} + */ + public function handleBatch(array $records): void + { + $messages = []; + + foreach ($records as $record) { + if (!$this->isHandling($record)) { + continue; + } + + if ($this->processors) { + $record = $this->processRecord($record); + } + + $messages[] = $record; + } + + if (!empty($messages)) { + $this->send((string) $this->getFormatter()->formatBatch($messages)); + } + } + /** * @inheritDoc */