logger

package
v0.0.0-...-4b7ff4e Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package copied from https://github.com/kyma-project/kyma/blob/1.11.0/components/service-binding-usage-controller/internal/platform/logger/spy/logger.go Only Reset() method was added.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogDummy

func NewLogDummy() *logrus.Entry

NewLogDummy returns dummy logger which discards logged messages on the fly. Useful when logger is required as dependency in unit testing.

Types

type LogSpy

type LogSpy struct {
	RawLogger *logrus.Logger
	Logger    *logrus.Entry
	// contains filtered or unexported fields
}

LogSpy is a helper construct for testing logging in unit tests. Beware: all methods are working on copies of of original messages buffer and are safe for multiple uses.

func NewLogSpy

func NewLogSpy() *LogSpy

NewLogSpy is a factory for LogSpy

func (*LogSpy) AssertErrorLogged

func (s *LogSpy) AssertErrorLogged(t *testing.T, errorExpected error)

AssertErrorLogged checks whatever a specific string was logged as error.

Compared elements: level, message

Wrapped errors are supported as long as original error message ends up in resulting one.

func (*LogSpy) AssertLogged

func (s *LogSpy) AssertLogged(t *testing.T, level logrus.Level, message string)

AssertLogged checks whatever a specific string was logged at a specific level.

Compared elements: level, message

Beware: we are checking for sub-strings and not for the exact match.

func (*LogSpy) AssertNotLogged

func (s *LogSpy) AssertNotLogged(t *testing.T, level logrus.Level, message string)

AssertNotLogged checks whatever a specific string was not logged at a specific level.

Compared elements: level, message

Beware: we are checking for sub-strings and not for the exact match.

func (*LogSpy) DumpAll

func (s *LogSpy) DumpAll() []string

DumpAll returns all logged messages.

func (*LogSpy) Reset

func (s *LogSpy) Reset()

Reset removes logged messages.

Jump to

Keyboard shortcuts

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