stackdriver

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEBUG     = slog.LevelDebug
	INFO      = slog.LevelInfo
	NOTICE    = slog.Level(2)
	WARNING   = slog.LevelWarn
	ERROR     = slog.LevelError
	CRITICAL  = slog.Level(10)
	ALERT     = slog.Level(12)
	EMERGENCY = slog.Level(14)
)

The slog package provides four log levels by default, and each one is associated with an integer value: DEBUG (-4), INFO (0), WARN (4), and ERROR (8).

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(ctx context.Context) *slog.Logger

GetLogger gets a *slog.Logger from context or returns the default one.

func Logging

func Logging(
	hOpts *HandlerOptions,
	mOpts *MiddlewareOptions,
) func(http.Handler) http.Handler

func ParseLogLevel

func ParseLogLevel(value string) slog.Leveler

func ReplaceLogLevel

func ReplaceLogLevel(_ []string, a slog.Attr) slog.Attr

func WithLogger

func WithLogger(ctx context.Context, logger *slog.Logger) context.Context

WithLogger adds a *slog.Logger to the current context.

func WithTrace

func WithTrace(
	logger *slog.Logger,
	span trace.Span,
	googleProjectID string,
) *slog.Logger

Types

type Handler

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

func NewHandler

func NewHandler(opts *HandlerOptions) *Handler

func (*Handler) Enabled

func (h *Handler) Enabled(ctx context.Context, level slog.Level) bool

func (*Handler) Handle

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

func (*Handler) WithAttrs

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

func (*Handler) WithGroup

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

type HandlerOptions

type HandlerOptions struct {
	ServiceName    string
	ServiceVersion string
	MinLevel       slog.Leveler
	AddSource      bool
}

type MiddlewareOptions

type MiddlewareOptions struct {
	GCPProjectID   string
	AddTrace       bool
	AddHTTPRequest bool
}

type Stack

type Stack []uintptr

func CaptureStack

func CaptureStack() *Stack

func (*Stack) Slice

func (s *Stack) Slice() []string

func (*Stack) String

func (s *Stack) String() string

Jump to

Keyboard shortcuts

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