Documentation
¶
Overview ¶
Package logger provides the server's single runtime logging surface.
Index ¶
- func Debug(component, message string, args ...any)
- func DebugContext(ctx context.Context, component, message string, args ...any)
- func Error(component, message string, args ...any)
- func ErrorArgs(component string, args ...any)
- func ErrorContext(ctx context.Context, component, message string, args ...any)
- func Errorf(component, format string, args ...any)
- func Fatalf(component, format string, args ...any)
- func GinLogger() gin.HandlerFunc
- func GinRecovery() gin.HandlerFunc
- func Info(component, message string, args ...any)
- func InfoArgs(component string, args ...any)
- func InfoContext(ctx context.Context, component, message string, args ...any)
- func Infof(component, format string, args ...any)
- func Setup(level slog.Level)
- func Warn(component, message string, args ...any)
- func WarnContext(ctx context.Context, component, message string, args ...any)
- func Warnf(component, format string, args ...any)
- type ConsoleHandler
- type GormLogger
- func (l *GormLogger) Error(ctx context.Context, msg string, data ...any)
- func (l *GormLogger) Info(ctx context.Context, msg string, data ...any)
- func (l *GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
- func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *GormLogger) Warn(ctx context.Context, msg string, data ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
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
type GormLogger ¶
type GormLogger struct {
SlowThreshold time.Duration
IgnoreRecordNotFoundError bool
LogLevel gormlogger.LogLevel
}
GormLogger 实现 gorm.io/gorm/logger.Interface
func (*GormLogger) LogMode ¶
func (l *GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
Click to show internal directories.
Click to hide internal directories.