5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-28 23:01:34 +00:00
matterbridge/vendor/github.com/apex/log/context.go
Wim 4dd8bae5c9
Update dependencies (#1610)
* Update dependencies

* Update module to go 1.17
2021-10-17 00:47:22 +02:00

20 lines
442 B
Go

package log
import "context"
// logKey is a private context key.
type logKey struct{}
// NewContext returns a new context with logger.
func NewContext(ctx context.Context, v Interface) context.Context {
return context.WithValue(ctx, logKey{}, v)
}
// FromContext returns the logger from context, or log.Log.
func FromContext(ctx context.Context) Interface {
if v, ok := ctx.Value(logKey{}).(Interface); ok {
return v
}
return Log
}