2020-02-09 19:46:33 +03:00
|
|
|
package zap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.uber.org/zap"
|
|
|
|
"go.uber.org/zap/zapcore"
|
2020-02-21 12:31:16 +03:00
|
|
|
|
|
|
|
"github.com/micro/go-micro/v2/logger"
|
2020-02-09 19:46:33 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type Options struct {
|
|
|
|
logger.Options
|
|
|
|
}
|
|
|
|
|
|
|
|
type configKey struct{}
|
|
|
|
|
|
|
|
// WithConfig pass zap.Config to logger
|
|
|
|
func WithConfig(c zap.Config) logger.Option {
|
2020-02-21 12:31:16 +03:00
|
|
|
return logger.SetOption(configKey{}, c)
|
2020-02-09 19:46:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type encoderConfigKey struct{}
|
|
|
|
|
|
|
|
// WithEncoderConfig pass zapcore.EncoderConfig to logger
|
|
|
|
func WithEncoderConfig(c zapcore.EncoderConfig) logger.Option {
|
2020-02-21 12:31:16 +03:00
|
|
|
return logger.SetOption(encoderConfigKey{}, c)
|
2020-02-09 19:46:33 +03:00
|
|
|
}
|
|
|
|
|
2020-02-21 12:31:16 +03:00
|
|
|
type namespaceKey struct{}
|
2020-02-09 19:46:33 +03:00
|
|
|
|
2020-02-21 12:31:16 +03:00
|
|
|
func WithNamespace(namespace string) logger.Option {
|
|
|
|
return logger.SetOption(namespaceKey{}, namespace)
|
2020-02-09 19:46:33 +03:00
|
|
|
}
|