log

package module
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 2 Imported by: 0

README

Documentation

Overview

Package log provides CLI-agnostic structured-logging setup over log/slog: textual level and format types bound from configuration, and a constructor that builds a *slog.Logger over any writer. It knows nothing about command-line frameworks; the binding of these types to flags lives in a consumer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format string

Format selects the log encoding (text or json).

const (
	FormatText Format = "text"
	FormatJSON Format = "json"
)

FormatText and FormatJSON are the supported log encodings.

type Level

type Level string

Level is the textual logging level (debug, info, warn, error).

type LoggerConfig

type LoggerConfig struct {
	Level  Level
	Format Format
}

LoggerConfig holds the logging configuration bound from a consumer's flags.

func (LoggerConfig) NewLogger

func (cfg LoggerConfig) NewLogger(w io.Writer) *slog.Logger

NewLogger builds a logger writing to w using the level and format in cfg.

Jump to

Keyboard shortcuts

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