namespaced

package
v0.0.0-...-aa2a11b Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NamespaceKey = "namespace"

Functions

func WithNamespace

func WithNamespace(namespace string, ctx log.Interface) log.Interface

WithNamespace adds a namespace to the logging context

Types

type Namespaced

type Namespaced struct {
	sync.RWMutex
	log.Interface
	// contains filtered or unexported fields
}

Namespaced is a logger that only logs an entry when the namespace of that entry is enabled

func Wrap

func Wrap(ctx log.Interface, namespaces ...string) *Namespaced

Wrap wraps the logger in a Namespaced logger and enables the specified namespaces. See SetNamespaces for information on how to set the namspaces

func (*Namespaced) Debug

func (n *Namespaced) Debug(msg string)

func (*Namespaced) Debugf

func (n *Namespaced) Debugf(msg string, v ...interface{})

func (*Namespaced) Error

func (n *Namespaced) Error(msg string)

func (*Namespaced) Errorf

func (n *Namespaced) Errorf(msg string, v ...interface{})

func (*Namespaced) Fatal

func (n *Namespaced) Fatal(msg string)

func (*Namespaced) Fatalf

func (n *Namespaced) Fatalf(msg string, v ...interface{})

func (*Namespaced) Info

func (n *Namespaced) Info(msg string)

func (*Namespaced) Infof

func (n *Namespaced) Infof(msg string, v ...interface{})

func (*Namespaced) SetNamespaces

func (n *Namespaced) SetNamespaces(namespaces ...string)

SetNamespaces replaces the set of enabled namespaces The namespaces follow this format: "*" enables all namespaces "a" enables namespace a "-a" disables namespace a (even if "a" or "*" is set) For example:

  • SetNamespaces("*", "-foo") enables every namespace but foo
  • SetNamespaces("foo") enables only foo
  • SetNamespaces() disables all namespaced entries

Note that entries without a namespace will always be logged.

func (*Namespaced) Warn

func (n *Namespaced) Warn(msg string)

func (*Namespaced) Warnf

func (n *Namespaced) Warnf(msg string, v ...interface{})

func (*Namespaced) WithError

func (n *Namespaced) WithError(err error) log.Interface

func (*Namespaced) WithField

func (n *Namespaced) WithField(k string, v interface{}) log.Interface

WithField adds a field to the logger

func (*Namespaced) WithFields

func (n *Namespaced) WithFields(fields log.Fields) log.Interface

WithFields adds multiple fields to the logger

Jump to

Keyboard shortcuts

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