diff --git a/src/FluentLogger.php b/src/FluentLogger.php index 01482f9..7c1176e 100644 --- a/src/FluentLogger.php +++ b/src/FluentLogger.php @@ -165,6 +165,16 @@ public function registerErrorHandler($callable) return true; } + /** + * unregister error handler + * + * @return void + */ + public function unregisterErrorHandler() + { + $this->error_handler = null; + } + /** * make a various style transport uri with specified host and port. * currently, in_forward uses tcp transport only. diff --git a/tests/Fluent/Logger/BaseLoggerTest.php b/tests/Fluent/Logger/BaseLoggerTest.php index f7a97b2..b581ca7 100644 --- a/tests/Fluent/Logger/BaseLoggerTest.php +++ b/tests/Fluent/Logger/BaseLoggerTest.php @@ -64,4 +64,15 @@ public function invalidErrorHandlerProvider() ), ); } + + public function testUnregisterErrorHandler() + { + $base = $this->getMockForAbstractClass('Fluent\Logger\FluentLogger'); + $prop = new \ReflectionProperty($base, 'error_handler'); + $prop->setAccessible(true); + $base->registerErrorHandler(function() {}); + $this->assertNotNull($prop->getValue($base)); + $base->unregisterErrorHandler(); + $this->assertNull($prop->getValue($base)); + } }