slogcommon

package module
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 10 Imported by: 65

README

Nothing to see here (internal package)

tag Go Version GoDoc Build Status Go report Coverage Contributors License

gif-nothing-to-see-meme

A toolchain for slog Go library.

This project gathers common functions for my slog Go libraries:

See also:

HTTP middlewares:

Loggers:

Log sinks:

🤝 Contributing

Don't hesitate ;)

# Install some dev dependencies
make tools

# Run tests
make test
# or
make watch-test

👤 Contributors

Contributors

💫 Show your support

Give a ⭐️ if this project helped you!

GitHub Sponsors

📝 License

Copyright © 2023 Samuel Berthe.

This project is MIT licensed.

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 added in v0.10.0

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

func AttrToValue

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

func AttrsToMap added in v0.10.0

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

func AttrsToString added in v0.3.0

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

func ContextExtractor added in v0.16.0

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

func ExtractError added in v0.15.0

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

func ExtractFromContext added in v0.16.0

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 added in v0.13.0

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

func FormatError

func FormatError(err error) any

func FormatErrorKey

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

func FormatRequest added in v0.5.0

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

func RecordToAttrsMap added in v0.19.0

func RecordToAttrsMap(r slog.Record) map[string]any

func RemoveEmptyAttrs added in v0.17.0

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

func ReplaceAttrs added in v0.7.0

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

func ReplaceError added in v0.11.0

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

func Source added in v0.9.0

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

func StringSource added in v0.13.0

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

func UniqAttrs

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

@TODO: should be recursive

func ValueToString added in v0.2.0

func ValueToString(v slog.Value) string

Types

type ReplaceAttrFn added in v0.7.0

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