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 logrus adapter for Logger interface (#752) #759

Merged
merged 4 commits into from
Sep 18, 2018

Conversation

aswinmprabhu
Copy link
Contributor

No description provided.

// NewLogrusLogger returns a logger that logs the keyvals to Writer
// with a time stamp at the logrus.InfoLevel
func NewLogrusLogger(w io.Writer) Logger {
newLogger := logrus.New()
Copy link
Member

Choose a reason for hiding this comment

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

I believe the main use case for this package is to adapt a *logrus.Logger used as the main logger in an application so it can be passed to code that expects a Go kit log.Logger. For that use case this constructor would be more flexible if it were declared as NewLogrusLogger(logger *logrus.Logger) log.Logger.

This form allows the main application to configure logrus however it wants and then simply adapt it to the Go kit log.Logger interface.

"fmt"
"io"

"github.com/sirupsen/logrus"
Copy link
Member

Choose a reason for hiding this comment

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

We don't want the base Go kit log package to have a dependency on logrus. The logrus adapter should be in its own package in a subdirectory. I suggest it go in github.com/go-kit/kit/log/logrus.

@@ -0,0 +1,31 @@
package log
Copy link
Member

Choose a reason for hiding this comment

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

Now that the code is moved into the log/logrus package, the package name here should also be logrus.

Copy link
Member

Choose a reason for hiding this comment

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

Please add at least a sentence of package documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you please clarify on what you mean by package documentation? I looked at other packages like endpoint.go and metrics.go and didn't see anything other that function and type docs.

Copy link
Member

@ChrisHines ChrisHines left a comment

Choose a reason for hiding this comment

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

Sorry for the delayed response and the way I split comments between stand alone comments and review comments. I was trying the new VS Code Github PR extension and didn't realize right away that it didn't support grouping comments into a single review (or I don't know how to use it right yet).

@@ -0,0 +1,31 @@
package log
Copy link
Member

Choose a reason for hiding this comment

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

Please add at least a sentence of package documentation.

Copy link
Member

@ChrisHines ChrisHines left a comment

Choose a reason for hiding this comment

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

The code looks good now. Just a couple fixes in the docs and this should be ready to merge.

log/logrus/logrus_logger.go Outdated Show resolved Hide resolved
log/logrus/logrus_logger.go Outdated Show resolved Hide resolved
Copy link
Member

@ChrisHines ChrisHines left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@ChrisHines ChrisHines merged commit 9890679 into go-kit:master Sep 18, 2018
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.

3 participants