Explorar o código

Merge pull request #1553 from dsch/threadsave-stream-handler

Set StreamHandler stream chunk size, fixes #1552
Jordi Boggiano %!s(int64=4) %!d(string=hai) anos
pai
achega
5bf534f052
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      src/Monolog/Handler/StreamHandler.php

+ 4 - 0
src/Monolog/Handler/StreamHandler.php

@@ -23,6 +23,8 @@ use Monolog\Utils;
  */
 class StreamHandler extends AbstractProcessingHandler
 {
+    protected const MAX_CHUNK_SIZE = 2147483647;
+
     /** @var resource|null */
     protected $stream;
     protected $url;
@@ -46,6 +48,7 @@ class StreamHandler extends AbstractProcessingHandler
         parent::__construct($level, $bubble);
         if (is_resource($stream)) {
             $this->stream = $stream;
+            stream_set_chunk_size($this->stream, self::MAX_CHUNK_SIZE);
         } elseif (is_string($stream)) {
             $this->url = Utils::canonicalizePath($stream);
         } else {
@@ -110,6 +113,7 @@ class StreamHandler extends AbstractProcessingHandler
 
                 throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $this->url));
             }
+            stream_set_chunk_size($this->stream, self::MAX_CHUNK_SIZE);
         }
 
         if ($this->useLocking) {