Ver código fonte

Merge pull request #93 from Shreef/master

2nd fix for issue #91
Jordi Boggiano 13 anos atrás
pai
commit
afa7d891cc
1 arquivos alterados com 8 adições e 2 exclusões
  1. 8 2
      src/Monolog/Handler/BufferHandler.php

+ 8 - 2
src/Monolog/Handler/BufferHandler.php

@@ -38,6 +38,9 @@ class BufferHandler extends AbstractHandler
         parent::__construct($level, $bubble);
         $this->handler = $handler;
         $this->bufferSize = $bufferSize;
+
+        // __destructor() doesn't get called on Fatal errors
+        register_shutdown_function(array($this, 'close'));
     }
 
     /**
@@ -62,6 +65,9 @@ class BufferHandler extends AbstractHandler
      */
     public function close()
     {
-        $this->handler->handleBatch($this->buffer);
+        if($this->buffer) {
+            $this->handler->handleBatch($this->buffer);
+            $this->buffer = array();
+        }
     }
-}
+}