Skip to content

Commit

Permalink
Merge pull request #47 from fvovan/unregister_error_handler
Browse files Browse the repository at this point in the history
Add unregisterErrorHandler() method
  • Loading branch information
travail authored Feb 15, 2017
2 parents 9a9e10f + a4f2858 commit c5a19ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/FluentLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions tests/Fluent/Logger/BaseLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

0 comments on commit c5a19ba

Please sign in to comment.