logger

package
v0.0.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gorm added in v0.0.21

type Gorm struct {
	// contains filtered or unexported fields
}

Gorm struct.

func NewLoggerGorm

func NewLoggerGorm(c *GormSetting) *Gorm

NewLoggerGorm func

func (*Gorm) Error added in v0.0.21

func (l *Gorm) Error(ctx context.Context, msg string, data ...interface{})

Error print the error level log.

func (*Gorm) Info added in v0.0.21

func (l *Gorm) Info(ctx context.Context, msg string, data ...interface{})

Info print the info level log.

func (*Gorm) LogMode added in v0.0.21

func (l *Gorm) LogMode(level logger.LogLevel) logger.Interface

LogMode log mode(same logrus.level)

func (*Gorm) Trace added in v0.0.21

func (l *Gorm) Trace(
	ctx context.Context,
	begin time.Time,
	fc func() (sql string, rowsAffected int64),
	err error,
)

Trace print the SQL log.

func (*Gorm) Warn added in v0.0.21

func (l *Gorm) Warn(ctx context.Context, msg string, data ...interface{})

Warn print the warn level log.

type GormConfig

type GormConfig struct {
	// If the time specified by SlowThreshold is exceeded, it is displayed in the log as a SlowQuery.
	SlowThreshold time.Duration
	// If true is specified for IgnoreRecordNotFoundError, no log is output at the error level even if the record does not exist as a search result.
	// If false, logs are output at the error level when a record does not exist as a search result.
	IgnoreRecordNotFoundError bool
	// LogLevel outputs logs above the specified level.
	LogLevel LogLevel
}

GormConfig set configurations.

type GormSetting added in v0.0.21

type GormSetting struct {
	Logger     *logrus.Logger
	GormConfig *GormConfig
}

GormSetting sets configurations.

type Interface

type Interface interface {
	LogMode(logger.LogLevel) Interface
	Info(context.Context, string, ...interface{})
	Warn(context.Context, string, ...interface{})
	Error(context.Context, string, ...interface{})
	Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)
}

Interface Gorm Logger interface.

type LogLevel

type LogLevel int

LogLevel log level.

const (
	// Silent silent log level
	Silent LogLevel = iota + 1
	// Error error log level
	Error
	// Warn warn log level
	Warn
	// Info info log level
	Info
)

type Logger

type Logger struct {
	Entry *logrus.Entry
}

Logger struct.

func NewLogger

func NewLogger(logger *logrus.Logger) *Logger

NewLogger returns an instance of logger

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug outputs debug level log.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf outputs debug level log.

func (*Logger) Debugln

func (l *Logger) Debugln(args ...interface{})

Debugln outputs debug level log.

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

Error outputs error level log.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf outputs error level log.

func (*Logger) Errorln

func (l *Logger) Errorln(args ...interface{})

Errorln outputs error level log.

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

Fatal outputs fatal level log.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

Fatalf outputs fatal level log.

func (*Logger) Fatalln

func (l *Logger) Fatalln(args ...interface{})

Fatalln outputs fatal level log.

func (*Logger) GetEntry

func (l *Logger) GetEntry() *logrus.Entry

GetEntry gets *logrus.Entry.

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

Info outputs info level log.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

Infof outputs info level log.

func (*Logger) Infoln

func (l *Logger) Infoln(args ...interface{})

Infoln outputs info level log.

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

Panic outputs panic log.

func (*Logger) Panicf

func (l *Logger) Panicf(format string, args ...interface{})

Panicf outputs panic log.

func (*Logger) Panicln

func (l *Logger) Panicln(args ...interface{})

Panicln outputs panic log.

func (*Logger) Print

func (l *Logger) Print(args ...interface{})

Print outputs printf.

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...interface{})

Printf outputs printf.

func (*Logger) Println

func (l *Logger) Println(args ...interface{})

Println outputs printf.

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

Warn outputs warn level log.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Warnf outputs warn level log.

func (*Logger) Warning

func (l *Logger) Warning(args ...interface{})

Warning outputs warn level log.

func (*Logger) Warningf

func (l *Logger) Warningf(format string, args ...interface{})

Warningf outputs warn level log.

func (*Logger) Warningln

func (l *Logger) Warningln(args ...interface{})

Warningln outputs warn level log.

func (*Logger) Warnln

func (l *Logger) Warnln(args ...interface{})

Warnln outputs warn level log.

func (*Logger) WithContext

func (l *Logger) WithContext(ctx context.Context) *Logger

WithContext calls WithContext function of logger entry.

func (*Logger) WithContextValue

func (l *Logger) WithContextValue(key string) *Logger

WithContextValue calls WithField function of logger entry.

func (*Logger) WithError

func (l *Logger) WithError(err error) *Logger

WithError calls WithError function of logger entry.

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

WithField calls WithField function of logger entry.

func (*Logger) WithFields

func (l *Logger) WithFields(fields logrus.Fields) *Logger

WithFields calls WithField function of logger entry.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL