logger

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package logger provides a small, dependency-free structured logger used across the framework. It supports colored output, leveled logs, SQL query logging, and slow-query reporting. Drop-in replacements can be wired by implementing the Logger interface in your application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int8

Level enumerates log severities.

const (
	LevelDebug Level = iota - 1
	LevelInfo
	LevelWarn
	LevelError
	LevelSilent Level = 99
)

type Logger

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

Logger writes leveled & SQL-aware log lines to an io.Writer.

func New

func New(level Level) *Logger

New creates a Logger writing to stdout/stderr.

func NewWith

func NewWith(out, err io.Writer, level Level, colored bool) *Logger

NewWith creates a Logger with custom writers (useful in tests).

func (*Logger) Debug

func (l *Logger) Debug(args ...any)

Debug logs at the debug level.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...any)

Debugf logs a formatted debug message.

func (*Logger) Error

func (l *Logger) Error(args ...any)

Error logs at the error level.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any)

Errorf logs a formatted error message.

func (*Logger) Info

func (l *Logger) Info(args ...any)

Info logs at the info level.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...any)

Infof logs a formatted info message.

func (*Logger) SQL

func (l *Logger) SQL(_ context.Context, query string, args []any, took time.Duration, err error)

SQL records a query trace.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel updates the runtime level.

func (*Logger) SlowSQL

func (l *Logger) SlowSQL(_ context.Context, query string, args []any, took time.Duration, err error)

SlowSQL records a slow-query trace at warn level.

func (*Logger) Warn

func (l *Logger) Warn(args ...any)

Warn logs at the warn level.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...any)

Warnf logs a formatted warn message.

Jump to

Keyboard shortcuts

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