slogcommon

package module
v0.0.0-...-e1e94c1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 10 Imported by: 1

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:

🀝 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 ΒΆ

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 ExtractError ΒΆ

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

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 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