Преглед изворни кода

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.
Павел Гвоздь пре 5 година
родитељ
комит
1c9c3676e6
1 измењених фајлова са 24 додато и 0 уклоњено
  1. 24 0
      src/Monolog/Handler/TelegramBotHandler.php

+ 24 - 0
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
      */