logging

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const LevelSuccess = slog.Level(2)

Custom log level for success (between Info and Warn)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsoleHandler

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

ConsoleHandler formats logs for human-readable console output

func NewConsoleHandler

func NewConsoleHandler(w io.Writer, opts *slog.HandlerOptions) *ConsoleHandler

NewConsoleHandler creates a handler that outputs user-friendly logs to the console

func (*ConsoleHandler) Enabled

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

func (*ConsoleHandler) Handle

func (h *ConsoleHandler) Handle(ctx context.Context, r 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 Logger

type Logger struct {
	*slog.Logger
}

Logger wraps *slog.Logger to add a Success method

func NewSlogLogger

func NewSlogLogger(cfg LoggerConfig) (*Logger, func() error)

NewSlogLogger creates a new Logger with console and optional file output Console output: human-readable with proper formatting File output: JSON with full trace details (when stack ID is known) Returns the logger and a cleanup function to close the file

func (*Logger) Success

func (l *Logger) Success(msg string, args ...any)

Success logs a success message with a green check symbol

type LoggerConfig

type LoggerConfig struct {
	StateDir string // Directory for log files
	StackID  string // Stack ID for grouping logs
}

LoggerConfig holds configuration for creating a logger

type MultiHandler

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

MultiHandler sends logs to multiple handlers

func NewMultiHandler

func NewMultiHandler(handlers ...slog.Handler) *MultiHandler

func (*MultiHandler) Enabled

func (h *MultiHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*MultiHandler) Handle

func (h *MultiHandler) Handle(ctx context.Context, r slog.Record) error

func (*MultiHandler) WithAttrs

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

func (*MultiHandler) WithGroup

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

Jump to

Keyboard shortcuts

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