logger

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 9 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 GormZap added in v0.0.28

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

GormZap struct.

func NewZapLoggerGorm added in v0.0.28

func NewZapLoggerGorm(c *GormZapSetting) *GormZap

NewZapLoggerGorm func

func (*GormZap) Error added in v0.0.28

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

Error print the error level log.

func (*GormZap) Info added in v0.0.28

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

Info print the info level log.

func (*GormZap) LogMode added in v0.0.28

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

LogMode log mode(same logrus.level)

func (*GormZap) Trace added in v0.0.28

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

Trace print the SQL log.

func (*GormZap) Warn added in v0.0.28

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

Warn print the warn level log.

type GormZapConfig added in v0.0.28

type GormZapConfig 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
}

GormZapConfig set configurations.

type GormZapSetting added in v0.0.28

type GormZapSetting struct {
	Config     *zap.Config
	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 LogLevelZap added in v0.0.28

type LogLevelZap int

LogLevelZap log level.

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.

type ZapInterface added in v0.0.28

type ZapInterface interface {
	LogMode(zapcore.Level) 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)
}

ZapInterface Gorm Logger interface.

type ZapLogger added in v0.0.28

type ZapLogger struct {
	Logger *zap.Logger
}

ZapLogger struct.

func NewZapLogger added in v0.0.28

func NewZapLogger(config *zap.Config) *ZapLogger

NewZapLogger returns an instance of logger

func (*ZapLogger) DPanic added in v0.0.28

func (l *ZapLogger) DPanic(msg string, fields ...zapcore.Field)

DPanic outputs panic log.

func (*ZapLogger) DPanicf added in v0.0.28

func (l *ZapLogger) DPanicf(format string, args ...interface{})

DPanicf outputs panic log.

func (*ZapLogger) DPanicln added in v0.0.28

func (l *ZapLogger) DPanicln(args ...interface{})

DPanicln outputs panic log.

func (*ZapLogger) Debug added in v0.0.28

func (l *ZapLogger) Debug(msg string, fields ...zapcore.Field)

Debug outputs debug level log.

func (*ZapLogger) Debugf added in v0.0.28

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

Debugf outputs debug level log.

func (*ZapLogger) Debugln added in v0.0.28

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

Debugln outputs debug level log.

func (*ZapLogger) Error added in v0.0.28

func (l *ZapLogger) Error(msg string, fields ...zapcore.Field)

Error outputs error level log.

func (*ZapLogger) Errorf added in v0.0.28

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

Errorf outputs error level log.

func (*ZapLogger) Errorln added in v0.0.28

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

Errorln outputs error level log.

func (*ZapLogger) Fatal added in v0.0.28

func (l *ZapLogger) Fatal(msg string, fields ...zapcore.Field)

Fatal outputs fatal level log.

func (*ZapLogger) Fatalf added in v0.0.28

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

Fatalf outputs fatal level log.

func (*ZapLogger) Fatalln added in v0.0.28

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

Fatalln outputs fatal level log.

func (*ZapLogger) Info added in v0.0.28

func (l *ZapLogger) Info(msg string, fields ...zapcore.Field)

Info outputs info level log.

func (*ZapLogger) Infof added in v0.0.28

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

Infof outputs info level log.

func (*ZapLogger) Infoln added in v0.0.28

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

Infoln outputs info level log.

func (*ZapLogger) Panic added in v0.0.28

func (l *ZapLogger) Panic(msg string, fields ...zapcore.Field)

Panic outputs panic log.

func (*ZapLogger) Panicf added in v0.0.28

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

Panicf outputs panic log.

func (*ZapLogger) Panicln added in v0.0.28

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

Panicln outputs panic log.

func (*ZapLogger) Warn added in v0.0.28

func (l *ZapLogger) Warn(msg string, fields ...zapcore.Field)

Warn outputs warn level log.

func (*ZapLogger) Warnf added in v0.0.28

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

Warnf outputs warn level log.

func (*ZapLogger) Warnln added in v0.0.28

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

Warnln outputs warn level log.

func (*ZapLogger) With added in v0.0.28

func (l *ZapLogger) With(fields ...zapcore.Field) *ZapLogger

With calls WithField function of logger.

func (*ZapLogger) WithError added in v0.0.28

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

WithError calls WithError function of logger.

Jump to

Keyboard shortcuts

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