1
0

options.go 896 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package zap
  2. import (
  3. "io"
  4. "go.uber.org/zap"
  5. "go.uber.org/zap/zapcore"
  6. "gogs.baozhida.cn/zoie/OAuth-core/logger"
  7. )
  8. type Options struct {
  9. logger.Options
  10. }
  11. type callerSkipKey struct{}
  12. func WithCallerSkip(i int) logger.Option {
  13. return logger.SetOption(callerSkipKey{}, i)
  14. }
  15. type configKey struct{}
  16. // WithConfig pass zap.Config to logger
  17. func WithConfig(c zap.Config) logger.Option {
  18. return logger.SetOption(configKey{}, c)
  19. }
  20. type encoderConfigKey struct{}
  21. // WithEncoderConfig pass zapcore.EncoderConfig to logger
  22. func WithEncoderConfig(c zapcore.EncoderConfig) logger.Option {
  23. return logger.SetOption(encoderConfigKey{}, c)
  24. }
  25. type namespaceKey struct{}
  26. func WithNamespace(namespace string) logger.Option {
  27. return logger.SetOption(namespaceKey{}, namespace)
  28. }
  29. type writerKey struct{}
  30. func WithOutput(out io.Writer) logger.Option {
  31. return logger.SetOption(writerKey{}, out)
  32. }