zlogsentry

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

zerolog-sentry

Build Status

Example
import (
	"errors"
	"io"
	stdlog "log"
	"os"

	"github.com/ColinEge/zerolog-sentry"
	"github.com/rs/zerolog"
)

func main() {
	w, err := zlogsentry.New("http://e35657dcf4fb4d7c98a1c0b8a9125088@localhost:9000/2")
	if err != nil {
		stdlog.Fatal(err)
	}

	defer w.Close()

	logger := zerolog.New(io.MultiWriter(w, os.Stdout)).With().Timestamp().Logger()

	logger.Error().Err(errors.New("dial timeout")).Msg("test message")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

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

func New

func New(dsn string, opts ...WriterOption) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Write

func (w *Writer) Write(data []byte) (int, error)

type WriterOption

type WriterOption interface {
	// contains filtered or unexported methods
}

func WithDebug

func WithDebug() WriterOption

WithDebug enables sentry client debug logs

func WithEnvironment

func WithEnvironment(environment string) WriterOption

func WithLevels

func WithLevels(levels ...zerolog.Level) WriterOption

WithLevels configures zerolog levels that have to be sent to Sentry. Default levels are error, fatal, panic

func WithRelease

func WithRelease(release string) WriterOption

func WithSampleRate

func WithSampleRate(rate float64) WriterOption

WithSampleRate configures the sample rate as a percentage of events to be sent in the range of 0.0 to 1.0

func WithServerName

func WithServerName(serverName string) WriterOption

WithServerName configures the server name field for events. Default value is OS hostname

func WithTags

func WithTags(tags map[string]string) WriterOption

WithTags configures additional tags for the scope

Jump to

Keyboard shortcuts

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