-
Notifications
You must be signed in to change notification settings - Fork 75
Add ignored user for whom logging is disabled. #19
Conversation
Thanks for your contribution, but I think ignoring certain log-calls isn't a good responsability of this package. There might be hundreds of reason why something shouldn't be logged. An mostly those reason are app specific. In your case your app should check the user before making a call to |
I understand, but checking the user before every |
I mind mind setting up handlers for this would be overkill. I think it's very easy create a function in an app like this: function myLogger() {
if (<your conditions>) {
Activity::log('logging like there's no tomorrow');
}
} so logging when some conditions are met doesn't become cumbersome. There are so many ways to go about it. You could have a function, or a class, or a service. |
I'll just give it a try tomorrow to see how it would look like and update the PR to discuss further. |
Ok! |
This change allows to write any custom logic as to whether logging should be done or not. By default, everything is logged, so the change is backwards compatible. If any logic is needed to enable or disable logging, this can be done in a custom class that implements the `IgnoreHandlerInterface`.
I just updated the PR to a more generic implementation. The change is actually quite minimal, but it opens a lot of flexibility to enable or disable logging. I'll update the readme depending on the outcome of this discussion. |
I'd like to merge this PR after these changes:
Thanks! |
On it! |
This commit implements the feedback by @freekmurze.
I just updated the PR to include your feedback. Let me know if there's anything that needs to be changed. |
We're getting there 😄 |
Great! I added some instructions and an example to the readme. |
Add ignored user for whom logging is disabled.
Hi, I changed things a bit in the current master. The I also went back to creating the handler out of the ioc container instead of using dep injection because that would be a breaking change (hadn't thought of that before). Could you try the current master branch and let me know if this works for you? |
Adding the text and the user that could be logged looks like a great addition. I'll try it out right away and let you know. |
It looks like there's a small bug on this line: https://github.com/spatie/activitylog/blob/master/src/Spatie/Activitylog/ActivitylogSupervisor.php#L121:
should be
After I changed that locally everything seems to work fine. You want me to create a PR for this? |
Whoops, sorry about that. It's fixed now. Going to test it out a little bit and tag it soon as a new version. Thank you very much for your contribution! |
No worries. Great doing business like this :) |
I agree 😄 |
This functionality is available in the newly tagged v2.2.0 |
Using it already 😎 |
This PR adds the config option to add a user id for whom logging is disabled. This can for example be useful for an administrator type of user.