logging

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package logging provides a configured slog logger for db-catalyst.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts Options) *slog.Logger

New constructs a slog.Logger with db-catalyst defaults.

Types

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
	With(args ...any) Logger
}

Logger is a generic logging interface that abstracts slog.

type NopLogger

type NopLogger struct{}

NopLogger is a logger that discards all output.

func NewNopLogger

func NewNopLogger() *NopLogger

NewNopLogger creates a new NopLogger.

func (*NopLogger) Debug

func (n *NopLogger) Debug(_ string, _ ...any)

Debug is a no-op.

func (*NopLogger) Error

func (n *NopLogger) Error(_ string, _ ...any)

Error is a no-op.

func (*NopLogger) Info

func (n *NopLogger) Info(_ string, _ ...any)

Info is a no-op.

func (*NopLogger) Warn

func (n *NopLogger) Warn(_ string, _ ...any)

Warn is a no-op.

func (*NopLogger) With

func (n *NopLogger) With(_ ...any) Logger

With returns the same NopLogger.

type Options

type Options struct {
	// Verbose toggles debug level logging when true.
	Verbose bool
	// Writer directs log output; defaults to os.Stderr when nil.
	Writer io.Writer
}

Options configures the default slog logger used by db-catalyst.

type SlogAdapter

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

SlogAdapter adapts *slog.Logger to the Logger interface.

func NewSlogAdapter

func NewSlogAdapter(logger *slog.Logger) *SlogAdapter

NewSlogAdapter creates a new SlogAdapter.

func (*SlogAdapter) Debug

func (s *SlogAdapter) Debug(msg string, args ...any)

Debug logs a debug message.

func (*SlogAdapter) Error

func (s *SlogAdapter) Error(msg string, args ...any)

Error logs an error message.

func (*SlogAdapter) Info

func (s *SlogAdapter) Info(msg string, args ...any)

Info logs an info message.

func (*SlogAdapter) Warn

func (s *SlogAdapter) Warn(msg string, args ...any)

Warn logs a warning message.

func (*SlogAdapter) With

func (s *SlogAdapter) With(args ...any) Logger

With returns a new Logger with the given attributes.

Jump to

Keyboard shortcuts

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