Documentation ¶
Index ¶
- Constants
- Variables
- func Configure(loggers []*logrus.Logger, format string, level string)
- func Default() *logrus.Entry
- func GrpcGo() *logrus.Entry
- func MessageProducer(mp grpcmwlogrus.MessageProducer, fieldsProducers ...FieldsProducer) grpcmwlogrus.MessageProducer
- func PropagationMessageProducer(actual grpcmwlogrus.MessageProducer) grpcmwlogrus.MessageProducer
- func StreamLogDataCatcherServerInterceptor() grpc.StreamServerInterceptor
- func UTCJsonFormatter() logrus.Formatter
- func UTCTextFormatter() logrus.Formatter
- func UnaryLogDataCatcherServerInterceptor() grpc.UnaryServerInterceptor
- type FieldsProducer
- type HookLogger
- type PerRPCLogHandler
- func (lh PerRPCLogHandler) HandleConn(ctx context.Context, cs stats.ConnStats)
- func (lh PerRPCLogHandler) HandleRPC(ctx context.Context, rs stats.RPCStats)
- func (lh PerRPCLogHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context
- func (lh PerRPCLogHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context
Constants ¶
const ( // GitalyLogDirEnvKey defines the environment variable used to specify the Gitaly log directory GitalyLogDirEnvKey = "GITALY_LOG_DIR" // LogTimestampFormat defines the timestamp format in log files LogTimestampFormat = "2006-01-02T15:04:05.000" // LogTimestampFormatUTC defines the utc timestamp format in log files LogTimestampFormatUTC = "2006-01-02T15:04:05.000Z" )
Variables ¶
var ( // Loggers is convenient when you want to apply configuration to all // loggers Loggers = []*logrus.Logger{defaultLogger, grpcGo} )
Functions ¶
func Configure ¶
Configure sets the format and level on all loggers. It applies level mapping to the GrpcGo logger.
func GrpcGo ¶
GrpcGo is a dedicated logrus logger for the grpc-go library. We use it to control the library's chattiness.
func MessageProducer ¶ added in v14.5.0
func MessageProducer(mp grpcmwlogrus.MessageProducer, fieldsProducers ...FieldsProducer) grpcmwlogrus.MessageProducer
MessageProducer returns a wrapper that extends passed mp to accept additional fields generated by each of the fieldsProducers.
func PropagationMessageProducer ¶ added in v14.5.0
func PropagationMessageProducer(actual grpcmwlogrus.MessageProducer) grpcmwlogrus.MessageProducer
PropagationMessageProducer catches logging information from the context and populates it to the special holder that should be present in the context. Should be used only in combination with PerRPCLogHandler.
func StreamLogDataCatcherServerInterceptor ¶ added in v14.5.0
func StreamLogDataCatcherServerInterceptor() grpc.StreamServerInterceptor
StreamLogDataCatcherServerInterceptor catches logging data produced by the upper interceptors and propagates it into the holder to pop up it to the HandleRPC method of the PerRPCLogHandler.
func UTCJsonFormatter ¶ added in v14.4.0
UTCJsonFormatter returns a Formatter that formats a logrus Entry's as json and converts the time field into UTC
func UTCTextFormatter ¶ added in v14.4.0
UTCTextFormatter returns a Formatter that formats a logrus Entry's as text and converts the time field into UTC
func UnaryLogDataCatcherServerInterceptor ¶ added in v14.5.0
func UnaryLogDataCatcherServerInterceptor() grpc.UnaryServerInterceptor
UnaryLogDataCatcherServerInterceptor catches logging data produced by the upper interceptors and propagates it into the holder to pop up it to the HandleRPC method of the PerRPCLogHandler.
Types ¶
type FieldsProducer ¶ added in v14.5.0
FieldsProducer returns fields that need to be added into the logging context.
type HookLogger ¶
type HookLogger struct {
// contains filtered or unexported fields
}
HookLogger is a wrapper around *logrus.Logger
func NewHookLogger ¶
func NewHookLogger() *HookLogger
NewHookLogger creates a file logger, since both stderr and stdout will be displayed in git output
func (*HookLogger) Errorf ¶
func (h *HookLogger) Errorf(format string, a ...interface{})
Errorf logs a formatted error at the Fatal level
func (*HookLogger) Fatal ¶
func (h *HookLogger) Fatal(err error)
Fatal logs an error at the Fatal level and writes a generic message to stderr
func (*HookLogger) Fatalf ¶
func (h *HookLogger) Fatalf(format string, a ...interface{})
Fatalf logs a formatted error at the Fatal level
func (*HookLogger) Logger ¶
func (h *HookLogger) Logger() *logrus.Logger
Logger returns the underlying logrus logger
type PerRPCLogHandler ¶ added in v14.5.0
type PerRPCLogHandler struct { Underlying stats.Handler FieldProducers []FieldsProducer }
PerRPCLogHandler is designed to collect stats that are accessible from the google.golang.org/grpc/stats.Handler, because some information can't be extracted on the interceptors level.
func (PerRPCLogHandler) HandleConn ¶ added in v14.5.0
func (lh PerRPCLogHandler) HandleConn(ctx context.Context, cs stats.ConnStats)
HandleConn only calls Underlying and exists to satisfy gRPC stats.Handler.
func (PerRPCLogHandler) HandleRPC ¶ added in v14.5.0
func (lh PerRPCLogHandler) HandleRPC(ctx context.Context, rs stats.RPCStats)
HandleRPC catches each RPC call and for the *stats.End stats invokes custom message producers to populate logging data. Once all data is collected the actual logging happens by using logger that is caught by PropagationMessageProducer.
func (PerRPCLogHandler) TagConn ¶ added in v14.5.0
func (lh PerRPCLogHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context
TagConn only calls Underlying and exists to satisfy gRPC stats.Handler.
func (PerRPCLogHandler) TagRPC ¶ added in v14.5.0
func (lh PerRPCLogHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context
TagRPC propagates a special data holder into the context that is responsible to hold logging information produced by the logging interceptor. The logging data should be caught by the UnaryLogDataCatcherServerInterceptor. It needs to be included into the interceptor chain below logging interceptor.