logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	IgnoreRecordNotFoundError bool          // Ignore ErrRecordNotFound Error
	SlowThreshold             time.Duration // Threshold for reporting slow SQL queries
}

type Interface

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

Interface logger interface

func New

func New(lgr log.Logger, configs ...Config) Interface

Constructor.

type Logger

type Logger struct {
	Config // Extra Gorm config.
	// contains filtered or unexported fields
}

Gorm logger via composition.

func (Logger) Error

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

Error print error messages.

func (Logger) Info

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

Info print info.

func (*Logger) LogMode

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

LogMode log mode

func (Logger) Trace

func (l Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace print sql message.

func (Logger) Warn

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

Warn print warn messages.

type Writer

type Writer interface {
	Info(msg string, fields log.Map)
	Warn(msg string, fields log.Map)
	Error(msg string, fields log.Map)
}

Writer log writer interface

Jump to

Keyboard shortcuts

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