mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-01 19:00:20 +02:00
Merge pull request #1553 from dsch/threadsave-stream-handler
Set StreamHandler stream chunk size, fixes #1552
This commit is contained in:
@@ -23,6 +23,8 @@ use Monolog\Utils;
|
|||||||
*/
|
*/
|
||||||
class StreamHandler extends AbstractProcessingHandler
|
class StreamHandler extends AbstractProcessingHandler
|
||||||
{
|
{
|
||||||
|
protected const MAX_CHUNK_SIZE = 2147483647;
|
||||||
|
|
||||||
/** @var resource|null */
|
/** @var resource|null */
|
||||||
protected $stream;
|
protected $stream;
|
||||||
protected $url;
|
protected $url;
|
||||||
@@ -46,6 +48,7 @@ class StreamHandler extends AbstractProcessingHandler
|
|||||||
parent::__construct($level, $bubble);
|
parent::__construct($level, $bubble);
|
||||||
if (is_resource($stream)) {
|
if (is_resource($stream)) {
|
||||||
$this->stream = $stream;
|
$this->stream = $stream;
|
||||||
|
stream_set_chunk_size($this->stream, self::MAX_CHUNK_SIZE);
|
||||||
} elseif (is_string($stream)) {
|
} elseif (is_string($stream)) {
|
||||||
$this->url = Utils::canonicalizePath($stream);
|
$this->url = Utils::canonicalizePath($stream);
|
||||||
} else {
|
} 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));
|
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) {
|
if ($this->useLocking) {
|
||||||
|
Reference in New Issue
Block a user