33 lines
631 B
Go
33 lines
631 B
Go
|
package zap
|
||
|
|
||
|
import (
|
||
|
"github.com/micro/go-micro/v2/logger"
|
||
|
"go.uber.org/zap"
|
||
|
"go.uber.org/zap/zapcore"
|
||
|
)
|
||
|
|
||
|
type Options struct {
|
||
|
logger.Options
|
||
|
}
|
||
|
|
||
|
type configKey struct{}
|
||
|
|
||
|
// WithConfig pass zap.Config to logger
|
||
|
func WithConfig(c zap.Config) logger.Option {
|
||
|
return setOption(configKey{}, c)
|
||
|
}
|
||
|
|
||
|
type encoderConfigKey struct{}
|
||
|
|
||
|
// WithEncoderConfig pass zapcore.EncoderConfig to logger
|
||
|
func WithEncoderConfig(c zapcore.EncoderConfig) logger.Option {
|
||
|
return setOption(encoderConfigKey{}, c)
|
||
|
}
|
||
|
|
||
|
type levelKey struct{}
|
||
|
|
||
|
// WithLevel pass log level
|
||
|
func WithLevel(l logger.Level) logger.Option {
|
||
|
return setOption(levelKey{}, l)
|
||
|
}
|