Documentation
¶
Overview ¶
Package grpclog provides logging middleware for gRPC server handlers. It supports request/response body logging with configurable granularity and automatic inclusion of application context from metadata.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombinedLog ¶ added in v1.64.4
func CombinedLog(logger log.Logger, logBody bool) grpc.Middleware
CombinedLog creates a middleware that logs gRPC server requests and responses in a single entry. When logBody is true, request and response bodies are included in the logs. Includes application context (name and ID) from metadata.
func Log ¶
func Log(logger log.Logger, logBody bool) grpc.Middleware
Log creates a middleware that logs gRPC server requests and responses separately. When logBody is true, request and response bodies are included in the logs. Logs at Debug level for requests and responses.
func LogWithOptions ¶
func LogWithOptions(logger log.Logger, opts ...Option) grpc.Middleware
LogWithOptions creates a middleware that logs gRPC server requests and responses with custom options. Provides fine-grained control over what is logged (request body, response body, combined logs).
Types ¶
type Option ¶
type Option func(cfg *logConfig)
Option configures logging behavior for server middleware.
func WithCombinedLog ¶ added in v1.64.4
WithCombinedLog enables a single combined log entry for request and response. When disabled, requests and responses are logged separately.
func WithLogBody ¶
WithLogBody enables logging of both request and response bodies.
func WithLogRequestBody ¶
WithLogRequestBody enables or disables logging of request bodies.
func WithLogResponseBody ¶
WithLogResponseBody enables or disables logging of response bodies.