common

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyValueToString

func AnyValueToString(v slog.Value) string

func AppendAttrsToGroup

func AppendAttrsToGroup(groups []string, actualAttrs []slog.Attr, newAttrs ...slog.Attr) []slog.Attr

func AppendRecordAttrsToAttrs

func AppendRecordAttrsToAttrs(attrs []slog.Attr, groups []string, record *slog.Record) []slog.Attr

func AttrToValue

func AttrToValue(attr slog.Attr) (string, any)

func AttrsToMap

func AttrsToMap(attrs ...slog.Attr) map[string]any

func AttrsToString

func AttrsToString(attrs ...slog.Attr) map[string]string

func ContextExtractor

func ContextExtractor(ctx context.Context, fns []func(ctx context.Context) []slog.Attr) []slog.Attr

func ExtractError

func ExtractError(attrs []slog.Attr, errorKeys ...string) ([]slog.Attr, error)

func ExtractFromContext

func ExtractFromContext(keys ...any) func(ctx context.Context) []slog.Attr

func FindAttrByGroupAndKey

func FindAttrByGroupAndKey(attrs []slog.Attr, groups []string, key string) (slog.Attr, bool)

func FindAttrByKey

func FindAttrByKey(attrs []slog.Attr, key string) (slog.Attr, bool)

func FindAttribute

func FindAttribute(attrs []slog.Attr, groups []string, key string) (slog.Attr, bool)

func FormatError

func FormatError(err error) map[string]any

func FormatErrorKey

func FormatErrorKey(values map[string]any, errorKeys ...string) map[string]any

func FormatRequest

func FormatRequest(req *http.Request, ignoreHeaders bool) map[string]any

func Map

func Map[T any, R any](collection []T, iteratee func(item T, index int) R) []R

Map manipulates a slice and transforms it to a slice of another type. Play: https://go.dev/play/p/OkPcYAhBo0D

func RemoveEmptyAttrs

func RemoveEmptyAttrs(attrs []slog.Attr) []slog.Attr

func ReplaceAttrs

func ReplaceAttrs(fn ReplaceAttrFn, groups []string, attrs ...slog.Attr) []slog.Attr

func ReplaceError

func ReplaceError(attrs []slog.Attr, errorKeys ...string) []slog.Attr

func Source

func Source(sourceKey string, r *slog.Record) slog.Attr

func StringSource

func StringSource(sourceKey string, r *slog.Record) slog.Attr

func UniqAttrs

func UniqAttrs(attrs []slog.Attr) []slog.Attr

@TODO: should be recursive

func ValueToString

func ValueToString(v slog.Value) string

Types

type ReplaceAttrFn

type ReplaceAttrFn = func(groups []string, a slog.Attr) slog.Attr

Jump to

Keyboard shortcuts

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