github.com/dfklegend/cell2/utils@v0.0.0-20240402033734-a0a9f3d9335d/logger/logrus/logrus.go (about)

     1  package logrus
     2  
     3  import (
     4  	"github.com/sirupsen/logrus"
     5  
     6  	"github.com/dfklegend/cell2/utils/logger/interfaces"
     7  )
     8  
     9  type logrusImpl struct {
    10  	impl logrus.FieldLogger
    11  }
    12  
    13  // New returns a new interfaces.Logger implementation based on logrus
    14  func New() interfaces.Logger {
    15  	log := logrus.New()
    16  	return NewWithLogger(log)
    17  }
    18  
    19  // NewWithEntry returns a new interfaces.Logger implementation based on a provided logrus entry instance
    20  // Deprecated: NewWithEntry is deprecated.
    21  func NewWithEntry(logger *logrus.Entry) interfaces.Logger {
    22  	return &logrusImpl{impl: logger}
    23  }
    24  
    25  // NewWithLogger returns a new interfaces.Logger implementation based on a provided logrus instance
    26  // Deprecated: NewWithLogger is deprecated.
    27  func NewWithLogger(logger *logrus.Logger) interfaces.Logger {
    28  	return &logrusImpl{impl: logrus.NewEntry(logger)}
    29  }
    30  
    31  // NewWithFieldLogger returns a new interfaces.Logger implementation based on a provided logrus instance
    32  func NewWithFieldLogger(logger logrus.FieldLogger) interfaces.Logger {
    33  	return &logrusImpl{impl: logger}
    34  }
    35  
    36  func (l *logrusImpl) Fatal(format ...interface{}) {
    37  	l.impl.Fatal(format...)
    38  }
    39  
    40  func (l *logrusImpl) Fatalf(format string, args ...interface{}) {
    41  	l.impl.Fatalf(format, args...)
    42  }
    43  
    44  func (l *logrusImpl) Fatalln(args ...interface{}) {
    45  	l.impl.Fatalln(args...)
    46  }
    47  
    48  func (l *logrusImpl) Debug(args ...interface{}) {
    49  	l.impl.Debug(args...)
    50  }
    51  
    52  func (l *logrusImpl) Debugf(format string, args ...interface{}) {
    53  	l.impl.Debugf(format, args...)
    54  }
    55  
    56  func (l *logrusImpl) Debugln(args ...interface{}) {
    57  	l.impl.Debugln(args...)
    58  }
    59  
    60  func (l *logrusImpl) Error(args ...interface{}) {
    61  	l.impl.Error(args...)
    62  }
    63  
    64  func (l *logrusImpl) Errorf(format string, args ...interface{}) {
    65  	l.impl.Errorf(format, args...)
    66  }
    67  
    68  func (l *logrusImpl) Errorln(args ...interface{}) {
    69  	l.impl.Errorln(args...)
    70  }
    71  
    72  func (l *logrusImpl) Info(args ...interface{}) {
    73  	l.impl.Info(args...)
    74  }
    75  
    76  func (l *logrusImpl) Infof(format string, args ...interface{}) {
    77  	l.impl.Infof(format, args...)
    78  }
    79  
    80  func (l *logrusImpl) Infoln(args ...interface{}) {
    81  	l.impl.Infoln(args...)
    82  }
    83  
    84  func (l *logrusImpl) Warn(args ...interface{}) {
    85  	l.impl.Warn(args...)
    86  }
    87  
    88  func (l *logrusImpl) Warnf(format string, args ...interface{}) {
    89  	l.impl.Warnf(format, args...)
    90  }
    91  
    92  func (l *logrusImpl) Warnln(args ...interface{}) {
    93  	l.impl.Warnln(args...)
    94  }
    95  
    96  func (l *logrusImpl) Panic(args ...interface{}) {
    97  	l.impl.Panic(args...)
    98  }
    99  
   100  func (l *logrusImpl) Panicf(format string, args ...interface{}) {
   101  	l.impl.Panicf(format, args...)
   102  }
   103  
   104  func (l *logrusImpl) Panicln(args ...interface{}) {
   105  	l.impl.Panicln(args...)
   106  }
   107  
   108  func (l *logrusImpl) WithFields(fields map[string]interface{}) interfaces.Logger {
   109  	return &logrusImpl{impl: l.impl.WithFields(fields)}
   110  }
   111  
   112  func (l *logrusImpl) WithField(key string, value interface{}) interfaces.Logger {
   113  	return &logrusImpl{impl: l.impl.WithField(key, value)}
   114  }
   115  
   116  func (l *logrusImpl) WithError(err error) interfaces.Logger {
   117  	return &logrusImpl{impl: l.impl.WithError(err)}
   118  }