log

package
v0.0.0-...-06fe44a Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: GPL-3.0 Imports: 19 Imported by: 2

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

Constants

This section is empty.

Variables

View Source
var File_logstreamer_proto protoreflect.FileDescriptor

Functions

func AddHook

func AddHook(ctx context.Context, hook logrus.Hook)

AddHook adds a hook to the logger.

func AddStreamToForward

func AddStreamToForward(stream grpc.ServerStream) (disconnect func())

AddStreamToForward adds stream identified to forward all logs to it.

func Debug

func Debug(ctx context.Context, args ...interface{})

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

func Debugf(ctx context.Context, format string, args ...interface{})

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

func Debugln(ctx context.Context, args ...interface{})

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

func Error(ctx context.Context, args ...interface{})

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

func Errorf(ctx context.Context, format string, args ...interface{})

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

func Errorln(ctx context.Context, args ...interface{})

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

func Info(ctx context.Context, args ...interface{})

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

func Infof(ctx context.Context, format string, args ...interface{})

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

func Infoln(ctx context.Context, args ...interface{})

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

func Warning(ctx context.Context, args ...interface{})

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

func Warningf(ctx context.Context, format string, args ...interface{})

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.

func Warningln

func Warningln(ctx context.Context, args ...interface{})

Warningln 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.Println; a newline is appended to local log if missing.

func WithoutRemoteSend

func WithoutRemoteSend(ctx context.Context) context.Context

WithoutRemoteSend takes a context with a logContext and returns a new context without the remote send. It is useful when we want a log to show what client it relates to, but we don't want to send it to the client.

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) Descriptor() ([]byte, []int)

Deprecated: Use Log.ProtoReflect.Descriptor instead.

func (*Log) GetCaller

func (x *Log) GetCaller() string

func (*Log) GetLevel

func (x *Log) GetLevel() string

func (*Log) GetLogHeader

func (x *Log) GetLogHeader() string

func (*Log) GetMsg

func (x *Log) GetMsg() string

func (*Log) ProtoMessage

func (*Log) ProtoMessage()

func (*Log) ProtoReflect

func (x *Log) ProtoReflect() protoreflect.Message

func (*Log) Reset

func (x *Log) Reset()

func (*Log) String

func (x *Log) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use LogMsg.ProtoReflect.Descriptor instead.

func (*LogMsg) GetCaller

func (x *LogMsg) GetCaller() string

func (*LogMsg) GetLevel

func (x *LogMsg) GetLevel() string

func (*LogMsg) GetLogHeader

func (x *LogMsg) GetLogHeader() string

func (*LogMsg) GetMsg

func (x *LogMsg) GetMsg() string

func (*LogMsg) ProtoMessage

func (*LogMsg) ProtoMessage()

func (*LogMsg) ProtoReflect

func (x *LogMsg) ProtoReflect() protoreflect.Message

func (*LogMsg) Reset

func (x *LogMsg) Reset()

func (*LogMsg) String

func (x *LogMsg) String() string

type Option

type Option func(*opts)

Option is an optional argument for the StreamClientInterceptor.

func WithClientID

func WithClientID(clientID string) Option

WithClientID is an optional argument to override the default client ID.

Directories

Path Synopsis
Package test contains the log test generated struct for logstreamer package tests.
Package test contains the log test generated struct for logstreamer package tests.

Jump to

Keyboard shortcuts

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