Documentation
¶
Index ¶
- func CaptureBodyStreamServerInterceptor() grpc.StreamServerInterceptor
- func CaptureBodyUnaryServerInterceptor() grpc.UnaryServerInterceptor
- func DisableGRPCBody(ctx context.Context, disableRequestBody bool, disableResponseBody bool) context.Context
- func DisableGRPCTraceBody(ctx context.Context, disableRequestBody bool, disableResponseBody bool) context.Context
- func EnableBody(ctxLogger *builder.Context, enableRequestBody bool, enableResponseBody bool)
- func EnableTraceBody(ctxLogger *builder.Context, enableRequestBody bool, enableResponseBody bool)
- func InitLoggerStreamServerInterceptor() grpc.StreamServerInterceptor
- func InitLoggerUnaryServerInterceptor() grpc.UnaryServerInterceptor
- func LoggerWithConfigStreamServerInterceptor() grpc.StreamServerInterceptor
- func LoggerWithConfigUnaryServerInterceptor() grpc.UnaryServerInterceptor
- func PrintDebug(ctxLogger *builder.Context, message string)
- func PrintError(ctxLogger *builder.Context, err error)
- func PrintInfo(ctxLogger *builder.Context, message string)
- func PrintWarn(ctxLogger *builder.Context, message string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureBodyStreamServerInterceptor ¶
func CaptureBodyStreamServerInterceptor() grpc.StreamServerInterceptor
CaptureBodyStreamServerInterceptor captures inbound and outbound stream messages only while body logging is enabled, then stores the captured values in the logger context.
When only one request or response message is observed, the stored value is that message directly. When multiple messages are exchanged, the stored value becomes a slice so the final log can reflect the full interaction.
func CaptureBodyUnaryServerInterceptor ¶
func CaptureBodyUnaryServerInterceptor() grpc.UnaryServerInterceptor
CaptureBodyUnaryServerInterceptor stores unary request and response payloads in the logger context only when body logging is enabled.
The captured values are later consumed by LoggerWithConfigUnaryServerInterceptor to populate details.request and details.response when each body is enabled.
func DisableGRPCBody ¶
func DisableGRPCBody(ctx context.Context, disableRequestBody bool, disableResponseBody bool) context.Context
DisableGRPCBody marks the current request-scoped logger context so the final gRPC structured log can omit request and response bodies independently.
The returned context is the logger context carrying those flags. In handlers reached through InitLoggerUnaryServerInterceptor or InitLoggerStreamServerInterceptor, the input context already contains the logger and the return value is mostly useful for chaining.
func DisableGRPCTraceBody ¶
func DisableGRPCTraceBody(ctx context.Context, disableRequestBody bool, disableResponseBody bool) context.Context
DisableGRPCTraceBody marks whether downstream trace services should omit their request and response bodies when builder.Context.TraceEnd finishes a trace inside a gRPC request.
func EnableBody ¶ added in v0.0.26
EnableBody marks whether the final gRPC request log should include request and response bodies independently.
Internally it stores the inverse disable flags in the request-scoped logger context so LoggerWithConfig can decide what to copy into details.request and details.response.
func EnableTraceBody ¶ added in v0.0.26
EnableTraceBody marks whether downstream trace services should include their request and response bodies when builder.Context.TraceEnd finishes a trace.
func InitLoggerStreamServerInterceptor ¶
func InitLoggerStreamServerInterceptor() grpc.StreamServerInterceptor
InitLoggerStreamServerInterceptor creates the request-scoped logger context for streaming gRPC calls.
It performs the same setup as InitLoggerUnaryServerInterceptor, but wraps the grpc.ServerStream so downstream handlers observe the enriched context through stream.Context().
func InitLoggerUnaryServerInterceptor ¶
func InitLoggerUnaryServerInterceptor() grpc.UnaryServerInterceptor
InitLoggerUnaryServerInterceptor creates the request-scoped logger context for unary gRPC calls.
It extracts any incoming distributed-tracing headers from gRPC metadata, starts the logger span, attaches the base gRPC metadata used by structured logs, and passes the enriched context to the next handler.
func LoggerWithConfigStreamServerInterceptor ¶
func LoggerWithConfigStreamServerInterceptor() grpc.StreamServerInterceptor
LoggerWithConfigStreamServerInterceptor emits the final structured log entry for a streaming gRPC call.
It applies the same finalization flow as the unary variant, but operates on the stream context and writes the log once the stream handler completes.
func LoggerWithConfigUnaryServerInterceptor ¶
func LoggerWithConfigUnaryServerInterceptor() grpc.UnaryServerInterceptor
LoggerWithConfigUnaryServerInterceptor emits the final structured log entry for a unary gRPC call.
It merges any captured request and response bodies into the logger details and then writes the log using the level previously stored in the logger context. If neither a log level nor a non-nil error is present, the function treats that condition as a developer error.
func PrintDebug ¶
PrintDebug schedules a debug-level log message for the current gRPC request and stores caller metadata so the final logger interceptor can emit it.
func PrintError ¶
PrintError schedules an error-level log message for the current gRPC request and stores caller metadata so the final logger interceptor can emit it.
Types ¶
This section is empty.