sentry

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 5 Imported by: 1

README

sentry-slog

Usage

import (
	"context"
	"log"
	"log/slog"

	sentry "github.com/litsea/sentry-slog"
)

h, err := sentry.NewHandler(
	sentry.WithDSN("https://sentry-dsn"),
	sentry.WithAttachStacktrace(true),
	sentry.WithEnvironment("local"),
	sentry.WithRelease("v0.1.0")
	sentry.WithLogLevel(slog.LevelError),
	sentry.WithLogAddSource(true),
	sentry.WithLogAttrFromContext(func(ctx context.Context){ ... }),
	sentry.WithLogReplaceAttr(func(groups []string, a slog.Attr) slog.Attr { ... })
	sentry.WithLogExtraAttrs(map[string]string{ ... }),
)
if err != nil {
	log.Fatal(err)
}

Default Options:

  • AttachStacktrace: true
  • LogLevel: slog.LevelError
  • LogAddSource: true
  • LogExtraAttrs: defaultLogExtraAttrs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(opts ...Option) (slog.Handler, error)

Types

type Option

type Option func(opt *sentry.ClientOptions, _ *slogsentry.Option, _ *logConfig)

func WithAttachStacktrace

func WithAttachStacktrace(v bool) Option

func WithDSN

func WithDSN(dsn string) Option

func WithDebug

func WithDebug(v bool) Option

func WithEnvironment

func WithEnvironment(env string) Option

func WithLogAddSource

func WithLogAddSource(v bool) Option

func WithLogAttrFromContext

func WithLogAttrFromContext(fns ...func(ctx context.Context) []slog.Attr) Option

func WithLogExtraAttrs

func WithLogExtraAttrs(attrs map[string]string) Option

func WithLogLevel

func WithLogLevel(l slog.Level) Option

func WithLogReplaceAttr added in v0.2.1

func WithLogReplaceAttr(fns ...func(groups []string, a slog.Attr) slog.Attr) Option

func WithRelease

func WithRelease(rev string) Option

func WithSentryHub added in v0.2.3

func WithSentryHub(hub *sentry.Hub) Option

Jump to

Keyboard shortcuts

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