Documentation ¶
Overview ¶
Package logtest contains the testing utils for the logging subsystem of PGK
Index ¶
- Constants
- type LogLevel
- type LogRecord
- type SpyLogger
- func (s *SpyLogger) AddRecord(record *LogRecord)
- func (s *SpyLogger) Debug(msg string, keysAndValues ...interface{})
- func (s *SpyLogger) Enabled() bool
- func (s *SpyLogger) Error(err error, msg string, keysAndValues ...interface{})
- func (s SpyLogger) GetLogger() logr.Logger
- func (s *SpyLogger) Info(msg string, keysAndValues ...interface{})
- func (s *SpyLogger) Trace(msg string, keysAndValues ...interface{})
- func (s *SpyLogger) Warning(msg string, keysAndValues ...interface{})
- func (s SpyLogger) WithCaller() log.Logger
- func (s SpyLogger) WithName(name string) log.Logger
- func (s *SpyLogger) WithValues(keysAndValues ...interface{}) log.Logger
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 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) WithCaller ¶
WithCaller implements the log.Logger interface
func (*SpyLogger) WithValues ¶
WithValues implements the log.Logger interface
Click to show internal directories.
Click to hide internal directories.