-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Expose additional filters for observed logs #943
Expose additional filters for observed logs #943
Conversation
Codecov Report
@@ Coverage Diff @@
## master #943 +/- ##
=======================================
Coverage 98.02% 98.02%
=======================================
Files 44 44
Lines 1974 1978 +4
=======================================
+ Hits 1935 1939 +4
Misses 30 30
Partials 9 9
Continue to review full report at Codecov.
|
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.
FilterLevel is an obvious yes.
Arbitrary Filter, I'm not opposed to exposing. @prashantv?
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.
FilterLevel is an obvious yes.
Arbitrary Filter, I'm not opposed to exposing. @prashantv?
I think it's useful, +1 for allowing arbitrary filter.
Export method `observer.(*ObservedLogs).Filter` to allow consumers to filter logs by arbitrary functions for testing. Currently consumers can call `(*ObservedLogs).All` and proceed to filter using `[]LoggedEntry` directly, but the result is then incompatible with existing methods such as `FilterMessage` because there is now way to re-construct an `*ObservedLogs` object.
Method `observer.(*ObservedLogs).FilterLevelExact` allows consumers to select entries logged at a given level, for testing.
2fa9151
to
130ef27
Compare
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.
LGTM w/ nit
There are various ways I examine logs when testing how my library uses
zap
.Filtering by log level seems generically useful.
Other filters may not be re-usable enough to include directly in
zap
, so expose the ability tofilter by an arbitrary function.