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 ¶
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 (*LogSpy) AssertErrorLogged ¶
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 ¶
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 ¶
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.