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