Просмотр исходного кода

Split off work into a new method to facilitate extension, fixes #945

Jordi Boggiano 8 лет назад
Родитель
Сommit
25da38373a
1 измененных файлов с 11 добавлено и 0 удалено
  1. 11 0
      src/Monolog/Handler/SlackHandler.php

+ 11 - 0
src/Monolog/Handler/SlackHandler.php

@@ -144,6 +144,17 @@ class SlackHandler extends SocketHandler
     protected function write(array $record)
     {
         parent::write($record);
+        $this->finalizeWrite();
+    }
+
+    /**
+     * Finalizes the request by reading some bytes and then closing the socket
+     *
+     * If we do not read some but close the socket too early, slack sometimes
+     * drops the request entirely.
+     */
+    protected function finalizeWrite()
+    {
         $res = $this->getResource();
         if (is_resource($res)) {
             @fread($res, 2048);