logging

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(v string)

Format will update the atomic logger value of which the slog.Handler is constructed. Valid values are "json" | "text" | "JSON" | "Text" | "TEXT". Defaults to "text".

func Level

func Level(v slog.Level)

Level sets the atomic, global log-level

func Logger

func Logger(settings ...Variadic) slog.Handler

func Verbose

func Verbose(v bool)

Verbose enables an atomic.Pointer to log internal Handler log messages.

Types

type Exclusions

type Exclusions struct {
	// Headers to exclude from request logging. Defaults include:
	//
	// 	- "Accept"
	// 	- "Accept-Encoding"
	// 	- "Accept-Language"
	// 	- "Connection"
	// 	- "Content-Length"
	// 	- "Content-Type"
	// 	- "Upgrade-Insecure-Requests"
	// 	- "Sec-Fetch-Mode"
	// 	- "Sec-Fetch-Site"
	// 	- "Sec-Fetch-Resource"
	// 	- "Sec-Fetch-User"
	// 	- "Sec-Fetch-Dest"
	// 	- "User-Agent"
	Headers []string
}

type Flag

type Flag[Value interface{}] interface {
	// Set will configure the given Setting implementation's logging flag.
	Set(v Value)

	// Value returns the implementation's value reference.
	Value() Value
}

Flag represents a given logging Option's value(s).

type Handler

type Handler struct {
	slog.Handler
	// contains filtered or unexported fields
}

func (*Handler) Enabled

func (h *Handler) Enabled(ctx context.Context, level slog.Level) bool

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, record slog.Record) error

func (*Handler) WithAttrs

func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*Handler) WithGroup

func (h *Handler) WithGroup(name string) slog.Handler

type Logs

type Logs struct {
	Exclusions Exclusions
}

type Options

type Options struct {
	Service  string
	Settings *slog.HandlerOptions
	Logs     Logs

	// Writer represents the output [io.Writer]. Defaults to [os.Stdout] if unspecified.
	Writer io.Writer
}

func Specification

func Specification() *Options

type Variadic

type Variadic func(o *Options)

Jump to

Keyboard shortcuts

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