mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Depend on iron-io/runner instead of iron-io/worker (#124)
This commit is contained in:
committed by
GitHub
parent
eed5422c59
commit
fbcec6bf40
@@ -1,29 +0,0 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// WithLogger stores the logger.
|
||||
func WithLogger(ctx context.Context, l logrus.FieldLogger) context.Context {
|
||||
return context.WithValue(ctx, "logger", l)
|
||||
}
|
||||
|
||||
// Logger returns the structured logger.
|
||||
func Logger(ctx context.Context) logrus.FieldLogger {
|
||||
l, ok := ctx.Value("logger").(logrus.FieldLogger)
|
||||
if !ok {
|
||||
return logrus.StandardLogger()
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
// Attempt at simplifying this whole logger in the context thing
|
||||
// Could even make this take a generic map, then the logger that gets returned could be used just like the stdlib too, since it's compatible
|
||||
func LoggerWithFields(ctx context.Context, fields logrus.Fields) (context.Context, logrus.FieldLogger) {
|
||||
l := Logger(ctx)
|
||||
l = l.WithFields(fields)
|
||||
ctx = WithLogger(ctx, l)
|
||||
return ctx, l
|
||||
}
|
||||
Reference in New Issue
Block a user