sentrykit

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: MIT Imports: 1 Imported by: 0

README

Sentry Kit

Sentry Kit - is go-kit-like logger. It can handles your error and shows in sentry.

Get Started

package main

import (
	"errors"
	"github.com/fr05t1k/sentrykit"
	"github.com/getsentry/sentry-go"
	"log"
	"os"
	"time"
)

func main() {
	client, _ := sentry.NewClient(sentry.ClientOptions{
		Dsn:         os.Getenv("SENTRY_DSN"),
		Environment: "dev",
	})

	logger := sentrykit.NewSentryLogger(client)

	// msg will be used as Event Title in Sentry
	logger.Log("msg", "User updated", "tries", 1, "properties", map[string]string{"username": "gopher"})
	// if you provide err field it should be error type to get calstack for sentry
	logger.Log("err", errors.New("test error"))

	client.Flush(time.Second * 5)
}

If you specify err field sentry considers as an exception and shows your callstack etc. Otherwise sentry triggers a message and gets the message from msg field.

image

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SentryClient

type SentryClient interface {
	CaptureException(exception error, hint *sentry.EventHint, scope sentry.EventModifier) *sentry.EventID
	CaptureMessage(message string, hint *sentry.EventHint, scope sentry.EventModifier) *sentry.EventID
}

type SentryLogger

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

func NewSentryLogger

func NewSentryLogger(client SentryClient) *SentryLogger

func (*SentryLogger) Log

func (s *SentryLogger) Log(keyvals ...interface{}) error

Sentry Logger captures exceptions if you provide "err" field other wise it captures simple messages

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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