log

package
v0.0.0-...-76354a4 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// The name of the logger. Shows up in the output.
	Name string

	// The logger to use. Allows setting output and format.
	Logger klog.Logger

	// Show call information in log output (can affect performance)
	Caller bool

	// The call stack depth. Useful for setting different depths for apps versus testing.
	CallDepth int

	// Excludes allows excluding logger contexts by name.
	Excludes []string
}

Config allows sharing a log config accross loggers.

func NewConfig

func NewConfig(name string, logr klog.Logger, caller bool, callDepth int) *Config

NewConfig returns a new logger config with the arguments set.

type Logger

type Logger struct {
	Caller    bool // Include the caller field name in the log output.
	CallDepth int  // Call stack depth for logging
	// contains filtered or unexported fields
}

Logger implements the go-kit logger type.

func NewLogger

func NewLogger(conf Config) Logger

NewLogger wraps a logger with a name context and caller information. If a named context is specified in the excludes slice, then any logging to that context will be ignored.

func WithCallDepth

func WithCallDepth(l Logger, callDepth int) Logger

func (Logger) Dump

func (l Logger) Dump(v interface{})

Dump pretty prints the v interface into the msg field

The output is a string containing escaped newlines. It is possoble to show the structured output in one line using:

echo -e $(go test -v ./pkg/parser -test.run=".*<test_id>*_Parse.*" -debug -exclude=lexer | grep "msg=dump" | sed -n "s/.*obj=\"\(.*\)\"/\1/p")

func (Logger) DumpExit

func (l Logger) DumpExit(v interface{})

DumpExit pretty prints the v interface to msg field and terminates program execution.

The output is a string containing escaped newlines. It is possoble to show the structured output in one line using:

echo -e $(go test -v ./pkg/parser -test.run=".*<test_id>*_Parse.*" -debug -exclude=lexer | grep "msg=dump" | sed -n "s/.*obj=\"\(.*\)\"/\1/p")

func (Logger) Err

func (l Logger) Err(err error) error

Err logs an error to the log context.

func (Logger) Log

func (l Logger) Log(keyvals ...interface{}) error

Log satisfies the logger interface.

func (Logger) Msg

func (l Logger) Msg(message string) error

Msg logs a message to the log context.

func (Logger) Msgr

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

Msgr logs a message with additional fields.

func (Logger) SetLogger

func (l Logger) SetLogger(logr klog.Logger)

SetLogger set the wrapped Logger standard logger

func (Logger) StdLogger

func (l Logger) StdLogger() klog.Logger

StdLogger gets the Logger originally used in creation of the wrapped logger.

type LoggerExcludes

type LoggerExcludes []string // Exclude a log context from being shown in the output

LoggerExcludes satisfies the flag Value interface

func (*LoggerExcludes) Set

func (e *LoggerExcludes) Set(value string) error

Set appends value

func (*LoggerExcludes) String

func (e *LoggerExcludes) String() string

String returns LoggerExcludes as a formatted string

Jump to

Keyboard shortcuts

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