github.com/weedge/lib@v0.0.0-20230424045628-a36dcc1d90e4/log/access_log.go (about)

     1  package log
     2  
     3  import (
     4  	"go.uber.org/zap"
     5  )
     6  
     7  type accessLog struct {
     8  	logger *zap.Logger
     9  }
    10  
    11  func newAccessLogger(config LoggerConfig, rotateByHour bool) (*accessLog, error) {
    12  	logger, err := createZapLogger(config, rotateByHour)
    13  	if err != nil {
    14  		return nil, err
    15  	}
    16  	return &accessLog{
    17  		logger: logger,
    18  	}, err
    19  }
    20  
    21  func (l *accessLog) Sync() {
    22  	_ = l.logger.Sync()
    23  }
    24  
    25  func (l *accessLog) Info(msg string, fields ...zap.Field) {
    26  	l.logger.Info(msg, fields...)
    27  }