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

Add debarkify to wrap bark.Logger in zap.Logger #85

Merged
merged 1 commit into from
Aug 9, 2016

Conversation

billf
Copy link
Contributor

@billf billf commented Jun 23, 2016

No description provided.

@billf
Copy link
Contributor Author

billf commented Jun 23, 2016

i'll edit the commits/descriptions if this is ok. open questions around unit tests and behavior of a few of the receivers.

@billf
Copy link
Contributor Author

billf commented Jun 30, 2016

updated to use KeyValueMap from #89


func TestDebark_CastNoop(t *testing.T) {
orig := zap.NewJSON(zap.DebugLevel)
assert.Equal(t, orig, Debarkify(Barkify(orig)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will do a deep equals, I think you want to do a pointer check here, assert.True(t, orig == Debarkify(...), ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@billf billf changed the title Debarkify strawman Debarkify Jul 13, 2016
// descendants. This makes it easy to change the log level at runtime
// without restarting your application.
func (z *zapper) SetLevel(l zap.Level) {
z.lvl = l
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panic if unknown level?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with not checking for now, we don't check in the underlying jsonLogger implementation either

@prashantv
Copy link
Collaborator

The code looks good, just a few comments on the tests. Let me know if you'd like help with the tests, I can help make some test changes too.

Can we also improve the title + description for this change?

Thanks @billf

@billf billf changed the title Debarkify Add debarkify to wrap bark.Logger in zap.Logger Aug 4, 2016
@billf
Copy link
Contributor Author

billf commented Aug 4, 2016

recent update: port #126 changes here as well

assert.Equal(t, 0, buf.Len(), "buffer not zero")
logger.Log(l, "ohai")
assert.NotEqual(t, 0, buf.Len(), "%q did not log", l)
buf.Reset()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need both the buf.Reset() calls? I think the one at the beginning can be removed?

@prashantv
Copy link
Collaborator

lgtm, just a couple of nits, and it's ready to merge. Thanks for being so patient @billf

logrusLogger.Out = os.Stdout
logrusLogger.Formatter = new(logrus.JSONFormatter)
logrusLogger.Formatter.(*logrus.JSONFormatter).TimestampFormat = "lies"
barkLogger := bark.NewLoggerFromLogrus(logrusLogger).WithField("errors", 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errors comes from here and i was just matching the field use above in ExampleBarkify()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, OK makes sense.

@billf
Copy link
Contributor Author

billf commented Aug 8, 2016

vet failure seems spurious:

zbark/example_test.go:33: ExampleBarkify refers to unknown identifier: Barkify
zbark/example_test.go:48: ExampleDebarkify refers to unknown identifier: Debarkify

@prashantv
Copy link
Collaborator

vet can give flaky errors if the package is not installed. We might need to do a go test -i $(PKGS) before we run the tests.

@billf
Copy link
Contributor Author

billf commented Aug 9, 2016

vet issue is addressed in #129

@prashantv
Copy link
Collaborator

lgtm, thanks @billf

@prashantv prashantv merged commit d11d285 into uber-go:master Aug 9, 2016
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.

2 participants