glogrus

package
v0.0.0-...-7b9449e Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package glogrus provides a gorm logger that wraps a logrus.Logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Logger is the logrus logger to use. If nil, logrus.StandardLogger() is used.
	Logger *logrus.Logger

	// SlowThreshold is the threshold for logging slow queries. If zero, 500ms is used.
	SlowThreshold time.Duration

	// IgnoreRecordNotFoundError determines if `gorm.ErrRecordNotFound` errors are logged.
	// `gorm.ErrRecordNotFound` logging is disabled IFF IgnoreRecordNotFoundError is true.
	IgnoreRecordNotFoundError bool

	// LogSQL determines if SQL queries are included in the log output produced by calls to Logger.Trace.
	//
	// `gorm.ErrRecordNotFound` logging is disabled IFF IgnoreRecordNotFoundError is true.
	LogSQL bool
}

Config is used to configure a gorm Logger that wraps a logrus.Logger.

type Logger

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

Logger is a gorm logger that wraps a logrus.Logger. The zero value of Logger is valid and writes to logrus.StandardLogger() with default settings.

func New

func New(cfg Config) *Logger

New returns a new *Logger configured with the given config.

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, s string, args ...any)

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, s string, args ...any)

func (*Logger) LogMode

func (l *Logger) LogMode(glogger.LogLevel) glogger.Interface

func (*Logger) Trace

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

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, s string, args ...any)

Jump to

Keyboard shortcuts

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