zapsentry

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: MIT Imports: 3 Imported by: 0

README

Sentry client for zap logger

Forked from https://github.com/TheZeroSlave/zapsentry

Added support for Go modules and few other changes.

Integration of sentry client into zap.Logger is pretty simple:

func modifyToSentryLogger(log *zap.Logger, DSN string) *zap.Logger {
	cfg := zapsentry.Configuration{
		Level: zapcore.ErrorLevel, //when to send message to sentry
		Tags: map[string]string{
			"component": "system",
		},
	}
	core, err := zapsentry.NewCore(cfg, zapsentry.NewSentryClientFromDSN(DSN))
	//in case of err it will return noop core. so we can safely attach it
	if err != nil {
		log.Warn("failed to init zap")
	}
	return zapsentry.AttachCoreToLogger(core, log)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachCoreToLogger

func AttachCoreToLogger(sentryCore zapcore.Core, l *zap.Logger) *zap.Logger

func NewCore

func NewCore(cfg Configuration, factory SentryClientFactory) (zapcore.Core, error)

Types

type ClientGetter

type ClientGetter interface {
	GetClient() *raven.Client
}

type Configuration

type Configuration struct {
	Tags              map[string]string
	DisableStacktrace bool
	Level             zapcore.Level
	SkipFrames        int
}

Configuration is a minimal set of parameters for Sentry integration.

type SentryClientFactory

type SentryClientFactory func() (*raven.Client, error)

func NewSentryClientFromClient

func NewSentryClientFromClient(client *raven.Client) SentryClientFactory

func NewSentryClientFromDSN

func NewSentryClientFromDSN(DSN string) SentryClientFactory

Jump to

Keyboard shortcuts

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