-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decoupling of RollbarLogger in init #190
Conversation
Allow passing a `RollbarLogger` in init instead of creating one from config. This allows to use a custom `RollbarLogger` by extending the class. You can also get the logger from a container for container based frameworks.
This is great. Do you think you can add a test case for this? |
Cool idea, but naming can be better. |
@ArturMoczulski Yest, but not easily. These are static methods altering the global state. We need to reset the state in I also noticed that it's going to break if you pass a
Please let me know and I'll make the modifications. |
Yes, but we will need it for test coverage. The extent of the test can be as minimal as just checking if subsequent call to Passing a new instance of RollbarLogger when one already exists in |
L30 needs to change as you have mentioned, it should be the same as L21, which makes me think it should delegate to a shared method like |
Renamed `$config` to `$configOrLogger` in `Rollbar::init()` Added tests Added DI section in README
@rokob Replacing the logger when passing a new configuration in |
(Don't really agree)
Not all tests properly clean up the global scope.
{ | ||
Rollbar::init(self::$simpleConfig); | ||
|
||
$this->assertInstanceOf('Rollbar\RollbarLogger', Rollbar::logger()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this comment above the method signature to suppress PHPMD issues in Codacy:
/**
* Usage of static method Rollbar::logger() is intended here.
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
{ | ||
$logger = $this->getMockBuilder('Rollbar\RollbarLogger')->disableOriginalConstructor()->getMock(); | ||
|
||
Rollbar::init($logger); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this comment above method signature to suppress PHPMD issues in Codacy:
/**
* Usage of static method Rollbar::logger() is intended here.
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
Static access is intended in these tests so suppress the warning for PHPMD.
Allow passing a
RollbarLogger
in init instead of creating one from config.This allows to use a custom
RollbarLogger
by extending the class. You can also get the logger from a container for container based frameworks.