-
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
Export zap's internal observing logger #372
Conversation
) | ||
infoLogger, _ := observer.New(InfoLevel) | ||
warnLogger, _ := observer.New(WarnLevel) | ||
tee := NewTee(infoLogger, warnLogger) |
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.
do we need real loggers here, can we pass NopLoggers
or something?
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.
The NopCore
is always disabled, so it's not helpful here.
zaptest/observer/observer.go
Outdated
// error, but does so that it can be used as an observer sink function. | ||
func (o *ObservedLogs) Add(log LoggedEntry) error { | ||
// Add appends a new observed log to the collection. | ||
func (o *ObservedLogs) Add(log LoggedEntry) { |
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.
does this need to be exported?
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.
Nope, I'll push a small change to un-export it.
"go.uber.org/zap/zaptest/observer" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" |
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.
👍 Thanks for the import reordering.
) | ||
infoLogger, _ := observer.New(InfoLevel) | ||
warnLogger, _ := observer.New(WarnLevel) | ||
tee := NewTee(infoLogger, warnLogger) |
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.
The NopCore
is always disabled, so it's not helpful here.
zaptest/observer/observer.go
Outdated
// error, but does so that it can be used as an observer sink function. | ||
func (o *ObservedLogs) Add(log LoggedEntry) error { | ||
// Add appends a new observed log to the collection. | ||
func (o *ObservedLogs) Add(log LoggedEntry) { |
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.
Nope, I'll push a small change to un-export it.
Simplify
internal/observer
and export it aszaptest/observer
.