feat: init nightly vuls for blackhat
This commit is contained in:
22
pkg/log/log.go
Normal file
22
pkg/log/log.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type ctxLogger struct{}
|
||||
|
||||
// ContextWithLogger adds logger to context
|
||||
func ContextWithLogger(ctx context.Context, l *zap.Logger) context.Context {
|
||||
return context.WithValue(ctx, ctxLogger{}, l)
|
||||
}
|
||||
|
||||
// LoggerFromContext returns logger from context
|
||||
func LoggerFromContext(ctx context.Context) *zap.Logger {
|
||||
if l, ok := ctx.Value(ctxLogger{}).(*zap.Logger); ok {
|
||||
return l
|
||||
}
|
||||
return zap.L()
|
||||
}
|
||||
Reference in New Issue
Block a user