logger

package
v0.0.0-...-50a15a0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SystemField = "system"
	KindField   = "span.kind"
)
View Source
var (
	DefaultDurationToField = DurationToTimeMillisField
	TimestampFormat        = utils.TimeFormat
)

Functions

func Debug

func Debug(message string, params ...interface{})

func DebugWithContext

func DebugWithContext(ctx context.Context, message string, params ...interface{})

func DefaultMessageProducer

func DefaultMessageProducer(ctx context.Context, format string, level Level, code codes.Code, err error, fields map[string]interface{})

func DurationToTimeMillisField

func DurationToTimeMillisField(duration time.Duration) (key string, value interface{})

func Error

func Error(err error, message string, params ...interface{})

func ErrorWithContext

func ErrorWithContext(ctx context.Context, err error, message string, params ...interface{})

func Fatal

func Fatal(err error, message string, params ...interface{})

func FatalWithContext

func FatalWithContext(ctx context.Context, err error, message string, params ...interface{})

func Info

func Info(message string, params ...interface{})

func InfoWithContext

func InfoWithContext(ctx context.Context, message string, params ...interface{})

func Panic

func Panic(err error, message string, params ...interface{})

func PanicWithContext

func PanicWithContext(ctx context.Context, err error, message string, params ...interface{})

func SetLevel

func SetLevel(level Level)

func StreamServerInterceptor

func StreamServerInterceptor(log Logger) grpc.StreamServerInterceptor

StreamServerInterceptor returns a new streaming server interceptor that adds logrus.Entry to the context.

func ToContext

func ToContext(ctx context.Context, log Logger) context.Context

func Trace

func Trace(message string, params ...interface{})

func TraceWithContext

func TraceWithContext(ctx context.Context, message string, params ...interface{})

func UnaryServerInterceptor

func UnaryServerInterceptor(log Logger) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.

func Warning

func Warning(message string, params ...interface{})

func WarningWithContext

func WarningWithContext(ctx context.Context, message string, params ...interface{})

Types

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

func (*Hook) Fire

func (hook *Hook) Fire(entry *logrus.Entry) error

func (*Hook) Levels

func (hook *Hook) Levels() []logrus.Level

type Level

type Level uint32
const (
	// PanicLevel level, highest level of severity. Logs and then calls panic with the
	// message passed to Debug, Info, ...
	PanicLevel Level = iota
	// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
	// TraceLevel level. Designates finer-grained informational events than the Debug.
	TraceLevel
)

func DefaultCodeToLevel

func DefaultCodeToLevel(code codes.Code) Level

DefaultCodeToLevel is the default implementation of gRPC return codes to log levels for server side.

func GetLevel

func GetLevel() Level

type Logger

type Logger interface {
	SetLevel(level Level)
	GetLevel() Level
	AddParam(key string, value interface{}) Logger
	SetSkipCaller(skip int) Logger

	Trace(message string, params ...interface{})
	Debug(message string, params ...interface{})
	Info(message string, params ...interface{})
	Warning(message string, params ...interface{})
	Error(err error, message string, params ...interface{})
	Fatal(err error, message string, params ...interface{})
	Panic(err error, message string, params ...interface{})

	TraceWithContext(ctx context.Context, message string, params ...interface{})
	DebugWithContext(ctx context.Context, message string, params ...interface{})
	InfoWithContext(ctx context.Context, message string, params ...interface{})
	WarningWithContext(ctx context.Context, message string, params ...interface{})
	ErrorWithContext(ctx context.Context, err error, message string, params ...interface{})
	FatalWithContext(ctx context.Context, err error, message string, params ...interface{})
	PanicWithContext(ctx context.Context, err error, message string, params ...interface{})
	WithSubModule(module string) Logger
	io.Writer
}

func Extract

func Extract(ctx context.Context) Logger

func FromContext

func FromContext(ctx context.Context) Logger

func GetLog

func GetLog() Logger

func New

func New(module string, opts ...Option) Logger

type Option

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

func WithExitFunc

func WithExitFunc(exitFunc func(int)) Option

func WithHookLevels

func WithHookLevels(levels []Level) Option

func WithLevel

func WithLevel(lvl Level) Option

func WithReportCallerOption

func WithReportCallerOption(reportCaller *ReportCaller) Option

type ReportCaller

type ReportCaller struct {
	File       bool
	FileFormat ReportFormat
	Func       bool
	FuncFormat ReportFormat
}

type ReportFormat

type ReportFormat func(string) string

Jump to

Keyboard shortcuts

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