gormzap

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any(key string, value any) func(ctx context.Context) zap.Field

Any custom immutable any field

func Float64

func Float64(key string, value float64) func(ctx context.Context) zap.Field

Float64 custom immutable float32 field

func Immutable

func Immutable(key string, value any) func(ctx context.Context) zap.Field

Immutable custom immutable field Deprecated: use Any instead

func Int64

func Int64(key string, value int64) func(ctx context.Context) zap.Field

Int64 custom immutable int64 field

func New

func New(zapLogger *zap.Logger, opts ...Option) logger.Interface

New logger form gorm2

func SetGormDBLogger

func SetGormDBLogger(db *gorm.DB, l logger.Interface)

SetGormDBLogger set db logger

func String

func String(key string, value string) func(ctx context.Context) zap.Field

String custom immutable string field

func Uint64

func Uint64(key string, value uint64) func(ctx context.Context) zap.Field

Uint64 custom immutable uint64 field

Types

type CallerCore added in v0.3.2

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

func NewCallerCore added in v0.3.2

func NewCallerCore() *CallerCore

func (*CallerCore) AddSkip added in v0.3.2

func (c *CallerCore) AddSkip(callerSkip int) *CallerCore

AddSkip add the number of callers skipped by caller annotation.

func (*CallerCore) AddSkipPackage added in v0.3.2

func (c *CallerCore) AddSkipPackage(vs ...string) *CallerCore

AddSkipPackage add the caller skip package.

func (*CallerCore) Enabled added in v0.3.2

func (c *CallerCore) Enabled(lvl zapcore.Level) bool

Enabled returns true if the given level is at or above this level.

func (*CallerCore) Level added in v0.3.2

func (c *CallerCore) Level() zapcore.Level

Level returns the minimum enabled log level.

func (*CallerCore) SetLevel added in v0.3.2

func (c *CallerCore) SetLevel(lv zapcore.Level) *CallerCore

SetLevel set the caller level.

func (*CallerCore) UseExternalLevel added in v0.3.2

func (c *CallerCore) UseExternalLevel(l zap.AtomicLevel) *CallerCore

UseExternalLevel use external level, which controller by user.

type Logger

type Logger struct {
	logger.Config
	// contains filtered or unexported fields
}

Logger logger for gorm2

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, msg string, args ...any)

Error print error messages

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, msg string, args ...any)

Info print info

func (*Logger) LogMode

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

LogMode log mode

func (*Logger) Trace

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

Trace print sql message

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, msg string, args ...any)

Warn print warn messages

type Option

type Option func(l *Logger)

Option logger/recover option

func WithCallerCore added in v0.3.2

func WithCallerCore(c *CallerCore) Option

WithConfig optional custom logger.Config

func WithConfig

func WithConfig(cfg logger.Config) Option

WithConfig optional custom logger.Config

func WithCustomFields

func WithCustomFields(fields ...func(ctx context.Context) zap.Field) Option

WithCustomFields optional custom field

func WithSkipPackages added in v0.0.4

func WithSkipPackages(skipPackages ...string) Option

WithSkipPackages optional custom logger.Config

Jump to

Keyboard shortcuts

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