slogcommon

package module
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 11 Imported by: 30

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) map[string]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 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