Documentation
¶
Overview ¶
Package streamlogger creates some stream client and server which can proxy logs to client, by adding to the grpc call some metadata used to identify and specify log levels.
Index ¶
- Variables
- func AddLogger(stream StreamLogger, funcName string) (context.Context, error)
- func ClientRequestLogInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, ...) (grpc.ClientStream, error)
- func NewClientCtx(ctx context.Context, level logrus.Level) context.Context
- func ServerIdleTimeoutInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- type StreamLogger
Constants ¶
This section is empty.
Variables ¶
var ErrLogMsg = errors.New(i18n.G("message was log"))
ErrLogMsg allows detecting when a recv message was only logs to client, consumed by the interceptor.
Functions ¶
func AddLogger ¶
func AddLogger(stream StreamLogger, funcName string) (context.Context, error)
AddLogger initializes a stream by checking log level, send headers back to client and return a context for further logging.
func ClientRequestLogInterceptor ¶
func ClientRequestLogInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
ClientRequestLogInterceptor ensure that the stream get a valid requestID from the service in headers and consumes logs by printing them.
func NewClientCtx ¶
NewClientCtx creates a requester ID and attach it to returned context.
func ServerIdleTimeoutInterceptor ¶
func ServerIdleTimeoutInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
ServerIdleTimeoutInterceptor adds a call to reset the server stream timeout if available.
Types ¶
type StreamLogger ¶
type StreamLogger interface { io.Writer grpc.ServerStream }
StreamLogger is an interface to associate a writer (for message passing) to a stream