ctxlogger

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 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.FieldLogger

func UnaryServerInterceptor

func UnaryServerInterceptor(logger log.FieldLogger, 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.FieldLogger) context.Context

Types

type ExtractFunction

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

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