1
0
mirror of https://github.com/zrepl/zrepl.git synced 2025-03-28 16:16:08 +01:00
zrepl/internal/daemon/logging/logging_context.go
2024-10-18 19:21:17 +02:00

25 lines
431 B
Go

package logging
import "context"
type contextKey int
const (
contextKeyLoggers contextKey = 1 + iota
contextKeyInjectedField
)
var contextKeys = []contextKey{
contextKeyLoggers,
contextKeyInjectedField,
}
func WithInherit(ctx, inheritFrom context.Context) context.Context {
for _, k := range contextKeys {
if v := inheritFrom.Value(k); v != nil {
ctx = context.WithValue(ctx, k, v) // no shadow
}
}
return ctx
}