Minor naming and control flow changes to satisfy golint

This commit is contained in:
Tolga Ceylan
2017-11-02 15:30:07 -07:00
parent d6078f3c8f
commit a530cd9be3
10 changed files with 67 additions and 68 deletions

View File

@@ -6,14 +6,16 @@ import (
"github.com/sirupsen/logrus"
)
type contextKey string
// WithLogger stores the logger.
func WithLogger(ctx context.Context, l logrus.FieldLogger) context.Context {
return context.WithValue(ctx, "logger", l)
return context.WithValue(ctx, contextKey("logger"), l)
}
// Logger returns the structured logger.
func Logger(ctx context.Context) logrus.FieldLogger {
l, ok := ctx.Value("logger").(logrus.FieldLogger)
l, ok := ctx.Value(contextKey("logger")).(logrus.FieldLogger)
if !ok {
return logrus.StandardLogger()
}