gormutil

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = NewLogger(LoggerConfig{
	IgnoreRecordNotFoundError: true,
	SlowThreshold:             200 * time.Millisecond,
})

DefaultLogger is a GORM-compatible logger that uses wharf-core logging.

Functions

func NewLogger

func NewLogger(config LoggerConfig) gormlogger.Interface

NewLogger creates a new gorm.io/gorm/logger.Interface compatible logger.

Types

type LoggerConfig

type LoggerConfig struct {
	// Logger is the logger implementation used when logging. This defaults to
	// a new scoped logger with the scope "GORM".
	Logger logger.Logger
	// AlsoUseGORMLogLevel sets wether to honor GORM's own logging levels.
	//
	// If set to false (which is the default) then the logging level
	// configuration from the wharf-core logging library will be the only one
	// filtering logs.
	AlsoUseGORMLogLevel bool
	// IgnoreRecordNotFoundError will omit any "RecordNotFound" errors if set
	// to true.
	IgnoreRecordNotFoundError bool
	// SlowThreshold sets what duration is considered a slow SQL operation.
	// If an operation takes longer than this to complete then a warning log
	// message will be emitted.
	//
	// Set to 0 to disable.
	SlowThreshold time.Duration
}

LoggerConfig holds configuration for the GORM logging integration. Many configuration values of in the gorm.io/gorm/logger.Config will you also find in here.

Jump to

Keyboard shortcuts

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