log

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(ctx context.Context, msg string, keyvals ...interface{})

Error extracts the logger from the given context and calls Error on it.

func Info

func Info(ctx context.Context, msg string, keyvals ...interface{})

Info extracts the logger from the given context and calls Info on it.

func WithFn

func WithFn(ctx context.Context, keyvals ...interface{}) context.Context

WithFn adds the current function name as "func" field and optional fields.

func WithLogger

func WithLogger(ctx context.Context, logger Adapter) context.Context

WithLogger sets the request context logger and returns the resulting new context.

func WithValues

func WithValues(ctx context.Context, keyvals ...interface{}) context.Context

WithValues instantiates a new logger by appending the given key/value pairs to the context logger and setting the resulting logger in the context.

Types

type Adapter

type Adapter interface {
	// Info logs an informational message.
	Info(msg string, keyvals ...interface{})
	// Error logs an error.
	Error(msg string, keyvals ...interface{})
	// New appends to the logger context and returns the updated logger logger.
	New(keyvals ...interface{}) Adapter
}

func DefaultLogger

func DefaultLogger() Adapter

DefaultLogger can be used if no fallback can be used.

func ErrorToInfo

func ErrorToInfo(a Adapter, prefix string) Adapter

ErrorToInfo will redirect error messages to info.

func Intercept

func Intercept(a Adapter, info, err func(msg string, keyvals ...interface{})) Adapter

Intercept can be used to intercept messages.

func Logger

func Logger(ctx context.Context) Adapter

Logger extracts the logger from the given context.

func NullInfo

func NullInfo(a Adapter) Adapter

NullInfo can be used to kill INFO messages.

func NullLogger

func NullLogger() Adapter

NullLogger can be used to kill logging.

Directories

Path Synopsis
Package testlogger provides a logging adapter for tests and benchmarks.
Package testlogger provides a logging adapter for tests and benchmarks.

Jump to

Keyboard shortcuts

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