testlogger

package
v0.113.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogMessage

type LogMessage struct {
	Message    string                 `json:"message"`
	Level      zerolog.Level          `json:"level"`
	Service    string                 `json:"service"`
	Error      *string                `json:"error"`
	Attributes map[string]interface{} `json:"-"`
}

type TestLogger

type TestLogger struct {
	*logger.Logger
	// contains filtered or unexported fields
}

func New

func New() *TestLogger

New returns a logger with an in memory buffer containing log messages for use in tests The logger will write to stdout and the buffer, if you want to hide the log output use HideLogOutput

func (*TestLogger) GetErrorMessages

func (l *TestLogger) GetErrorMessages() ([]LogMessage, error)

GetErrorMessages returns all log messages with error, fatal and panic level If you only want a single of those levels, use GetMessagesForLevel instead

func (*TestLogger) GetLogMessages

func (l *TestLogger) GetLogMessages() ([]LogMessage, error)

func (*TestLogger) GetMessagesForLevel

func (l *TestLogger) GetMessagesForLevel(level logger.Level) ([]LogMessage, error)

func (*TestLogger) HideLogOutput added in v0.65.0

func (l *TestLogger) HideLogOutput() *TestLogger

HideLogOutput hides the log output from stdout and only logs to the in-memory buffer

Jump to

Keyboard shortcuts

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