logrgorm2

package module
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: MIT Imports: 7 Imported by: 0

README

logrgorm2

😄 logrgorm2 is a logr logging driver for gorm v2

go.dev reference License GitHub release Made by Vchitai

GolangCI codecov Go Report Card CodeFactor

If you're using gorm v1, you can use https://github.com/vchitai/logrgorm instead.

Usage

import "github.com/vchitai/logrgorm2"

stdr.SetVerbosity(1)
logger := stdr.NewWithOptions(stdlog.New(os.Stderr, "", stdlog.LstdFlags), stdr.Options{LogCaller: stdr.All})
logger = logger.WithName("logr")
db, err = gorm.Open(sqlite.Open("./db.sqlite"), &gorm.Config{Logger: logger})

Install

Using go
$ go get -u github.com/vchitai/logrgorm2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GormLogger

type GormLogger interface {
	logger.Interface
	IgnoreRecordNotFoundError(bool) GormLogger
	SlowThreshold(time.Duration) GormLogger
}

func New

func New(ll logr.Logger) GormLogger

type Logger

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

func (*Logger) Error

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

func (*Logger) IgnoreRecordNotFoundError

func (l *Logger) IgnoreRecordNotFoundError(ignore bool) GormLogger

func (*Logger) Info

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

func (*Logger) LogMode

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

func (*Logger) SlowThreshold

func (l *Logger) SlowThreshold(threshold time.Duration) GormLogger

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, i ...interface{})

Jump to

Keyboard shortcuts

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