logging

package
v0.0.0-...-2935fa7 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Colors

func Colors(keyvals ...interface{}) term.FgBgColor

func Msg

func Msg(logger log.Logger, message string, keyvals ...interface{}) error

Record a structured log line with a message

Types

type Logger

type Logger struct {
	// Send a log message to the Info channel, formed of a sequence of key value
	// pairs. Info messages should be operationally interesting to a human who is
	// monitoring the logs. But not necessarily a human who is trying to
	// understand or debug the system. Any handled errors or warnings should be
	// sent to the Info channel (where you may wish to tag them with a suitable
	// key-value pair to categorise them as such).
	Info log.Logger
	// Send an log message to the Trace channel, formed of a sequence of key-value
	// pairs. Trace messages can be used for any state change in the system that
	// may be of interest to a machine consumer or a human who is trying to debug
	// the system or trying to understand the system in detail. If the messages
	// are very point-like and contain little structure, consider using a metric
	// instead.
	Trace  log.Logger
	Output *log.SwapLogger
}

InfoTraceLogger maintains provides two logging 'channels' that are interlaced to provide a coarse grained filter to distinguish human-consumable 'Info' messages and execution level 'Trace' messages.

func NewLogger

func NewLogger(outputLogger log.Logger) *Logger

Create an InfoTraceLogger by passing the initial outputLogger.

func NewNoopLogger

func NewNoopLogger() *Logger

func (*Logger) InfoMsg

func (l *Logger) InfoMsg(message string, keyvals ...interface{}) error

Record structured Info log line with a message

func (*Logger) Reload

func (l *Logger) Reload() error

func (*Logger) SwapOutput

func (l *Logger) SwapOutput(infoLogger log.Logger)

Hot swap the underlying outputLogger with another one to re-route messages

func (*Logger) Sync

func (l *Logger) Sync() error

Handle signals

func (*Logger) TraceMsg

func (l *Logger) TraceMsg(message string, keyvals ...interface{}) error

Record structured Trace log line with a message

func (*Logger) With

func (l *Logger) With(keyvals ...interface{}) *Logger

A logging context (see go-kit log's Context). Takes a sequence key values via With or WithPrefix and ensures future calls to log will have those contextual values appended to the call to an underlying logger. Values can be dynamic by passing an instance of the log.Valuer interface This provides an interface version of the log.Context struct to be used For implementations that wrap a log.Context. In addition it makes no assumption about the name or signature of the logging method(s). See InfoTraceLogger

func (*Logger) WithInfo

func (l *Logger) WithInfo(keyvals ...interface{}) *Logger

Establish a context on the Info channel keeping Trace the same

func (*Logger) WithPrefix

func (l *Logger) WithPrefix(keyvals ...interface{}) *Logger

func (*Logger) WithScope

func (l *Logger) WithScope(scopeName string) *Logger

Establish or extend the scope of this logger by appending scopeName to the Scope vector. Like With the logging scope is append only but can be used to provide parenthetical scopes by hanging on to the parent scope and using once the scope has been exited. The scope mechanism does is agnostic to the type of scope so can be used to identify certain segments of the call stack, a lexical scope, or any other nested scope.

func (*Logger) WithTrace

func (l *Logger) WithTrace(keyvals ...interface{}) *Logger

Establish a context on the Trace channel keeping Info the same

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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