logger

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package logger adapts go-partial diagnostic events to log/slog.

Index

Constants

View Source
const (
	// EventTemplateLog identifies diagnostic events emitted from templates.
	EventTemplateLog = "ext.logger.template"
)

Variables

This section is empty.

Functions

func FuncMap

func FuncMap() template.FuncMap

FuncMap returns the optional logger template helper for static parsing and docs.

func Logger

func Logger(ctx *partial.RenderContext, message string, pairs ...any) string

Logger emits an info-level diagnostic event from template code.

go-doc:sig func(message string, pairs ...any) string

func Sink

func Sink(log *slog.Logger, options ...Option) partial.EventSink

Sink returns an event sink that writes diagnostic events to slog, those of level warn and above unless options say otherwise. A nil log writes to slog.Default() as it is when each event is written, so a default set later is used.

func Stage

func Stage() partial.RenderStage

Stage gives templates the request-scoped logger helper. It is made only for the templates that call it.

Types

type Option

type Option func(*config)

Option configures a logger sink.

func WithLevels added in v0.15.0

func WithLevels(levels ...partial.EventLevel) Option

WithLevels writes only events of the given levels, whatever the minimum level.

func WithMinLevel

func WithMinLevel(level partial.EventLevel) Option

WithMinLevel ignores events below level.

Jump to

Keyboard shortcuts

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