micro-logger-zap/options.go
Vasiliy Tolstov f2ca0bc9d9 fix zaplogger field duplication
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-10 15:38:06 +03:00

39 lines
767 B
Go

package zap
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"github.com/micro/go-micro/v2/logger"
)
type Options struct {
logger.Options
}
type callerSkipKey struct{}
func WithCallerSkip(i int) logger.Option {
return logger.SetOption(callerSkipKey{}, i)
}
type configKey struct{}
// WithConfig pass zap.Config to logger
func WithConfig(c zap.Config) logger.Option {
return logger.SetOption(configKey{}, c)
}
type encoderConfigKey struct{}
// WithEncoderConfig pass zapcore.EncoderConfig to logger
func WithEncoderConfig(c zapcore.EncoderConfig) logger.Option {
return logger.SetOption(encoderConfigKey{}, c)
}
type namespaceKey struct{}
func WithNamespace(namespace string) logger.Option {
return logger.SetOption(namespaceKey{}, namespace)
}