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

log usages complicates using as a library #302

Open
directionless opened this issue Jun 24, 2021 · 3 comments
Open

log usages complicates using as a library #302

directionless opened this issue Jun 24, 2021 · 3 comments

Comments

@directionless
Copy link

Hi! In the vein of #175 I was playing with fscrypt as a library to get information about a directory. One thing I noticed, is a bunch of debugging oriented logging. To disable it, I ended up wrapping my calls to fscrypt with:

	origLog := log.Writer()
	defer func() {
		log.SetOutput(origLog)
	}()

But that feels a bit messy? I'm not sure if y'all have any thoughts about this, but I wanted to mention it as a small annoyance.

@josephlr
Copy link
Member

Ughhhhhh, I hate that Go's builtin logging doesn't have proper FATAL/ERROR/WARNING/INFO/DEBUG leveled logging.

Maybe we could switch to a better framework, unfortunately there seem to be multiple.

@josephlr
Copy link
Member

So the options are:

@directionless
Copy link
Author

It's the globals part that's so painful...

For what it's worth, I use github.com/go-kit/kit/log. The general pattern I have is that my New methods either take a logger, or I embed one in the context. Then all the library functions can call that, and the main routine can initialize it however it likes.

I'm curious about go.uber.org/zap, I see that in a couple of places.

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

No branches or pull requests

3 participants