logging

package
v0.0.0-...-98cd694 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Unlicense Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LoggerNameKey is a key we can use to denote logger names across implementations.
	LoggerNameKey = "_name_"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level *level

Level is a simple string alias for dependency injection's sake.

var (
	// InfoLevel describes a info-level log.
	InfoLevel Level = new(level)
	// DebugLevel describes a debug-level log.
	DebugLevel Level = new(level)
	// ErrorLevel describes a error-level log.
	ErrorLevel Level = new(level)
	// WarnLevel describes a warn-level log.
	WarnLevel Level = new(level)
)

type Logger

type Logger interface {
	Info(string)
	Debug(string)
	Error(err error, whatWasHappeningWhenErrorOccurred string)

	SetRequestIDFunc(RequestIDFunc)

	Clone() Logger
	WithName(string) Logger
	WithValues(map[string]any) Logger
	WithValue(string, any) Logger
	WithRequest(*http.Request) Logger
	WithResponse(response *http.Response) Logger
	WithError(error) Logger
	WithSpan(span trace.Span) Logger
}

Logger represents a simple logging interface we can build wrappers around. NOTICE: someone, naive and green, may be enticed to add a method to this interface akin to: WithQueryFilter(*types.QueryFilter) Logger This is a fool's errand, it would introduce a disallowed import cycle.

func EnsureLogger

func EnsureLogger(logger Logger) Logger

EnsureLogger guarantees that a Logger is available.

func NewNoopLogger

func NewNoopLogger() Logger

NewNoopLogger provides our noop Logger to dependency managers.

type RequestIDFunc

type RequestIDFunc func(*http.Request) string

RequestIDFunc fetches a string ID from a request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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