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

Simplify Example, Extend README #7

Open
gsauthof opened this issue Aug 31, 2020 · 0 comments
Open

Simplify Example, Extend README #7

gsauthof opened this issue Aug 31, 2020 · 0 comments

Comments

@gsauthof
Copy link

Since zap-logfmt registers itself as an encoder with zap, (arguably), it's even simpler to use than the current example in the README suggests, i.e. e.g.:

package main

import (
	"go.uber.org/zap"
	_ "github.com/jsternberg/zap-logfmt"
)

func main() {
	config := zap.NewProductionConfig()
	config.DisableCaller = true
	config.Encoding = "logfmt"
	logger, _ := config.Build()
	logger.Info("Hello World")
}

That means it's 5 lines shorter, doesn't require knowledge of zap's core API and doesn't change other zap defaults (i.e. logging to stdout instead of stderr and changing the logging severity to debug - although debug isn't used in the example).

It produces the same output as the current first example:

ts=1598901552.010505 level=info msg="Hello World"

Thus, perhaps you want include something like the above in your README.

Perhaps you also want to extend the README a bit:

  1. Explicitly mention that this package registers itself with the "logfmt" key such that Config.Encoding can be used to switch to logfmt output. FWIW - as being new to zap and your package - this wasn't obvious to me.
  2. Add some example output for the examples.
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

No branches or pull requests

1 participant