Documentation ¶
Overview ¶
Package grpclogger creates a logger interface to be used in grpc logger package (google.golang.org/grpc/grpclog). For more information on grpc see http://www.grpc.io, for grpc-go see https://github.com/grpc/grpc-go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateLogger ¶
CreateLogger creates a new logger that can be used in grpc/grpclog. It follows the default log package style of logging and therefore it doesn't have log levels (EventType). Because of this all calls to Print* will call logger.Error, hoping that grpclogger will only log errors in production.
Another shortcoming of the Logger interface defined by grpclog is that uses an empty interface a lot. We combat this by trying to make this into a single string using the fmt package. As result of this the message might not look very pretty, but it will contain all the provided information.
A third point is that a call to Fatal* in the builtin log package calls to os.Exit, which closes the application immediately without running deffered statements. To combat that we accept a close function which runs before the call to os.Exit. In this function logger.Close must be called by the user.
Types ¶
This section is empty.