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

Allow external configuration of logger #36

Closed
lzap opened this issue Mar 3, 2017 · 9 comments
Closed

Allow external configuration of logger #36

lzap opened this issue Mar 3, 2017 · 9 comments

Comments

@lzap
Copy link
Contributor

lzap commented Mar 3, 2017

I would like to have speed's internal logger under my control, ideally if I am able to provide own logger configuration (or log instance) that would be great. Currently it depends on some external custom formatter which I don't like, I would like to send everything into journald/syslog by default.

@suyash
Copy link
Collaborator

suyash commented Mar 6, 2017

@lzap there seem to be 2 solutions to this

  1. We set all the logging configuration here (https://github.com/performancecopilot/speed/blob/master/speed.go#L25-L29). We could allow the user to configure Formatter and Level

  2. We can allow the user to set a custom function, something like

var Logger func(string, ...interface{})

and use that as the logging function.

@natoscott any other ideas on this?

@natoscott
Copy link
Member

Bit beyond my golang expertise - @owenbutler any thoughts here?

@lzap
Copy link
Contributor Author

lzap commented Mar 6, 2017

Whatever works, my goal is to have ability to setup logger my own way in the application. In my case that would be everything into sylog/journald with default settings (no special formatters or anything like that).

@suyash
Copy link
Collaborator

suyash commented Mar 6, 2017

An update to this, played around with http://github.com/uber-go/zap today. Looks nice.

Currently waiting for uber-go/zap#346 to go through, then I will implement a custom logging solution built on zap using io.Writer interfaces.

@lzap
Copy link
Contributor Author

lzap commented Mar 7, 2017

I have just doublechecked that speed compiles fine on golang from RHEL7 (go version go1.6.3 linux/amd64). Is there any chance you can stick with golang system logging interface getting rid of logrus? This will make packaging easier. It already contain several deps tho.

Edit: If you can get rid of logrus and the formatter, the only dependency is github.com/codahale/hdrhistogram which is great news for packager. I plan to do Fedora and EPEL7 packages.

@suyash
Copy link
Collaborator

suyash commented Mar 8, 2017

@lzap please check out https://github.com/uber-go/zap. It is minimum-alloc logging library that is faster than stdlib log. Once my PR goes through, I plan to provide a way to specify io.Writer interfaces that the users wants logs to go to (os.Stdout, os.File*...), so if you want to pipe your logs somewhere else, all you would need to do is create a type satisfying io.Writer interface and add it to the list of outputs.

I do plan to remove logrus and the formatter, and replace it with zap.

Will try to do a PR today as a "preview" of what things will look like.

@lzap
Copy link
Contributor Author

lzap commented Mar 8, 2017

Okay, that's fine. Thanks.

@suyash
Copy link
Collaborator

suyash commented Mar 22, 2017

Fixed in #43

@suyash suyash closed this as completed Mar 22, 2017
@lzap
Copy link
Contributor Author

lzap commented Mar 25, 2017

Thanks looks good.

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

3 participants