# README
Lager gRPC Middleware
Middlewares for gRPC Go based off of grpc-ecosystem/go-grpc-middleware
Note: This library currently does not support streams or stream interceptors
Usage example:
import (
"github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/Unity-Technologies/go-lager-internal/grpc_lager"
)
myServer := grpc.NewServer(
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
grpc_ctxtags.UnaryServerInterceptor(),
grpc_lager.UnaryServerInterceptor(),
grpc_lager.PayloadUnaryServerInterceptor(deciderFunction)
)),
)
# Functions
DefaultCodeToLevel is the default implementation of gRPC return codes and interceptor log level for server side.
DefaultMessageProducer writes the default message.
DurationToDurationField uses a Duration field to log the request duration and leaves it up to Lager's encoder settings to determine how that is output.
DurationToTimeMillisField converts the duration to milliseconds and uses the key `grpc.time_ms`.
Pass in context and one character from "PEFWNAITDOG" to get a Lager object that has all the grpc_ctxtags updated.
No description provided by the author
TagsToPairs extracts the tags provided by the go-grpc-middleware library from the context, adds them to the context as Lager pairs and returns an updated context.
No description provided by the author
WithCodes customizes the function for mapping errors to error codes.
WithDecider customizes the function for deciding if the gRPC interceptor logs should log.
WithDurationField customizes the function for mapping request durations to Lager pairs.
WithLevels customizes the function for mapping gRPC return codes and interceptor log level statements.
WithMessageProducer customizes the function for message formation.
WithTimestampFormat customizes the timestamps emitted in the log fields.
# Variables
DefaultDurationToField is the default implementation of converting request duration to Lager pairs.
JSONPbFormatter is the formatter used for formatting protobuf messages as strings.
ServerField is used in every server-side log statement made through grpc_lager.
SystemField is used in every log statement made through grpc_lager.
# Interfaces
JSONPbFormater is a formatter that formats protobuf messages.
# Type aliases
CodeToLevel function defines the mapping between gRPC return codes and interceptor log level.
DurationToPairs function defines how to produce duration fields for logging.
MessageProducer produces a user defined log message.
No description provided by the author
ServerPayloadLoggingDecider is a user-provided function for deciding whether to log the server-side request/response payloads.