connectlog

package module
v0.0.0-...-d6ca787 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 8 Imported by: 1

README

Connect log package

PkgDoDev

This package contains Connect interceptor that uses slog.Logger to log results of handler calls.

Note: we have gcpconnect.go package that wraps this package and some other standard interceptors.

By default, it doesn't log when handler returns nil error. This can be changed by using connectlog.WithSuccess().

Example:

	path, handler := xxxconnect.NewXXXServiceHandler(
		service,
		connect.WithInterceptors(connectlog.NewLoggingInterceptor(logger)),
		connect.WithRecover(connectlog.NewLoggingRecoverHandler(logger)),
	)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoggingInterceptor

func NewLoggingInterceptor(logger *slog.Logger, opts ...Option) connect.UnaryInterceptorFunc

NewLoggingInterceptor returns unary interceptor that logs response errors. It injects context logger with method and trace context.

func NewLoggingRecoverHandler

func NewLoggingRecoverHandler(logger *slog.Logger) func(context.Context, connect.Spec, http.Header, any) error

NewLoggingRecoverHandler returns a recover handler that logs panics.

Types

type Option

type Option func(o *options)

func WithSuccess

func WithSuccess() Option

Jump to

Keyboard shortcuts

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