Skip to content
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

Merged
merged 2 commits into from
Mar 14, 2017
Merged

Conversation

billf
Copy link
Contributor

@billf billf commented Mar 13, 2017

Simplify internal/observer and export it as zaptest/observer.

)
infoLogger, _ := observer.New(InfoLevel)
warnLogger, _ := observer.New(WarnLevel)
tee := NewTee(infoLogger, warnLogger)
Copy link
Collaborator

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?

Copy link
Contributor

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.

// 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) {
Copy link
Collaborator

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?

Copy link
Contributor

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"
Copy link
Contributor

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)
Copy link
Contributor

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.

// 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) {
Copy link
Contributor

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.

@akshayjshah akshayjshah changed the title Expose an observer suitable for use in tests Export zap Mar 14, 2017
@akshayjshah akshayjshah changed the title Export zap Export zap's internal observing logger Mar 14, 2017
@akshayjshah akshayjshah merged commit 79e323d into uber-go:master Mar 14, 2017
@billf billf deleted the observer branch March 14, 2017 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants