spy

package
v0.0.0-...-05e509a Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package spy provides an implementation of zap.Logger that helps test logging wrappers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() (*Logger, *Sink)

New returns a new spy logger at the default level and its sink.

Types

type Log

type Log struct {
	Level  zap.Level
	Msg    string
	Fields []zap.Field
}

A Log is an encoding-agnostic representation of a log message.

type Logger

type Logger struct {
	sync.Mutex
	zap.Meta
	// contains filtered or unexported fields
}

Logger satisfies zap.Logger, but makes testing convenient.

func (*Logger) Check

func (l *Logger) Check(lvl zap.Level, msg string) *zap.CheckedMessage

Check returns a CheckedMessage if logging a particular message would succeed.

func (*Logger) DFatal

func (l *Logger) DFatal(msg string, fields ...zap.Field)

DFatal logs at the Fatal level if the development flag is set, and the Fatal level otherwise.

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...zap.Field)

Debug logs at the Debug level.

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...zap.Field)

Error logs at the Error level.

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...zap.Field)

Fatal logs at the Fatal level. Note that the spy logger doesn't actuall call os.Exit.

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...zap.Field)

Info logs at the Info level.

func (*Logger) Log

func (l *Logger) Log(lvl zap.Level, msg string, fields ...zap.Field)

Log writes a message at the specified level.

func (*Logger) Panic

func (l *Logger) Panic(msg string, fields ...zap.Field)

Panic logs at the Panic level. Note that the spy Logger doesn't actually panic.

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...zap.Field)

Warn logs at the Warn level.

func (*Logger) With

func (l *Logger) With(fields ...zap.Field) zap.Logger

With creates a new Logger with additional fields added to the logging context.

type Sink

type Sink struct {
	sync.Mutex
	// contains filtered or unexported fields
}

A Sink stores Log structs.

func (*Sink) Logs

func (s *Sink) Logs() []Log

Logs returns a copy of the sink's accumulated logs.

func (*Sink) WriteLog

func (s *Sink) WriteLog(lvl zap.Level, msg string, fields []zap.Field)

WriteLog writes a log message to the LogSink.

Jump to

Keyboard shortcuts

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