logger

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logger configures a slog logger for the github-metrics project.

The exported New function returns a slog.Logger whose handler enriches log records with context-bound attributes (currently the GitHub login set via ctxutil.WithLogin). The default output format is JSON; switch to text via Options.Format.

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 a context-aware handler.

func ParseLevel

func ParseLevel(s string) slog.Level

ParseLevel maps a string ("debug" / "info" / "warn" / "error") to the corresponding slog.Level. Unknown values fall back to slog.LevelInfo.

func SetDefault

func SetDefault(opts Options) *slog.Logger

SetDefault installs a logger built from opts as the global slog default. It returns the installed logger for convenience.

Types

type Format

type Format string

Format selects the underlying slog handler.

const (
	// FormatJSON is the production default; emits one JSON object per record.
	FormatJSON Format = "json"
	// FormatText is intended for local development; emits key=value lines.
	FormatText Format = "text"
)

type Options

type Options struct {
	// Format selects JSON (default) or text output.
	Format Format
	// Level sets the minimum record level. Zero value is slog.LevelInfo.
	Level slog.Level
	// Writer is the destination. Defaults to os.Stderr when nil.
	Writer io.Writer
}

Options configures a logger constructed by New.

Jump to

Keyboard shortcuts

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