Depend on iron-io/runner instead of iron-io/worker (#124)

This commit is contained in:
Seif Lotfy سيف لطفي
2016-10-05 20:42:12 +02:00
committed by GitHub
parent eed5422c59
commit fbcec6bf40
24 changed files with 142 additions and 146 deletions

View File

@@ -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
}