buckets

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Attrs map[string]any
}

Bucket holds key value pairs to log, it can hold other Bucket's to implement groups.

func (*Bucket) Append

func (l *Bucket) Append(attrs ...any)

append stores into it's context: Pairs of [string, any] or slog.Attr's. For any other format, it will print the value or values given with a BADKEY name.

func (*Bucket) AsAttrs

func (l *Bucket) AsAttrs() []any

asAttrs returns internal representation of context as slog.Attr's to be printed by a slog.Logger.

type BucketConfig

type BucketConfig struct {
	// Logger used to log with context
	Logger *slog.Logger
	// Allocated Capacity for a new bucket, this is sent to 'make' as
	// the Capacity for internal maps. i.e. make(map[string]any, Capacity)
	Capacity int
}

BucketConfig stores the configuration options used to create a new internal map where key / values will be stored.

func DefaultBucketConfig

func DefaultBucketConfig() *BucketConfig

Generate default values for a BucketConfig.

type BucketConfigurator

type BucketConfigurator = func(c *BucketConfig)

BucketConfigurator mutates the configuration to create a new internal map where key / values will be stored.

func WithCapacity

func WithCapacity(capacity int) BucketConfigurator

WithCapacity modifies the default capacity for a bucket. Returns a BucketConfigurator with the given capacity.

func WithLogger

func WithLogger(logger *slog.Logger) BucketConfigurator

WithLogger modifies the default logger for a bucket. Returns a BucketConfigurator with the given logger.

Jump to

Keyboard shortcuts

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