logger

package
v1.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package logger provides the server's single runtime logging surface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(component, message string, args ...any)

func DebugContext

func DebugContext(ctx context.Context, component, message string, args ...any)

func Error

func Error(component, message string, args ...any)

func ErrorArgs

func ErrorArgs(component string, args ...any)

func ErrorContext

func ErrorContext(ctx context.Context, component, message string, args ...any)

func Errorf

func Errorf(component, format string, args ...any)

func Fatalf

func Fatalf(component, format string, args ...any)

func GinLogger

func GinLogger() gin.HandlerFunc

GinLogger records completed requests. Query values are intentionally omitted because they commonly contain credentials or other sensitive data.

func GinRecovery

func GinRecovery() gin.HandlerFunc

func Info

func Info(component, message string, args ...any)

func InfoArgs

func InfoArgs(component string, args ...any)

func InfoContext

func InfoContext(ctx context.Context, component, message string, args ...any)

func Infof

func Infof(component, format string, args ...any)

func Setup

func Setup(level slog.Level)

Setup installs the process-wide console logger before the application starts.

func Warn

func Warn(component, message string, args ...any)

func WarnContext

func WarnContext(ctx context.Context, component, message string, args ...any)

func Warnf

func Warnf(component, format string, args ...any)

Types

type ConsoleHandler

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

ConsoleHandler keeps console logs concise while retaining structured fields. Example: 2026/07/21 10:51:52 INFO/SERVER Starting server on 0.0.0.0:25774 ...

func NewConsoleHandler

func NewConsoleHandler(w io.Writer, level slog.Level) *ConsoleHandler

func (*ConsoleHandler) Enabled

func (h *ConsoleHandler) Enabled(_ context.Context, level slog.Level) bool

func (*ConsoleHandler) Handle

func (h *ConsoleHandler) Handle(_ context.Context, record slog.Record) error

func (*ConsoleHandler) WithAttrs

func (h *ConsoleHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*ConsoleHandler) WithGroup

func (h *ConsoleHandler) WithGroup(name string) slog.Handler

type GormLogger

type GormLogger struct {
	SlowThreshold             time.Duration
	IgnoreRecordNotFoundError bool
	LogLevel                  gormlogger.LogLevel
}

GormLogger 实现 gorm.io/gorm/logger.Interface

func NewGormLogger

func NewGormLogger() *GormLogger

NewGormLogger 创建 GORM logger

func (*GormLogger) Error

func (l *GormLogger) Error(ctx context.Context, msg string, data ...any)

func (*GormLogger) Info

func (l *GormLogger) Info(ctx context.Context, msg string, data ...any)

func (*GormLogger) LogMode

func (*GormLogger) Trace

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

func (*GormLogger) Warn

func (l *GormLogger) Warn(ctx context.Context, msg string, data ...any)

Jump to

Keyboard shortcuts

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