logger

package
v0.24.0 Latest Latest
Warning

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

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

Documentation

Overview

Package logger configures structured logging and carries loggers through contexts.

Index

Constants

View Source
const (
	EventQuarantine  = "quarantine"
	EventReceived    = "received"
	EventCorrelation = "correlation"
)

Event names for the notable proxy events, used as the event tag value.

View Source
const Component = "spectre"

Component is the component tag value shared by every SPECTRE proxy log line, e.g. the @component:spectre facet in Datadog.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *slog.Logger

FromContext returns the attached logger, or a logger that discards output if none is attached.

func New

func New(config Config, output io.Writer) *slog.Logger

New constructs a logger that writes to output using the supplied configuration.

func Tagged added in v0.20.0

func Tagged(log *slog.Logger) *slog.Logger

Tagged returns log with the SPECTRE component tag attached to every line.

func WithLogger

func WithLogger(ctx context.Context, log *slog.Logger) context.Context

WithLogger returns a child context carrying log without changing the parent context.

Types

type Config

type Config struct {
	// Level is the minimum severity written to the log.
	Level slog.Level `name:"log-level" default:"info" help:"Minimum log level (debug, info, warn, error)."`
	// JSON enables JSON output instead of text output.
	JSON bool `name:"log-json" help:"Write logs as JSON."`
}

Config contains logging flags that can be embedded in a Kong CLI.

func NewConfig

func NewConfig() Config

NewConfig returns the default logging configuration: info-level text output.

Jump to

Keyboard shortcuts

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