log

package
v0.0.0-...-9a44da8 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// G is an alias for GetLogger.
	//
	// We may want to define this locally to a package to get package tagged log
	// messages.
	G = GetLogger

	// L is an alias for the the standard logger.
	L = logrus.NewEntry(logrus.StandardLogger())
)

Functions

func GetLogger

func GetLogger(ctx context.Context) *logrus.Entry

GetLogger retrieves the current logger from the context. If no logger is available, the default logger is returned.

func GetModulePath

func GetModulePath(ctx context.Context) string

GetModulePath returns the module path for the provided context. If no module is set, an empty string is returned.

func WithField

func WithField(ctx context.Context, key, value string) context.Context

WithField is convenience wrapper around WithFields.

func WithFields

func WithFields(ctx context.Context, fields logrus.Fields) context.Context

WithFields returns a new context with added fields to logger.

func WithLogger

func WithLogger(ctx context.Context, logger *logrus.Entry) context.Context

WithLogger returns a new context with the provided logger. Use in combination with logger.WithField(s) for great effect.

func WithModule

func WithModule(ctx context.Context, module string) context.Context

WithModule adds the module to the context, appending it with a slash if a module already exists. A module is just a roughly correlated defined by the call tree for a given context.

As an example, we might have a "node" module already part of a context. If this function is called with "tls", the new value of module will be "node/tls".

Modules represent the call path. If the new module and last module are the same, a new module entry will not be created. If the new module and old older module are the same but separated by other modules, the cycle will be represented by the module path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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