Back to godoc.org
gorm.io/gorm / logger

Package logger

v1.20.2
Latest Go to latest

The latest major version is .

Published: Sep 27, 2020 | License: MIT | Module: gorm.io/gorm

Index

Constants

const (
	Reset       = "\033[0m"
	Red         = "\033[31m"
	Green       = "\033[32m"
	Yellow      = "\033[33m"
	Blue        = "\033[34m"
	Magenta     = "\033[35m"
	Cyan        = "\033[36m"
	White       = "\033[37m"
	BlueBold    = "\033[34;1m"
	MagentaBold = "\033[35;1m"
	RedBold     = "\033[31;1m"
	YellowBold  = "\033[33;1m"
)

Colors

Variables

var (
	Discard = New(log.New(ioutil.Discard, "", log.LstdFlags), Config{})
	Default = New(log.New(os.Stdout, "\r\n", log.LstdFlags), Config{
		SlowThreshold: 100 * time.Millisecond,
		LogLevel:      Warn,
		Colorful:      true,
	})
	Recorder = traceRecorder{Interface: Default}
)

func ExplainSQL

func ExplainSQL(sql string, numericPlaceholder *regexp.Regexp, escaper string, avars ...interface{}) string

type Config

type Config struct {
	SlowThreshold time.Duration
	Colorful      bool
	LogLevel      LogLevel
}

type Interface

type Interface interface {
	LogMode(LogLevel) Interface
	Info(context.Context, string, ...interface{})
	Warn(context.Context, string, ...interface{})
	Error(context.Context, string, ...interface{})
	Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
}

Interface logger interface

func New

func New(writer Writer, config Config) Interface

type LogLevel

type LogLevel int

LogLevel

const (
	Silent LogLevel = iota + 1
	Error
	Warn
	Info
)

type Writer

type Writer interface {
	Printf(string, ...interface{})
}

Writer log writer interface

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier