streamlogger

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func NewClientCtx(ctx context.Context, level logrus.Level) context.Context

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL