logging

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package logging provides the native slog infrastructure used by pkg.

Index

Constants

View Source
const (
	FormatText Format = "text"
	FormatJSON Format = "json"

	// LevelFatal and LevelPanic preserve the legacy severity names without
	// adding process exit or panic behavior to slog.
	LevelFatal = slog.LevelError + 4
	LevelPanic = slog.LevelError + 8
)

Variables

This section is empty.

Functions

func Fallback

func Fallback() *slog.Logger

Fallback returns the explicit logger used when a caller supplies nil. It is independent from slog.Default and writes Info-and-above text logs to stderr.

func New

func New(w io.Writer, format Format, options *slog.HandlerOptions) *slog.Logger

New constructs a logger backed by NewHandler.

func NewGRPCLogger

func NewGRPCLogger(logger *slog.Logger) grpclogging.Logger

NewGRPCLogger adapts slog to go-grpc-middleware's logging.Logger interface.

func NewHandler

func NewHandler(w io.Writer, format Format, options *slog.HandlerOptions) slog.Handler

NewHandler constructs a standard slog handler. The caller owns w and the Leveler in options, allowing tests and applications to control both without changing process-global logging state.

func OrFallback

func OrFallback(logger *slog.Logger) *slog.Logger

OrFallback normalizes a possibly nil logger.

func ParseLevel

func ParseLevel(value string) (slog.Level, bool)

ParseLevel parses the levels supported by the legacy debugger config. The boolean reports whether value was recognized.

Types

type Format

type Format string

Format selects the output format used by NewHandler.

func ParseFormat

func ParseFormat(value string) (Format, bool)

ParseFormat parses a supported output format. The boolean reports whether value was recognized.

Jump to

Keyboard shortcuts

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