testlog

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hook

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

Hook is a hook designed for dealing with logs in test scenarios.

func NewNullLogger

func NewNullLogger() (*logrus.Logger, *Hook)

NewNullLogger Creates a discarding logger and installs the test hook.

func (*Hook) CheckAllContained

func (t *Hook) CheckAllContained(tb testing.TB, strs ...string)

CheckAllContained looks through all the passed strings and verifies that all of them have been logged.

func (*Hook) CheckContained

func (t *Hook) CheckContained(tb testing.TB, strs ...string)

CheckContained looks through all the passed strings and verifies that at least one of those have been logged.

func (*Hook) CheckNotContained

func (t *Hook) CheckNotContained(tb testing.TB, strs ...string)

CheckNotContained looks through all the passed strings and verifies that none of those fragments have been logged.

func (*Hook) Entries

func (t *Hook) Entries() []*logrus.Entry

Entries is a thread safe accessor for all entries.

func (*Hook) Fire

func (t *Hook) Fire(e *logrus.Entry) error

Fire complies to the Hook interface.

func (*Hook) LastEntry

func (t *Hook) LastEntry() (l *logrus.Entry)

LastEntry returns the last entry that was logged or nil.

func (*Hook) Levels

func (t *Hook) Levels() []logrus.Level

Levels complies to the Hook interface.

func (*Hook) Reset

func (t *Hook) Reset()

Reset removes all Entries from this test hook.

func (*Hook) String

func (t *Hook) String() string

String returns the string representation of all the entries cumulatively logged in this Hook. If isolation is needed, prefer to make a new hook per test case.

Jump to

Keyboard shortcuts

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