mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-07 13:46:38 +02:00
This commit is contained in:
@@ -58,6 +58,8 @@ class RollbarHandler extends AbstractProcessingHandler
|
|||||||
*/
|
*/
|
||||||
private $hasRecords = false;
|
private $hasRecords = false;
|
||||||
|
|
||||||
|
protected $initialized = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token
|
* @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token
|
||||||
* @param int $level The minimum logging level at which this handler will be triggered
|
* @param int $level The minimum logging level at which this handler will be triggered
|
||||||
@@ -75,6 +77,12 @@ class RollbarHandler extends AbstractProcessingHandler
|
|||||||
*/
|
*/
|
||||||
protected function write(array $record)
|
protected function write(array $record)
|
||||||
{
|
{
|
||||||
|
if (!$this->initialized) {
|
||||||
|
// __destructor() doesn't get called on Fatal errors
|
||||||
|
register_shutdown_function(array($this, 'close'));
|
||||||
|
$this->initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
$context = $record['context'];
|
$context = $record['context'];
|
||||||
$payload = array();
|
$payload = array();
|
||||||
if (isset($context['payload'])) {
|
if (isset($context['payload'])) {
|
||||||
@@ -105,14 +113,19 @@ class RollbarHandler extends AbstractProcessingHandler
|
|||||||
$this->hasRecords = true;
|
$this->hasRecords = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function flush()
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function close()
|
|
||||||
{
|
{
|
||||||
if ($this->hasRecords) {
|
if ($this->hasRecords) {
|
||||||
$this->rollbarNotifier->flush();
|
$this->rollbarNotifier->flush();
|
||||||
$this->hasRecords = false;
|
$this->hasRecords = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function close()
|
||||||
|
{
|
||||||
|
$this->flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user