github.com/weedge/lib@v0.0.0-20230424045628-a36dcc1d90e4/log/rpc_log.go (about) 1 package log 2 3 import ( 4 "go.uber.org/zap" 5 ) 6 7 type rpcLog struct { 8 logger *zap.SugaredLogger 9 } 10 11 func newRpcLogger(config LoggerConfig, rotateByHour bool) (*rpcLog, error) { 12 logger, err := createZapLogger(config, rotateByHour) 13 if err != nil { 14 return nil, err 15 } 16 return &rpcLog{ 17 logger: logger.Sugar(), 18 }, nil 19 } 20 21 func (l *rpcLog) Sync() { 22 _ = l.logger.Sync() 23 } 24 25 func (l *rpcLog) Info(args ...interface{}) { 26 l.logger.Info(args...) 27 } 28 func (l *rpcLog) Debug(args ...interface{}) { 29 l.logger.Debug(args...) 30 } 31 func (l *rpcLog) Warn(args ...interface{}) { 32 l.logger.Warn(args...) 33 } 34 func (l *rpcLog) Error(args ...interface{}) { 35 l.logger.Error(args...) 36 } 37 func (l *rpcLog) Infof(format string, args ...interface{}) { 38 l.logger.Infof(format, args...) 39 } 40 func (l *rpcLog) Debugf(format string, args ...interface{}) { 41 l.logger.Debugf(format, args...) 42 } 43 func (l *rpcLog) Warnf(format string, args ...interface{}) { 44 l.logger.Warnf(format, args...) 45 } 46 func (l *rpcLog) Errorf(format string, args ...interface{}) { 47 l.logger.Errorf(format, args...) 48 }