mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-10 23:24:02 +02:00
Lazy-initialize the buffer handler, fixes #359
This commit is contained in:
@@ -28,6 +28,7 @@ class BufferHandler extends AbstractHandler
|
||||
protected $bufferLimit;
|
||||
protected $flushOnOverflow;
|
||||
protected $buffer = array();
|
||||
protected $initialized = false;
|
||||
|
||||
/**
|
||||
* @param HandlerInterface $handler Handler.
|
||||
@@ -42,9 +43,6 @@ class BufferHandler extends AbstractHandler
|
||||
$this->handler = $handler;
|
||||
$this->bufferLimit = (int) $bufferLimit;
|
||||
$this->flushOnOverflow = $flushOnOverflow;
|
||||
|
||||
// __destructor() doesn't get called on Fatal errors
|
||||
register_shutdown_function(array($this, 'close'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,6 +54,12 @@ class BufferHandler extends AbstractHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->initialized) {
|
||||
// __destructor() doesn't get called on Fatal errors
|
||||
register_shutdown_function(array($this, 'close'));
|
||||
$this->initialized = true;
|
||||
}
|
||||
|
||||
if ($this->bufferLimit > 0 && $this->bufferSize === $this->bufferLimit) {
|
||||
if ($this->flushOnOverflow) {
|
||||
$this->flush();
|
||||
|
Reference in New Issue
Block a user