virtual-kubelet: Index | Files | Directories

package log

import ""

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.


Package Files

log.go nop.go

func WithLogger Uses

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.

type Fields Uses

type Fields map[string]interface{}

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

type Logger Uses

type Logger interface {
    Debugf(string, ...interface{})
    Infof(string, ...interface{})
    Warnf(string, ...interface{})
    Errorf(string, ...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 uninitialized and no logger is available in a provided context, a
    // panic will occur.
    L   Logger = nopLogger{}

func GetLogger Uses

func GetLogger(ctx context.Context) Logger

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


logrusPackage logrus implements a using Logrus as a backend You can use this by creating a logrus logger and calling `FromLogrus(entry)`.

Package log imports 1 packages (graph) and is imported by 20 packages. Updated 2019-07-20. Refresh now. Tools for package owners.