logtest

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package logtest contains the testing utils for the logging subsystem of the instance manager

Index

Constants

View Source
const (
	// LogLevelError is the error log level
	LogLevelError = LogLevel("ERROR")

	// LogLevelWarning is the error log level
	LogLevelWarning = LogLevel("WARNING")

	// LogLevelDebug is the debug log level
	LogLevelDebug = LogLevel("DEBUG")

	// LogLevelTrace is the error log level
	LogLevelTrace = LogLevel("TRACE")

	// LogLevelInfo is the error log level
	LogLevelInfo = LogLevel("INFO")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LogLevel

type LogLevel string

LogLevel is the type representing a set of log levels

type LogRecord

type LogRecord struct {
	LoggerName string
	Level      LogLevel
	Message    string
	Error      error
	Attributes map[string]interface{}
}

LogRecord represents a log message

func NewRecord

func NewRecord(name string, level LogLevel, msg string, err error, keysAndValues ...interface{}) *LogRecord

NewRecord create a new log record

func (*LogRecord) WithValues

func (record *LogRecord) WithValues(keysAndValues ...interface{})

WithValues reads a set of keys and values, using them as attributes of the log record

type SpyLogger

type SpyLogger struct {
	Name       string
	Attributes map[string]interface{}

	Records   []LogRecord
	EventSink *SpyLogger
}

SpyLogger is an implementation of the Logger interface that keeps track of the passed log entries

func NewSpy

func NewSpy() *SpyLogger

NewSpy creates a new logger interface which will collect every log message sent

func (*SpyLogger) AddRecord

func (s *SpyLogger) AddRecord(record *LogRecord)

AddRecord adds a log record inside the spy

func (*SpyLogger) Debug

func (s *SpyLogger) Debug(msg string, keysAndValues ...interface{})

Debug implements the log.Logger interface

func (*SpyLogger) Enabled

func (s *SpyLogger) Enabled() bool

Enabled implements the log.Logger interface

func (*SpyLogger) Error

func (s *SpyLogger) Error(err error, msg string, keysAndValues ...interface{})

Error implements the log.Logger interface

func (SpyLogger) GetLogger

func (s SpyLogger) GetLogger() logr.Logger

GetLogger implements the log.Logger interface

func (*SpyLogger) Info

func (s *SpyLogger) Info(msg string, keysAndValues ...interface{})

Info implements the log.Logger interface

func (*SpyLogger) Trace

func (s *SpyLogger) Trace(msg string, keysAndValues ...interface{})

Trace implements the log.Logger interface

func (*SpyLogger) Warning

func (s *SpyLogger) Warning(msg string, keysAndValues ...interface{})

Warning implements the log.Logger interface

func (SpyLogger) WithCaller

func (s SpyLogger) WithCaller() log.Logger

WithCaller implements the log.Logger interface

func (SpyLogger) WithName

func (s SpyLogger) WithName(name string) log.Logger

WithName implements the log.Logger interface

func (*SpyLogger) WithValues

func (s *SpyLogger) WithValues(keysAndValues ...interface{}) log.Logger

WithValues implements the log.Logger interface

Jump to

Keyboard shortcuts

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