logging

package
v0.0.0-...-86597e6 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JsonHandler    = LoggingHandle("json")
	TextHandler    = LoggingHandle("text")
	SentryHandler  = LoggingHandle("sentry")
	RollbarHandler = LoggingHandle("rollbar")
)
View Source
const (
	BackendJsonHandler = BackendLoggingHandle("json")
	BackendTextHandler = BackendLoggingHandle("text")
)

Variables

View Source
var (
	IgnoreTracing = slog.Attr{
		Key:   "Ignore",
		Value: slog.BoolValue(true),
	}
)

Functions

func NewAsyncHandler

func NewAsyncHandler(h slog.Handler) slog.Handler

func NewJSONHandler

func NewJSONHandler(opts ...Option) slog.Handler

func NewTextHandler

func NewTextHandler(opts ...Option) slog.Handler

func ToInterface

func ToInterface[T any](values []T) []any

func WithErr

func WithErr(err error) slog.Attr

func WithStack

func WithStack(err error) slog.Attr

Types

type AsyncHandler

type AsyncHandler struct {
	slog.Handler
	// contains filtered or unexported fields
}

func (*AsyncHandler) Close

func (h *AsyncHandler) Close() error

func (*AsyncHandler) Handle

func (h *AsyncHandler) Handle(ctx context.Context, r slog.Record) error

func (*AsyncHandler) WithAttrs

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

func (*AsyncHandler) WithGroup

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

type Backend

type Backend struct {
	Level   slog.Level           `yaml:"level" default:"info"`
	Handler BackendLoggingHandle `yaml:"handler" default:"json"`
}

type BackendLoggingHandle

type BackendLoggingHandle string

type ErrorTracking

type ErrorTracking struct {
	slog.Handler
	// contains filtered or unexported fields
}

func (*ErrorTracking) Close

func (h *ErrorTracking) Close() error

func (*ErrorTracking) Handle

func (h *ErrorTracking) Handle(ctx context.Context, record slog.Record) error

func (*ErrorTracking) WithAttrs

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

func (*ErrorTracking) WithGroup

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

type Handle

type Handle interface {
	slog.Handler
	io.Closer
}

func NewDatadogHandler

func NewDatadogHandler(service Service, handler slog.Handler) Handle

func NewErrorTracking

func NewErrorTracking(handler slog.Handler) Handle

func NewHandler

func NewHandler(handlers ...slog.Handler) Handle

func NewRollbarHandler

func NewRollbarHandler(conf *RollbarConfig) Handle

func NewSentryHandler

func NewSentryHandler(conf *SentryConfig, environment string) Handle

type LoggingHandle

type LoggingHandle string

type Option

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

func WithHandler

func WithHandler(handler slog.Handler) Option

func WithLevel

func WithLevel(level slog.Leveler) Option

func WithReplaceAttr

func WithReplaceAttr(attrFn ReplaceAttr) Option

func WithWriter

func WithWriter(writer io.Writer) Option

type ReplaceAttr

type ReplaceAttr func(groups []string, a slog.Attr) slog.Attr

type RollbarConfig

type RollbarConfig struct {
	LogLevel string  `yaml:"logLevel" default:"warn"`
	Token    string  `yaml:"token"`
	Backend  Backend `yaml:"backend"`

	Client *http.Client
	// contains filtered or unexported fields
}

func (*RollbarConfig) Close

func (c *RollbarConfig) Close()

func (*RollbarConfig) Init

func (c *RollbarConfig) Init(env, version, serverRoot string)

type SentryConfig

type SentryConfig struct {
	LogLevel       string   `yaml:"logLevel" default:"warn"`
	DSN            string   `yaml:"dsn"`
	SampleRate     float64  `yaml:"sampleRate" default:"1.0"`
	IgnoreErrors   []string `yaml:"ignoreErrors"`
	Debug          bool     `yaml:"debug"`
	SendDefaultPII bool     `yaml:"sendDefaultPII"`
	Backend        Backend  `yaml:"backend"`

	Environment string
	Transport   sentry.Transport
}

func (*SentryConfig) SentryOptions

func (c *SentryConfig) SentryOptions(environment string) sentry.ClientOptions

type Service

type Service interface {
	ServiceName() string
	Environment() string
	Version() string
}

Jump to

Keyboard shortcuts

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