rpclog

package
v3.17.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Overview

Package rpclog implements a gRPC logging middleware.

Index

Constants

View Source
const NamespaceHook = "namespace"

NamespaceHook is the name of the namespace hook.

Variables

This section is empty.

Functions

func AddField added in v3.11.1

func AddField(ctx context.Context, key string, value interface{})

AddField adds a log field to the fields in the request context. Not safe for concurrent use.

func DefaultClientCodeToLevel

func DefaultClientCodeToLevel(code codes.Code) log.Level

DefaultClientCodeToLevel is the default implementation of gRPC return codes to log levels for client side.

func DefaultCodeToLevel

func DefaultCodeToLevel(code codes.Code) log.Level

DefaultCodeToLevel is the default implementation of gRPC return codes and interceptor log level for server side.

func ReplaceGrpcLogger

func ReplaceGrpcLogger(logger log.Interface)

ReplaceGrpcLogger sets the given log.Interface as a gRPC-level logger. This should be called *before* any other initialization, preferably from init() functions.

func StreamClientInterceptor

func StreamClientInterceptor(ctx context.Context, opts ...Option) grpc.StreamClientInterceptor

StreamClientInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls.

func StreamNamespaceHook

func StreamNamespaceHook(namespace string) hooks.StreamHandlerMiddleware

StreamNamespaceHook adds the component namespace to the context of the stream.

func StreamServerInterceptor

func StreamServerInterceptor(ctx context.Context, opts ...Option) grpc.StreamServerInterceptor

StreamServerInterceptor returns a new streaming server interceptor that adds the logger from the global context to the call context.

func UnaryClientInterceptor

func UnaryClientInterceptor(ctx context.Context, opts ...Option) grpc.UnaryClientInterceptor

UnaryClientInterceptor returns a new unary client interceptor that optionally logs the execution of external gRPC calls.

func UnaryNamespaceHook

func UnaryNamespaceHook(namespace string) hooks.UnaryHandlerMiddleware

UnaryNamespaceHook adds the component namespace to the context of the unary call.

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, opts ...Option) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptors that adds the logger from the global context to the call context.

Types

type CodeToLevel

type CodeToLevel func(code codes.Code) log.Level

CodeToLevel function defines the mapping between gRPC return codes and interceptor log level.

type Option

type Option func(*options)

Option for the grpc logging interceptors

func WithCodes

func WithCodes(f grpc_logging.ErrorToCode) Option

WithCodes customizes the function for mapping errors to error codes.

func WithIgnoreMethods added in v3.9.0

func WithIgnoreMethods(methods []string) Option

WithIgnoreMethods sets a list of methods for which no log messages are printed on success.

func WithLevels

func WithLevels(f CodeToLevel) Option

WithLevels customizes the function for mapping gRPC return codes and interceptor log level statements.

Jump to

Keyboard shortcuts

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