ctxlogger

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterLogs

func FilterLogs(req any) map[string]interface{}

func GetLogger

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

func UnaryServerInterceptor

func UnaryServerInterceptor(logger *log.Logger, extractFunction ExtractFunction) grpc.UnaryServerInterceptor

The first registerred interceptor will be called first. Need to register requestid first to add request-id. Then the logger can get the request-id.

func WithLogger

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

Types

type ExtractFunction

type ExtractFunction func(ctx context.Context, req any, info *grpc.UnaryServerInfo, logger *log.Logger) *log.Logger

ExtractFunction extracts information from the ctx and/or the request and put it in the logger. This function is called before the application's handler is called so that it can add more context to the logger.

Jump to

Keyboard shortcuts

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