1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00
go-micro/logger/context.go

15 lines
287 B
Go
Raw Normal View History

package logger
import "context"
type loggerKey struct{}
func FromContext(ctx context.Context) (Logger, bool) {
l, ok := ctx.Value(loggerKey{}).(Logger)
return l, ok
}
func NewContext(ctx context.Context, l Logger) context.Context {
return context.WithValue(ctx, loggerKey{}, l)
}