sentry

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldError       = "error"
	FieldRequest     = "request"
	FieldEnvironment = "env"
	FieldBuildInfo   = "build"
)

Common log fields.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler is a log/slog.Handler for Sentry.

func New

func New(level slog.Leveler, options sentry.ClientOptions) (*Handler, error)

New returns a new Sentry logging handler.

func NewFromClient

func NewFromClient(level slog.Leveler, client *sentry.Client) *Handler

NewFromClient initializes a new Handler which sends logs to the provided sentry client.

func (*Handler) Enabled

func (h *Handler) Enabled(_ context.Context, level slog.Level) bool

Enabled returns true if level is at least to the configured minimum level.

func (*Handler) Flush

func (h *Handler) Flush(timeout time.Duration) bool

Flush waits until the underlying Sentry transport sends any buffered events, blocking for at most the given timeout. It returns false if the timeout was reached, in which case some events may not have been sent.

func (*Handler) Handle

func (h *Handler) Handle(_ context.Context, r slog.Record) error

Handle logs r Sentry.

func (*Handler) ReplaceAttr added in v0.2.0

func (h *Handler) ReplaceAttr(fn func(groups []string, a slog.Attr) slog.Attr)

ReplaceAttr can be used to change the default keys of the built-in attributes, convert types (for example, to replace a `time.Time` with the integer seconds since the Unix epoch), sanitize personal information, or remove attributes from the output.

func (*Handler) WithAttrs

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

WithAttrs returns a clone of h, with attrs appended.

func (*Handler) WithGroup

func (h *Handler) WithGroup(name string) slog.Handler

WithGroup returns a clone of h, with the named group added.

Jump to

Keyboard shortcuts

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