log

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEntryToCTX

func AddEntryToCTX(ctx context.Context, entry *logrus.Entry) context.Context

AddEntryToCTX adds entry to ctx

func AddFieldsToCTX

func AddFieldsToCTX(ctx context.Context, fields logrus.Fields) context.Context

AddFieldsToCTX adds fields to ctx

func AddSLOGAttrToCTX added in v0.0.9

func AddSLOGAttrToCTX(ctx context.Context, attrs []slog.Attr) context.Context

AddSLOGAttrToCTX adds slog attr to ctx

func ClientLoggerUnaryInterceptor added in v0.0.9

func ClientLoggerUnaryInterceptor(from, to string) grpc.UnaryClientInterceptor

ClientLoggerUnaryInterceptor returns a new unary client interceptor for log from what to

func Debug

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

func Debugf

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

func Error

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

func Errorf

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

func Fatal

func Fatal(ctx context.Context, v ...interface{})

func Fatalf

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

func GetEntryFromCTX

func GetEntryFromCTX(ctx context.Context) (*logrus.Entry, bool)

func GetFieldsFromCTX

func GetFieldsFromCTX(ctx context.Context) logrus.Fields

func GetSLOGAttrFromCTX added in v0.0.9

func GetSLOGAttrFromCTX(ctx context.Context) []slog.Attr

GetSLOGAttrFromCTX returns slog attrs from ctx

func Info

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

func Infof

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

func InitLog

func InitLog(out io.Writer)

InitLog initializes logrus logger It uses nested-logrus-formatter It sets log level from LOGLVL env variable data format: 2006|01|02 15:04:05.000

func MustGetEntryFromCTX

func MustGetEntryFromCTX(ctx context.Context) *logrus.Entry

MustGetEntryFromCTX returns a *logrus.Entry from ctx if ctx has no *logrus.Entry, returns a new *logrus.Entry

func NewEntryFormCTXWithFields

func NewEntryFormCTXWithFields(ctx context.Context) *logrus.Entry

NewEntryFormCTXWithFields returns a *logrus.Entry with fields from ctx

func NewFromCTX

func NewFromCTX(ctx context.Context) *logrus.Entry

NewFromCTX returns a new logrus.Entry with fields from ctx

func Panic

func Panic(ctx context.Context, v ...interface{})

func Panicf

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

func ServerLoggerUnaryInterceptor

func ServerLoggerUnaryInterceptor() func(ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler) (interface{}, error)

func Trace

func Trace(ctx context.Context, v ...interface{})

func Tracef

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

func Warn

func Warn(ctx context.Context, v ...interface{})

func Warnf

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

Types

type CTXAttrHandler added in v0.0.9

type CTXAttrHandler struct {
	slog.Handler
}

func NewCTXAttrHandler added in v0.0.9

func NewCTXAttrHandler(serviceName string, mainHandler slog.Handler) CTXAttrHandler

NewCTXAttrHandler

is a slog.Handler that adds slog.Attr to slog.Record from context.Context

func (CTXAttrHandler) Handle added in v0.0.9

func (p CTXAttrHandler) Handle(ctx context.Context, record slog.Record) error

Jump to

Keyboard shortcuts

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