observer

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(enab zapcore.LevelEnabler, sink func(LoggedEntry) error, withContext bool) zapcore.Core

New creates a new Core that buffers logs in memory (without any encoding). It's particularly useful in tests.

Types

type LoggedEntry

type LoggedEntry struct {
	zapcore.Entry
	Context []zapcore.Field
}

An LoggedEntry is an encoding-agnostic representation of a log message. Field availability is context dependant.

type ObservedLogs

type ObservedLogs struct {
	// contains filtered or unexported fields
}

ObservedLogs is a concurrency-safe, ordered collection of observed logs.

func (*ObservedLogs) Add

func (o *ObservedLogs) Add(log LoggedEntry) error

Add appends a new observed log to the collection. It always returns nil error, but does so that it can be used as an observer sink function.

func (*ObservedLogs) All

func (o *ObservedLogs) All() []LoggedEntry

All returns a copy of all the observed logs.

func (*ObservedLogs) AllUntimed

func (o *ObservedLogs) AllUntimed() []LoggedEntry

AllUntimed returns a copy of all the observed logs, but overwrites the observed timestamps with time.Time's zero value. This is useful when making assertions in tests.

func (*ObservedLogs) Len

func (o *ObservedLogs) Len() int

Len returns the number of items in the collection.

func (*ObservedLogs) TakeAll

func (o *ObservedLogs) TakeAll() []LoggedEntry

TakeAll returns a copy of all the observed logs, and truncates the observed slice.

Jump to

Keyboard shortcuts

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