mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-14 17:14:16 +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 $bufferLimit;
|
||||||
protected $flushOnOverflow;
|
protected $flushOnOverflow;
|
||||||
protected $buffer = array();
|
protected $buffer = array();
|
||||||
|
protected $initialized = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param HandlerInterface $handler Handler.
|
* @param HandlerInterface $handler Handler.
|
||||||
@@ -42,9 +43,6 @@ class BufferHandler extends AbstractHandler
|
|||||||
$this->handler = $handler;
|
$this->handler = $handler;
|
||||||
$this->bufferLimit = (int) $bufferLimit;
|
$this->bufferLimit = (int) $bufferLimit;
|
||||||
$this->flushOnOverflow = $flushOnOverflow;
|
$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;
|
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->bufferLimit > 0 && $this->bufferSize === $this->bufferLimit) {
|
||||||
if ($this->flushOnOverflow) {
|
if ($this->flushOnOverflow) {
|
||||||
$this->flush();
|
$this->flush();
|
||||||
|
Reference in New Issue
Block a user