logger

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MPL-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DisableThreshold = 0
)

Variables

View Source
var (
	// Discard logger will print any log to io.Discard
	Discard       = NewWithWriter(Config{}, log.New(io.Discard, "", log.LstdFlags))
	DefaultConfig = Config{
		LogLevel:                  Warn,
		SlowQueryThreshold:        defaultSlowQueryThreshold,
		SlowTransactionThreshold:  defaultSlowTransactionThreshold,
		IgnoreRecordNotFoundError: false,
		ParameterizedQueries:      false,
	}
	// Default is default logger
	Default = New(DefaultConfig)
)

Functions

func FindLastCaller

func FindLastCaller(skip int) (string, int, int)

search in the stacktrace the last file outside gormzap, cql and gorm

Types

type Config

type Config struct {
	LogLevel                  LogLevel      // GORM's Log level: the level of the logs generated by gorm
	SlowQueryThreshold        time.Duration // Slow SQL Query threshold (use DisableThreshold to disable it)
	SlowTransactionThreshold  time.Duration // Slow Transaction threshold (use DisableThreshold to disable it)
	IgnoreRecordNotFoundError bool          // if true, ignore gorm.ErrRecordNotFound error for logger
	ParameterizedQueries      bool          // if true, don't include params in the query execution logs
	Colorful                  bool          // log with colors
}

type Interface

type Interface interface {
	gormLogger.Interface
	// change log mode
	ToLogMode(level gormLogger.LogLevel) Interface
	// Trace a committed transaction
	TraceTransaction(ctx context.Context, begin time.Time)
}

func New

func New(config Config) Interface

func NewWithWriter

func NewWithWriter(config Config, writer Writer) Interface

type LogLevel added in v0.5.0

type LogLevel = gormLogger.LogLevel
const (
	// Silent silent log level
	Silent LogLevel = gormLogger.Silent
	// Error error log level
	Error LogLevel = gormLogger.Error
	// Warn warn log level
	Warn LogLevel = gormLogger.Warn
	// Info info log level
	Info LogLevel = gormLogger.Info
)

type Writer added in v0.5.0

type Writer = gormLogger.Writer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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