dobs

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 5 Imported by: 1

README

dobs

unified solution for logs, metrics, errors, context in Go

It's just the first letter of my name and obs-ervability

Design

API ideas
ContextWithAttrs / AttrsFromContext
NewErrorWithAttrs / NewErrorFromContext
WrapSlogHandler / ToSlogHandler
AttrsFromJSON / AttrsToJSON

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorRecordGroup = "error"

Functions

func ContextAppendAttrs

func ContextAppendAttrs(parent context.Context, attrs ...Attr) context.Context

Types

type Attr

type Attr = slog.Attr

type Attrs

type Attrs []Attr

func AttrsFromContext

func AttrsFromContext(ctx context.Context) Attrs

func UnwrapAttrs

func UnwrapAttrs(err error) Attrs

func (Attrs) Copy

func (attrs Attrs) Copy() Attrs

func (Attrs) Find

func (attrs Attrs) Find(key string) (Attr, bool)

type ContextKeyType

type ContextKeyType string
const (
	ContextKeyAttrs ContextKeyType = "attrs"
)

type Error

type Error struct {
	Err   error
	Attrs Attrs
	// contains filtered or unexported fields
}

func Errorf

func Errorf(f string, a ...any) Error

func NewError

func NewError(err error, addPCDepth int) Error

func (Error) Error

func (e Error) Error() string

func (Error) LogTo

func (e Error) LogTo(ctx context.Context, logger *slog.Logger)

func (Error) Record

func (e Error) Record() slog.Record

func (Error) Unwrap

func (e Error) Unwrap() error

func (Error) WithAttrs

func (e Error) WithAttrs(attrs ...Attr) Error

func (Error) WithContextAttrs

func (e Error) WithContextAttrs(ctx context.Context) Error

func (Error) WrappedAttrs

func (e Error) WrappedAttrs() Attrs

type Record

type Record slog.Record

type SlogHandler

type SlogHandler struct {
	// contains filtered or unexported fields
}

func NewSlogHandler

func NewSlogHandler(wrapped slog.Handler) *SlogHandler

func (*SlogHandler) Enabled

func (slh *SlogHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*SlogHandler) Handle

func (slh *SlogHandler) Handle(ctx context.Context, r slog.Record) error

func (*SlogHandler) WithAttrs

func (slh *SlogHandler) WithAttrs(attrs []Attr) slog.Handler

func (*SlogHandler) WithGroup

func (slh *SlogHandler) WithGroup(name string) slog.Handler

type Value

type Value = slog.Value

Jump to

Keyboard shortcuts

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