logr

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: MIT Imports: 8 Imported by: 0

README

Logr

Logr is a simple helper for Logrus which helps wrap loggers to log Opentracing information.

Example

If you have a context that might already be in a trace, then you can simple create a new Logrus logger with your context. This a gRPC handler for example.

func (s *routeGuideServer) GetFeature(ctx context.Context, point *pb.Point) (*pb.Feature, error) {
        logr.WithCtx(ctx).Info("Called GetFeature woo!")
}
Interface

Logr follows the logr.FieldLogger interface

type FieldLogger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Printf(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})

	Debug(args ...interface{})
	Info(args ...interface{})
	Print(args ...interface{})
	Warn(args ...interface{})
	Warning(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Panic(args ...interface{})
}

Documentation

Index

Constants

View Source
const TraceKey = "traceId"

Variables

This section is empty.

Functions

func SetLevelFromEnv

func SetLevelFromEnv()

SetLevelFromEnv is a convienience function to set the log level from env vars such as those on Kubernetes or Docker hosts

Types

type FieldLogr

type FieldLogr interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Printf(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})

	Debug(args ...interface{})
	Info(args ...interface{})
	Print(args ...interface{})
	Warn(args ...interface{})
	Warning(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Panic(args ...interface{})
}

type Logr

type Logr struct {
	Logger FieldLogr
	// contains filtered or unexported fields
}

func NewWithLogger

func NewWithLogger(logger *logrus.Logger) *Logr

NewWithLogger creates a new Logr from an existing logrus logger.

func WithCtx

func WithCtx(ctx context.Context) *Logr

WithCtx will return a logrus logger that will log Zipkin when logging.

func (*Logr) Debug

func (l *Logr) Debug(args ...interface{})

func (*Logr) DebugObject

func (l *Logr) DebugObject(name string, object interface{})

func (*Logr) Debugf

func (l *Logr) Debugf(format string, args ...interface{})

func (*Logr) Error

func (l *Logr) Error(args ...interface{})

func (*Logr) Errorf

func (l *Logr) Errorf(format string, args ...interface{})

func (*Logr) Info

func (l *Logr) Info(args ...interface{})

func (*Logr) Infof

func (l *Logr) Infof(format string, args ...interface{})

func (*Logr) LogErrorToTrace

func (l *Logr) LogErrorToTrace(level, msg string)

LogErrorToTrace logs the msg to the tracing span with the level

func (*Logr) LogToTrace

func (l *Logr) LogToTrace(level, msg string)

LogToTrace logs the msg to the tracing span with the level

func (*Logr) Print

func (l *Logr) Print(args ...interface{})

func (*Logr) Printf

func (l *Logr) Printf(format string, args ...interface{})

func (*Logr) Warn

func (l *Logr) Warn(args ...interface{})

func (*Logr) Warnf

func (l *Logr) Warnf(format string, args ...interface{})

func (*Logr) Warning

func (l *Logr) Warning(args ...interface{})

func (*Logr) Warningf

func (l *Logr) Warningf(format string, args ...interface{})

func (*Logr) WithContext

func (l *Logr) WithContext(ctx context.Context) *Logr

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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