mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-26 02:14:44 +01:00
26 lines
431 B
Go
26 lines
431 B
Go
package driver
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zrepl/zrepl/logger"
|
|
)
|
|
|
|
type Logger = logger.Logger
|
|
|
|
type contexKey int
|
|
|
|
const contexKeyLogger contexKey = iota + 1
|
|
|
|
func getLog(ctx context.Context) Logger {
|
|
l, ok := ctx.Value(contexKeyLogger).(Logger)
|
|
if !ok {
|
|
l = logger.NewNullLogger()
|
|
}
|
|
return l
|
|
}
|
|
|
|
func WithLogger(ctx context.Context, log Logger) context.Context {
|
|
return context.WithValue(ctx, contexKeyLogger, log)
|
|
}
|