logging

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package logging provides custom console logging handlers with support for unified time formatting, ANSI colors, and multiline log readability.

Key Components:

  • ConsoleHandler: Custom slog.Handler that formats logs with ANSI colors
  • NewLogger(): Creates a new scoped logger

Dependencies:

  • log/slog: Structured logging standard library

Example:

log := logging.NewLogger("my-subsystem")
log.Info("Hello, world")

Index

Constants

This section is empty.

Variables

View Source
var Default = NewLogger("")

Functions

func DebugEnabled

func DebugEnabled() bool

func NewLogger

func NewLogger(subsystem string) *slog.Logger

func NewLoggerWithWriter

func NewLoggerWithWriter(w io.Writer, subsystem string) *slog.Logger

Types

type ConsoleHandler

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

func NewConsoleHandler

func NewConsoleHandler(w io.Writer, lvl slog.Level, subsys string) *ConsoleHandler

func (*ConsoleHandler) Enabled

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

func (*ConsoleHandler) Handle

func (h *ConsoleHandler) Handle(_ 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

Jump to

Keyboard shortcuts

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