connectlog

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 8 Imported by: 1

README

Connect log package

GoDoc

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

Note: we have gcpconnect package that wraps this package and adds telemetry and server code.

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