From abd3228062b47662ac0d9d4720a9573cfff36c81 Mon Sep 17 00:00:00 2001 From: Vladimir Finko Date: Mon, 6 Feb 2017 12:41:42 +0100 Subject: [PATCH 1/2] Add unregisterErrorHandler() method --- src/FluentLogger.php | 10 ++++++++++ 1 file changed, 10 insertions(+) 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. From a4f28584a95169293ee4386223bd5694a4cc047d Mon Sep 17 00:00:00 2001 From: Vladimir Finko Date: Tue, 7 Feb 2017 10:38:26 +0100 Subject: [PATCH 2/2] add test --- tests/Fluent/Logger/BaseLoggerTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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)); + } }