logger

package
v0.0.0-...-267db73 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package logger defines interfaces that logger drivers implement to log messages.

Index

Constants

This section is empty.

Variables

View Source
var Default = Discard()

Default returns the default logger.

Functions

func WithContext

func WithContext(ctx context.Context, logger Logger) context.Context

WithContext returns a new context with the provided logger. Use in combination with logger.WithField for great effect.

Types

type Dumper

type Dumper interface {
	DumpRequest(*http.Request)
	DumpResponse(*http.Response)
}

Dumper dumps the http.Request and http.Response message payload for debugging purposes.

func DiscardDumper

func DiscardDumper() Dumper

DiscardDumper returns a no-op dumper.

func StandardDumper

func StandardDumper(body bool) Dumper

StandardDumper returns a standard dumper.

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Debugln(args ...interface{})

	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Errorln(args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Infoln(args ...interface{})

	Trace(args ...interface{})
	Tracef(format string, args ...interface{})
	Traceln(args ...interface{})

	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Warnln(args ...interface{})

	WithError(error) Logger
	WithField(string, interface{}) Logger
}

A Logger represents an active logging object that generates lines of output to an io.Writer.

func Discard

func Discard() Logger

Discard returns a no-op logger

func FromContext

func FromContext(ctx context.Context) Logger

FromContext retrieves the current logger from the context.

func FromRequest

func FromRequest(r *http.Request) Logger

FromRequest retrieves the current logger from the request. If no logger is available, the default logger is returned.

func Logrus

func Logrus(entry *logrus.Entry) Logger

Logrus returns a Logger that wraps a logrus.Entry.

Jump to

Keyboard shortcuts

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