log

package
v1.0.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2017 License: Apache-2.0, CC-BY-SA-4.0 Imports: 6 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 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 an 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