2018-08-22 00:10:09 +02:00
|
|
|
package replication
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2018-08-25 21:30:25 +02:00
|
|
|
"github.com/zrepl/zrepl/logger"
|
2018-08-22 00:19:03 +02:00
|
|
|
"github.com/zrepl/zrepl/replication/fsrep"
|
2018-08-22 00:10:09 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type contextKey int
|
|
|
|
|
|
|
|
const (
|
|
|
|
contextKeyLog contextKey = iota
|
|
|
|
)
|
|
|
|
|
|
|
|
type Logger = logger.Logger
|
|
|
|
|
|
|
|
func WithLogger(ctx context.Context, l Logger) context.Context {
|
|
|
|
ctx = context.WithValue(ctx, contextKeyLog, l)
|
|
|
|
ctx = fsrep.WithLogger(ctx, l)
|
|
|
|
return ctx
|
|
|
|
}
|
|
|
|
|
|
|
|
func getLogger(ctx context.Context) Logger {
|
|
|
|
l, ok := ctx.Value(contextKeyLog).(Logger)
|
|
|
|
if !ok {
|
|
|
|
l = logger.NewNullLogger()
|
|
|
|
}
|
|
|
|
return l
|
|
|
|
}
|