Documentation ¶
Index ¶
- Constants
- func Annotator(ctx context.Context, req *http.Request) metadata.MD
- func CopyLoggerWithLevel(logger *logrus.Logger, lvl logrus.Level) *logrus.Logger
- func CustomFieldsStreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamServerInterceptor
- func CustomFieldsUnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor
- func DisableRequestID(o *gwLogCfg)
- func EnableAccountID(o *gwLogCfg)
- func EnableDynamicLogLevel(o *gwLogCfg)
- func GatewayLoggingInterceptor(logger *logrus.Logger, opts ...GWLogOption) grpc.UnaryClientInterceptor
- func GatewayLoggingSentinelInterceptor() grpc.UnaryClientInterceptor
- func LogLevelInterceptor(defaultLevel logrus.Level) grpc.UnaryServerInterceptor
- func New(level string) *logrus.Logger
- func SentinelValueFromCtx(ctx context.Context) (value, ok bool)
- func StreamClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamClientInterceptor
- func StreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamServerInterceptor
- func UnaryClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryClientInterceptor
- func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor
- type CodeToLevel
- type GWLogOption
- type Option
Constants ¶
const ( DefaultAccountIDKey = "account_id" DefaultRequestIDKey = "request_id" DefaultSubjectKey = "subject" // Might be used for different purposes DefaultDurationKey = "grpc.time_ms" DefaultGRPCCodeKey = "grpc.code" DefaultGRPCMethodKey = "grpc.method" DefaultGRPCServiceKey = "grpc.service" DefaultGRPCStartTimeKey = "grpc.start_time" DefaultClientKindValue = "client" DefaultServerKindValue = "server" )
Variables ¶
This section is empty.
Functions ¶
func Annotator ¶
Annotator is a function that reads the http headers of incoming requests searching for special logging arguments
func CopyLoggerWithLevel ¶
CopyLoggerWithLevel makes a copy of the given (logrus) logger at the logger level. If copying an entry, use CopyLoggerWithLevel(entry.Logger, level).WithFields(entry.Data) on the result (changes to these entries' fields will not affect each other).
func CustomFieldsStreamServerInterceptor ¶ added in v0.19.3
func CustomFieldsStreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamServerInterceptor
func CustomFieldsUnaryServerInterceptor ¶ added in v0.19.3
func CustomFieldsUnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor
func DisableRequestID ¶ added in v0.16.2
func DisableRequestID(o *gwLogCfg)
DisableRequestID disables request-id inclusion (and generation if needed) in gw interceptor logs
func EnableAccountID ¶ added in v0.16.2
func EnableAccountID(o *gwLogCfg)
EnableAccountID is a shorthand for WithAccountID(nil)
func EnableDynamicLogLevel ¶ added in v0.16.2
func EnableDynamicLogLevel(o *gwLogCfg)
EnableDynamicLogLevel is a shorthand for WithDynamicLogLevel(true)
func GatewayLoggingInterceptor ¶ added in v0.16.2
func GatewayLoggingInterceptor(logger *logrus.Logger, opts ...GWLogOption) grpc.UnaryClientInterceptor
GatewayLoggingInterceptor handles the functions of the various toolkit interceptors offered for the grpc server, as well as the standard grpc_logrus server interceptor behavior (superset of grpc_logrus client interceptor behavior)
func GatewayLoggingSentinelInterceptor ¶ added in v0.16.2
func GatewayLoggingSentinelInterceptor() grpc.UnaryClientInterceptor
GatewayLoggingSentinelInterceptor is meant to be the last interceptor in the client interceptor chain, it sets a value left in the context by the GatewayLoggingInterceptor so that it knows whether the call makes it to the server, and thus the server will log the call, and the gateway doesn't need to.
func LogLevelInterceptor ¶
func LogLevelInterceptor(defaultLevel logrus.Level) grpc.UnaryServerInterceptor
LogLevelInterceptor sets the level of the logger in the context to either the default or the value set in the context via grpc metadata. Also sets the custom log tag if present for pseudo-tracing purposes
func SentinelValueFromCtx ¶ added in v0.17.0
func StreamClientInterceptor ¶ added in v0.19.3
func StreamClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamClientInterceptor
func StreamServerInterceptor ¶ added in v0.19.3
func StreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamServerInterceptor
func UnaryClientInterceptor ¶ added in v0.19.3
func UnaryClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryClientInterceptor
func UnaryServerInterceptor ¶ added in v0.19.3
func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor
Types ¶
type CodeToLevel ¶ added in v0.19.3
CodeToLevel function defines the mapping between gRPC return codes and interceptor log level. From https://github.com/grpc-ecosystem/go-grpc-middleware/blob/06f64829ca1f521d41cd6235a7a204a6566fb0dc/logging/logrus/options.go#L57
type GWLogOption ¶ added in v0.16.2
type GWLogOption func(*gwLogCfg)
GWLogOption is a type of function that alters a gwLogCfg in the instantiation of a GatewayLoggingInterceptor
func WithAccountID ¶ added in v0.16.2
func WithAccountID(keyfunc jwt.Keyfunc) GWLogOption
WithAccountID enables the account_id field in gw interceptor logs, like the server interceptor
func WithCodeFunc ¶ added in v0.17.0
func WithCodeFunc(codeFunc grpc_logrus.CodeToLevel) GWLogOption
func WithDynamicLogLevel ¶ added in v0.16.2
func WithDynamicLogLevel(enable bool) GWLogOption
WithDynamicLogLevel enables or disables dynamic log levels like handled in the server interceptor
type Option ¶ added in v0.19.3
type Option func(*options)
func WithCustomFields ¶ added in v0.19.3
Allows to provide custom fields for logging which are expected to be in JWT token
func WithCustomHeaders ¶ added in v0.19.3
Allows to provide custom fields for logging from request headers
func WithLevels ¶ added in v0.19.3
func WithLevels(f CodeToLevel) Option
WithLevels customizes the function for mapping gRPC return codes and interceptor log level statements. From https://github.com/grpc-ecosystem/go-grpc-middleware/blob/06f64829ca1f521d41cd6235a7a204a6566fb0dc/logging/logrus/options.go#L70