sloggorm

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 7 Imported by: 0

README

sloggorm

Intro

slog logging driver for gorm2

Usage

import (
	"github.com/chg1f/sloggorm"
	"gorm.io/gorm"
)

func main() {
	tx, _ := gorm.Open(nil, &gorm.Config{Logger: sloggorm.Default})
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LogLevel                  gormlogger.LogLevel
	ParameterizedQueries      bool
	IgnoreRecordNotFoundError bool
	FailedLevel               slog.Level
	SlowThreshold             time.Duration
}

type Logger

type Logger struct {
	*slog.Logger
	Config
}

func New added in v0.0.4

func New(log *slog.Logger, cfg *Config) *Logger

func (*Logger) Error

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

func (*Logger) Info

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

func (*Logger) LogMode

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

func (*Logger) ParamsFilter

func (l *Logger) ParamsFilter(ctx context.Context, sql string, params ...interface{}) (string, []interface{})

func (*Logger) Trace

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

func (*Logger) Warn

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

Jump to

Keyboard shortcuts

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