Documentation ¶
Overview ¶
Package log implements multiple string interceptors to stream logs initiated and tagged from the server to the targeted clients.
This package allows then to multiplex logs, while only sending the parts for each stream connection to the destination client. Each client can have its own log level, independently of the daemon one.
There are also privilege clients where all stream connection could be forwarded.
Index ¶
- Variables
- func AddHook(ctx context.Context, hook logrus.Hook)
- func AddStreamToForward(stream grpc.ServerStream) (disconnect func())
- func Debug(ctx context.Context, args ...interface{})
- func Debugf(ctx context.Context, format string, args ...interface{})
- func Debugln(ctx context.Context, args ...interface{})
- func Error(ctx context.Context, args ...interface{})
- func Errorf(ctx context.Context, format string, args ...interface{})
- func Errorln(ctx context.Context, args ...interface{})
- func Info(ctx context.Context, args ...interface{})
- func Infof(ctx context.Context, format string, args ...interface{})
- func Infoln(ctx context.Context, args ...interface{})
- func RemoveAllStreams()
- func SetReportCaller(reportCaller bool)
- func StreamClientInterceptor(logger *logrus.Logger, args ...Option) grpc.StreamClientInterceptor
- func StreamServerInterceptor(localLogger *logrus.Logger) ...
- func Warning(ctx context.Context, args ...interface{})
- func Warningf(ctx context.Context, format string, args ...interface{})
- func Warningln(ctx context.Context, args ...interface{})
- func WithoutRemoteSend(ctx context.Context) context.Context
- type Log
- func (*Log) Descriptor() ([]byte, []int)deprecated
- func (x *Log) GetCaller() string
- func (x *Log) GetLevel() string
- func (x *Log) GetLogHeader() string
- func (x *Log) GetMsg() string
- func (*Log) ProtoMessage()
- func (x *Log) ProtoReflect() protoreflect.Message
- func (x *Log) Reset()
- func (x *Log) String() string
- type LogMsg
- func (*LogMsg) Descriptor() ([]byte, []int)deprecated
- func (x *LogMsg) GetCaller() string
- func (x *LogMsg) GetLevel() string
- func (x *LogMsg) GetLogHeader() string
- func (x *LogMsg) GetMsg() string
- func (*LogMsg) ProtoMessage()
- func (x *LogMsg) ProtoReflect() protoreflect.Message
- func (x *LogMsg) Reset()
- func (x *LogMsg) String() string
- type Option
Constants ¶
This section is empty.
Variables ¶
var File_log_proto protoreflect.FileDescriptor
var File_logstreamer_proto protoreflect.FileDescriptor
Functions ¶
func AddStreamToForward ¶
func AddStreamToForward(stream grpc.ServerStream) (disconnect func())
AddStreamToForward adds stream identified to forward all logs to it.
func Debug ¶
Debug logs at the DEBUG level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Print; a newline is appended to local log if missing.
func Debugf ¶
Debugf logs at the DEBUG level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Printf; a newline is appended to local log if missing.
func Debugln ¶
Debugln logs at the DEBUG level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Println; a newline is appended to local log if missing.
func Error ¶
Error logs at the ERROR level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Print; a newline is appended to local log if missing.
func Errorf ¶
Errorf logs at the ERROR level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Printf; a newline is appended to local log if missing.
func Errorln ¶
Errorln logs at the ERROR level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Println; a newline is appended to local log if missing.
func Info ¶
Info logs at the INFO level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Print; a newline is appended to local log if missing.
func Infof ¶
Infof logs at the INFO level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Printf; a newline is appended to local log if missing.
func Infoln ¶
Infoln logs at the INFO level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Println; a newline is appended to local log if missing.
func RemoveAllStreams ¶
func RemoveAllStreams()
RemoveAllStreams flushes all streams from the existing forwarders.
func SetReportCaller ¶
func SetReportCaller(reportCaller bool)
SetReportCaller set if we want to report caller to standard logger.
func StreamClientInterceptor ¶
func StreamClientInterceptor(logger *logrus.Logger, args ...Option) grpc.StreamClientInterceptor
StreamClientInterceptor allows to tag the client with an unique ID and request the server to stream back to the client logs corresponding to that request to the given logger. It will use ReportCaller value from logger to decide if we print the callstack (first frame outside of that package).
func StreamServerInterceptor ¶
func StreamServerInterceptor(localLogger *logrus.Logger) func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
StreamServerInterceptor wraps the server stream to create a new dedicated logger to stream back the logs. It will use serverLogger to log locally the same messages, prefixing by the request ID. It will use ReportCaller value from localLogger to decide if we print the callstack (first frame outside of that package).
func Warning ¶
Warning logs at the WARNING level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Print; a newline is appended to local log if missing.
func Warningf ¶
Warningf logs at the WARNING level. If the context contains a stream, it will stream there and use associated local logger. Arguments are handled in the manner of fmt.Printf; a newline is appended to local log if missing.
Types ¶
type Log ¶
type Log struct { // use logHeader instead of header as the result will be polymorphic and we want // to give the more chances to not decode by error. // this will contain an unique identifier string. LogHeader string `protobuf:"bytes,1,opt,name=logHeader,proto3" json:"logHeader,omitempty"` Level string `protobuf:"bytes,2,opt,name=level,proto3" json:"level,omitempty"` Caller string `protobuf:"bytes,3,opt,name=caller,proto3" json:"caller,omitempty"` Msg string `protobuf:"bytes,4,opt,name=msg,proto3" json:"msg,omitempty"` // contains filtered or unexported fields }
func (*Log) Descriptor
deprecated
func (*Log) GetLogHeader ¶
func (*Log) ProtoMessage ¶
func (*Log) ProtoMessage()
func (*Log) ProtoReflect ¶
func (x *Log) ProtoReflect() protoreflect.Message
type LogMsg ¶
type LogMsg struct { // use logHeader instead of header as the result will be polymorphic and we want // to give the more chances to not decode by error. // this will contain an unique identifier string. LogHeader string `protobuf:"bytes,1,opt,name=logHeader,proto3" json:"logHeader,omitempty"` Level string `protobuf:"bytes,2,opt,name=level,proto3" json:"level,omitempty"` Caller string `protobuf:"bytes,3,opt,name=caller,proto3" json:"caller,omitempty"` Msg string `protobuf:"bytes,4,opt,name=msg,proto3" json:"msg,omitempty"` // contains filtered or unexported fields }
func (*LogMsg) Descriptor
deprecated
func (*LogMsg) GetLogHeader ¶
func (*LogMsg) ProtoMessage ¶
func (*LogMsg) ProtoMessage()
func (*LogMsg) ProtoReflect ¶
func (x *LogMsg) ProtoReflect() protoreflect.Message