log

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package log defines the interfaces used for logging in virtual-kubelet. It uses a context.Context to store logger details. Additionally you can set the default logger to use by setting log.L. This is used when no logger is stored in the passed in context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLogger

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

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

Types

type Fields added in v0.9.0

type Fields map[string]interface{}

Fields allows setting multiple fields on a logger at one time.

type Logger added in v0.9.0

type Logger interface {
	Debug(...interface{})
	Debugf(string, ...interface{})
	Info(...interface{})
	Infof(string, ...interface{})
	Warn(...interface{})
	Warnf(string, ...interface{})
	Error(...interface{})
	Errorf(string, ...interface{})
	Fatal(...interface{})
	Fatalf(string, ...interface{})

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

Logger is the interface used for logging in virtual-kubelet

virtual-kubelet will access the logger via context using `GetLogger` (or its alias, `G`) You can set the default logger to use by setting the `L` variable.

var (
	// G is an alias for GetLogger.
	G = GetLogger

	// L is the default logger. It should be initialized before using `G` or `GetLogger`
	// If L is unitialized and no logger is available in a provided context, a
	// panic will occur.
	L Logger = nopLogger{}
)

func GetLogger

func GetLogger(ctx context.Context) Logger

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

Directories

Path Synopsis
Package logrus implements a github.com/virtual-kubelet/virtual-kubelet/log.Logger using Logrus as a backend You can use this by creating a logrus logger and calling `FromLogrus(entry)`.
Package logrus implements a github.com/virtual-kubelet/virtual-kubelet/log.Logger using Logrus as a backend You can use this by creating a logrus logger and calling `FromLogrus(entry)`.

Jump to

Keyboard shortcuts

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