util

package
v0.0.0-...-1a0708b Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContextKeyRequestID = contextKey("RequestID")
)

Context keys.

Functions

func Check

func Check(err error, msg string)

Check the error and exit the process when not nil

func GetLogger

func GetLogger() *zap.SugaredLogger

GetLogger returns a configured instance of the logger

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext returns the Request ID stored in context or a new RequestID.

Types

type GormLogger

type GormLogger struct {
	*zap.SugaredLogger

	SlowThreshold time.Duration
}

GormLogger wraps logger with some gorm specific functionality

func (GormLogger) Error

func (l GormLogger) Error(ctx context.Context, msg string, data ...interface{})

Error print error messages.

func (GormLogger) Info

func (l GormLogger) Info(ctx context.Context, msg string, data ...interface{})

Info print info.

func (*GormLogger) LogMode

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

LogMode log mode.

func (GormLogger) Trace

func (l GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace print sql message.

func (GormLogger) Warn

func (l GormLogger) Warn(ctx context.Context, msg string, data ...interface{})

Warn print warn messages.

Jump to

Keyboard shortcuts

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