package logz import "go-micro.dev/v4/logger" // 实现go-micro的logger var _ logger.Logger = &zapStd{} func (z *zapStd) Init(options ...logger.Option) error { return nil } func (z *zapStd) Options() logger.Options { return logger.Options{} } func (z *zapStd) Fields(fields map[string]interface{}) logger.Logger { //args := make([]interface{}, 0, len(fields)) //for k, v := range fields { // args = append(args, k) // args = append(args, v) //} //z.log.With(args...) return z } func (z *zapStd) Log(level logger.Level, v ...interface{}) { switch level { case logger.DebugLevel: z.log.Debug(v...) case logger.InfoLevel: z.log.Info(v...) case logger.WarnLevel: z.log.Warn(v...) case logger.ErrorLevel: z.log.Error(v...) case logger.FatalLevel: z.log.Fatal(v...) default: z.log.Info(v...) } } func (z *zapStd) Logf(level logger.Level, format string, v ...interface{}) { switch level { case logger.DebugLevel: z.log.Debugf(format, v...) case logger.InfoLevel: z.log.Infof(format, v...) case logger.WarnLevel: z.log.Warnf(format, v...) case logger.ErrorLevel: z.log.Errorf(format, v...) case logger.FatalLevel: z.log.Fatalf(format, v...) default: z.log.Infof(format, v...) } } func (z zapStd) String() string { return "zap logger" }