mirror of
https://github.com/zrepl/zrepl.git
synced 2024-12-22 23:20:51 +01:00
44bd354eae
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
26 lines
436 B
Go
26 lines
436 B
Go
package driver
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zrepl/zrepl/logger"
|
|
)
|
|
|
|
type Logger = logger.Logger
|
|
|
|
type contextKey int
|
|
|
|
const contextKeyLogger contextKey = iota + 1
|
|
|
|
func getLog(ctx context.Context) Logger {
|
|
l, ok := ctx.Value(contextKeyLogger).(Logger)
|
|
if !ok {
|
|
l = logger.NewNullLogger()
|
|
}
|
|
return l
|
|
}
|
|
|
|
func WithLogger(ctx context.Context, log Logger) context.Context {
|
|
return context.WithValue(ctx, contextKeyLogger, log)
|
|
}
|