gitlab.com/gitlab-org/labkit@v1.21.0/log/logrus.go (about) 1 package log 2 3 import ( 4 "github.com/sirupsen/logrus" 5 ) 6 7 // Note that we specifically discourage the use of Fatal, Error by excluding them from the API. 8 // Since we prefer structured logging with `.WithError(err)` 9 10 // Fields is an alias for the underlying logger Fields type 11 // Using this alias saves clients from having to import 12 // two distinct logging packages, which can be confusing. 13 type Fields = logrus.Fields 14 15 // New is a delegator method for logrus.New. 16 func New() *logrus.Logger { 17 return logrus.New() 18 } 19 20 // Info is a delegator method for logrus.Info 21 // Info is an exception to our rule about discouraging non-structured use, as there are valid 22 // reasons for simply emitting a single log line. 23 func Info(args ...interface{}) { 24 logger.Info(args...) 25 } 26 27 // WithField is a delegator method for logrus.WithField. 28 func WithField(key string, value interface{}) *logrus.Entry { 29 return logger.WithField(key, value) 30 } 31 32 // WithFields is a delegator method for logrus.WithFields. 33 func WithFields(fields Fields) *logrus.Entry { 34 return logger.WithFields(fields) 35 } 36 37 // WithError is a delegator method for logrus.WithError. 38 func WithError(err error) *logrus.Entry { 39 return logger.WithError(err) 40 }