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

nest: Add PreNest marker (and other cleanups) #12

Merged
merged 1 commit into from
Nov 12, 2018

Conversation

wking
Copy link
Contributor

@wking wking commented Nov 12, 2018

The PreNest marker allows us to drop the empty-string delimiters from library callers and still get readable output from fmt.Print-style renderers. I've added a new unit test showing that log implementations that want to detect Markers should use reflect.DeepEqual or something else that is stricter than ==.

I've also adjusted the expected order of keys in the unit-test map. Currently this output is unstable, but this (golang/go@a440cc0, golang/go#21095) will have the order stabilized in future Go releases. The change here sets us up for compatibility with that new logic.

I've also made the Newf and Logf implementations more compact by turning them into wrappers around New and Log respectively.

I think this stabilizes around the library-consumer API we want here. There's probably still room for improvement in the parent-facing API (e.g. storing wrapping-call-site in the marker so parents can toggle logger display on a per-package basis?), but stabilizing that API is less important.

The PreNest marker allows us to drop the empty-string delimiters from
library callers and still get readable output from fmt.Print-style
renderers.  I've added a new unit test showing that log
implementations that want to detect Markers should use
reflect.DeepEqual or something else that is stricter than ==.

I've also adjusted the expected order of keys in the unit-test map.
Currently this output is unstable, but [1,2,3] will have the order
stabilized in future Go releases.  The change here sets us up for
compatibility with that new logic.

I've also made the Newf and Logf implementations more compact by
turning them into wrappers around New and Log respectively.

[1]: https://go-review.googlesource.com/c/go/+/142737/
[2]: golang/go@a440cc0
[3]: golang/go#21095
@asim
Copy link
Contributor

asim commented Nov 12, 2018

I think my only qualm would be the naming. Nest/PreNest doesn't feel like the right thing. Going to merge but we need to change to something else I think.

@asim asim merged commit d779b9e into go-log:master Nov 12, 2018
@wking
Copy link
Contributor Author

wking commented Nov 12, 2018

No need to rush these in ;). I'm fine letting them wait while we work out naming, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants