logging

package
v0.0.0-...-8d9275d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRecentEscalatedLogs

func GetRecentEscalatedLogs(c context.Context) []zapcore.Entry

GetRecentEscalatedLogs returns a list of recent buffered warn and error logs.

func GetRecentLogs

func GetRecentLogs(c context.Context) []zapcore.Entry

GetRecentLogs returns a list of recent buffered logs.

func L

func L(c context.Context) (l *zap.Logger)

L returns the logger embedded in rhe Context by WithLogger.

If there is no logger, L will panic.

func LogError

func LogError(c context.Context, err error)

LogError outputs the contents of the error, err, to the logger.

func S

S is shorthand for L(c).Sugar().

Like L, if there is no logger, S will panic.

func UseLogger

func UseLogger(c context.Context, l *zap.Logger) context.Context

UseLogger installs the provided Logger into the Context.

func WithLogger

func WithLogger(c context.Context, cfg *zap.Config, fn func(context.Context) error) (err error)

WithLogger runs the specified function with a logger embedded in the Context.

Types

type MemoryLogger

type MemoryLogger struct {
	// Size is the number of log entries to retain.
	Size int

	// Level is the minimum log level to retain.
	MinLevel zapcore.Level
	// contains filtered or unexported fields
}

MemoryLogger integrates as a zap Logger hook which retains the last set of logs.

MemoryLogger's fields may not be adjusted after it has been installed as a hook.

Internally, MemoryLogger uses a ring buffer.

func (*MemoryLogger) Get

func (ml *MemoryLogger) Get() []zapcore.Entry

Get returns the active entries.

func (*MemoryLogger) Hook

func (ml *MemoryLogger) Hook(e zapcore.Entry) error

Hook is a zap logging hook that adds this log entry to the MemoryLogger.

type VerbosityFlag

type VerbosityFlag struct {
	// Level is the underlying zapcore.Level variable to write to.
	*zapcore.Level
}

VerbosityFlag is a pflag.Value wrapper around a zapcore.Level, allowing it to be used as a pflag.Value.

zapcore.Level provides flag.Value interface, so we only need to augment it.

func (*VerbosityFlag) Type

func (vf *VerbosityFlag) Type() string

Type implements cobra's "pflag.Value" interface.

Jump to

Keyboard shortcuts

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