Documentation ¶
Overview ¶
Example (Logger) ¶
logrusLog := logrus.New() logrusLog.SetOutput(os.Stdout) logrusLog.SetFormatter(&logrus.TextFormatter{ DisableColors: true, DisableTimestamp: true, }) log := NewLogrus(logrusLog) log.Trace("some Trace log") log.Debug("some Debug log") log.Info("some Info log") log.Warn("some Warn log") log.Error("some Error log") log.WithField("RequestID", 1234).Trace("some Trace log") log.WithFields(map[string]interface{}{ "RequestID": 1234, "Name": "SomeName", }).Info("some Info log") someError := errors.New("an error occurred") log.WithError(someError).Error("some Error log")
Output: level=info msg="some Info log" level=warning msg="some Warn log" level=error msg="some Error log" level=info msg="some Info log" Name=SomeName RequestID=1234 level=error msg="some Error log" error="an error occurred"
Index ¶
- type GormLogger
- func (l *GormLogger) Error(ctx context.Context, s string, args ...interface{})
- func (l *GormLogger) Info(ctx context.Context, s string, args ...interface{})
- func (l *GormLogger) LogMode(logger.LogLevel) logger.Interface
- func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *GormLogger) Warn(ctx context.Context, s string, args ...interface{})
- type Logger
- type Logrus
- func (l *Logrus) Debug(args ...interface{})
- func (l *Logrus) Debugf(format string, args ...interface{})
- func (l *Logrus) Error(args ...interface{})
- func (l *Logrus) Errorf(format string, args ...interface{})
- func (l *Logrus) Info(args ...interface{})
- func (l *Logrus) Infof(format string, args ...interface{})
- func (l *Logrus) Trace(args ...interface{})
- func (l *Logrus) Tracef(format string, args ...interface{})
- func (l *Logrus) Warn(args ...interface{})
- func (l *Logrus) Warnf(format string, args ...interface{})
- func (l *Logrus) WithError(err error) Logger
- func (l *Logrus) WithField(key string, value interface{}) Logger
- func (l *Logrus) WithFields(fields map[string]interface{}) Logger
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GormLogger ¶
type GormLogger struct { SlowThreshold time.Duration SourceField string SkipErrRecordNotFound bool Silent bool // contains filtered or unexported fields }
GormLogger .
func (*GormLogger) Error ¶
func (l *GormLogger) Error(ctx context.Context, s string, args ...interface{})
Error .
func (*GormLogger) Info ¶
func (l *GormLogger) Info(ctx context.Context, s string, args ...interface{})
Info .
func (*GormLogger) LogMode ¶
func (l *GormLogger) LogMode(logger.LogLevel) logger.Interface
LogMode .
type Logger ¶
type Logger interface { Trace(args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) Tracef(format string, args ...interface{}) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) WithField(key string, value interface{}) Logger WithFields(fields map[string]interface{}) Logger WithError(err error) Logger }
Logger is a basic logging interface
func NewLogrusEntry ¶
NewLogrusEntry compatible logger
Click to show internal directories.
Click to hide internal directories.