logruslogger

package module
v1.2.115 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package logruslogger defines logrus-based logging for grpc. Importing this package will install logrus as the logger used by grpclog. Attention, Info -> Debug to mute verbose messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyLoggerOption

type EmptyLoggerOption struct{}

EmptyLoggerOption does not alter the configuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type Logger

type Logger struct {
	Entry *logrus.Entry

	LevelTranslator func(level logrus.Level) logrus.Level
	// contains filtered or unexported fields
}

Logger adapts logrus's Logger to be compatible with grpclog.LoggerV2, the experimental grpclog.DepthLoggerV2 and the deprecated grpclog.Logger.

func NewLogger

func NewLogger(logger *logrus.Entry, opts ...LoggerOption) *Logger

func (*Logger) ApplyOptions

func (o *Logger) ApplyOptions(options ...LoggerOption) *Logger

ApplyOptions call apply() for all options one by one

func (*Logger) Error

func (g *Logger) Error(args ...interface{})

Error implements grpclog.Entry.LoggerV2's Error.

func (*Logger) ErrorDepth

func (g *Logger) ErrorDepth(depth int, args ...interface{})

ErrorDepth acts as Warn but uses depth to determine which call frame to log. ErrorDepth(0, "msg") is the same as Error("msg").

func (*Logger) Errorf

func (g *Logger) Errorf(format string, args ...interface{})

Errorf implements grpclog.Entry.LoggerV2's Errorf.

func (*Logger) Errorln

func (g *Logger) Errorln(args ...interface{})

Errorln implements grpclog.Entry.LoggerV2's Errorln.

func (*Logger) Fatal

func (g *Logger) Fatal(args ...interface{})

Fatal implements grpclog.Entry.LoggerV2's Fatal.

func (*Logger) FatalDepth

func (g *Logger) FatalDepth(depth int, args ...interface{})

FatalDepth acts as Warn but uses depth to determine which call frame to log. FatalDepth(0, "msg") is the same as Fatal("msg").

func (*Logger) Fatalf

func (g *Logger) Fatalf(format string, args ...interface{})

Fatalf implements grpclog.Entry.LoggerV2's Fatalf.

func (*Logger) Fatalln

func (g *Logger) Fatalln(args ...interface{})

Fatalln implements grpclog.Entry.LoggerV2's Fatalln.

func (*Logger) Info

func (g *Logger) Info(args ...interface{})

Info implements grpclog.Entry.LoggerV2's Info.

func (*Logger) InfoDepth

func (g *Logger) InfoDepth(depth int, args ...interface{})

InfoDepth implements grpclog.Entry.LoggerV2's DebugDepth. InfoDepth acts as Info but uses depth to determine which call frame to log. InfoDepth(0, "msg") is the same as Info("msg").

func (*Logger) Infof

func (g *Logger) Infof(format string, args ...interface{})

Infof implements grpclog.Entry.LoggerV2's Infof.

func (*Logger) Infoln

func (g *Logger) Infoln(args ...interface{})

Infoln implements grpclog.Entry.LoggerV2's Infoln.

func (*Logger) Log

func (g *Logger) Log(level logrus.Level, args ...interface{})

Log implements grpclog.Entry.LoggerV2's Log.

func (*Logger) LogDepth

func (g *Logger) LogDepth(level logrus.Level, depth int, args ...interface{})

LogDepth acts as Warn but uses depth to determine which call frame to log. LogDepth(0, "msg") is the same as Log("msg").

func (*Logger) Logf

func (g *Logger) Logf(level logrus.Level, format string, args ...interface{})

Logf implements grpclog.Entry.LoggerV2's Logf.

func (*Logger) Logln

func (g *Logger) Logln(level logrus.Level, args ...interface{})

Logln implements grpclog.Entry.LoggerV2's Logln.

func (*Logger) V

func (g *Logger) V(l int) bool

V implements grpclog.Entry.LoggerV2.

func (*Logger) Warning

func (g *Logger) Warning(args ...interface{})

Warning implements grpclog.Entry.LoggerV2's Warn.

func (*Logger) WarningDepth

func (g *Logger) WarningDepth(depth int, args ...interface{})

WarningDepth acts as Warn but uses depth to determine which call frame to log. WarningDepth(0, "msg") is the same as Warn("msg").

func (*Logger) Warningf

func (g *Logger) Warningf(format string, args ...interface{})

Warningf implements grpclog.Entry.LoggerV2's Warnf.

func (*Logger) Warningln

func (g *Logger) Warningln(args ...interface{})

Warningln implements grpclog.Entry.LoggerV2's Warnln.

type LoggerOption

type LoggerOption interface {
	// contains filtered or unexported methods
}

A LoggerOption sets options.

func WithLogger added in v1.2.86

func WithLogger(v Logger) LoggerOption

WithLogger sets Logger.

func WithLoggerEntry added in v1.2.86

func WithLoggerEntry(v *logrus.Entry) LoggerOption

WithLoggerEntry sets Entry in Logger.

func WithLoggerLevelTranslator added in v1.2.86

func WithLoggerLevelTranslator(v func(level logrus.Level) logrus.Level) LoggerOption

WithLoggerLevelTranslator sets LevelTranslator in Logger.

func WithLoggerVerbose

func WithLoggerVerbose(v int) LoggerOption

WithLoggerVerbose sets verbose in Logger.

type LoggerOptionFunc

type LoggerOptionFunc func(*Logger)

LoggerOptionFunc wraps a function that modifies Logger into an implementation of the LoggerOption interface.

Jump to

Keyboard shortcuts

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