Documentation ¶
Index ¶
- func LogLineChecksum(line string) string
- func Set(logger Logger) (err error)
- type Logger
- type Mock
- func (log *Mock) AuditErr(msg string)
- func (log *Mock) AuditErrf(format string, a ...interface{})
- func (log *Mock) AuditInfo(msg string)
- func (log *Mock) AuditInfof(format string, a ...interface{})
- func (log *Mock) AuditObject(msg string, obj interface{})
- func (m *Mock) Clear()
- func (log *Mock) Debug(msg string)
- func (log *Mock) Debugf(format string, a ...interface{})
- func (log *Mock) Err(msg string)
- func (log *Mock) Errf(format string, a ...interface{})
- func (m *Mock) ExpectMatch(reString string) error
- func (m *Mock) GetAll() []string
- func (m *Mock) GetAllMatching(reString string) []string
- func (log *Mock) Info(msg string)
- func (log *Mock) InfoObject(msg string, obj interface{})
- func (log *Mock) Infof(format string, a ...interface{})
- func (log *Mock) Warning(msg string)
- func (log *Mock) Warningf(format string, a ...interface{})
- type WaitingMock
- func (log *WaitingMock) AuditErr(msg string)
- func (log *WaitingMock) AuditErrf(format string, a ...interface{})
- func (log *WaitingMock) AuditInfo(msg string)
- func (log *WaitingMock) AuditInfof(format string, a ...interface{})
- func (log *WaitingMock) AuditObject(msg string, obj interface{})
- func (log *WaitingMock) Debug(msg string)
- func (log *WaitingMock) Debugf(format string, a ...interface{})
- func (log *WaitingMock) Err(msg string)
- func (log *WaitingMock) Errf(format string, a ...interface{})
- func (log *WaitingMock) Info(msg string)
- func (log *WaitingMock) InfoObject(msg string, obj interface{})
- func (log *WaitingMock) Infof(format string, a ...interface{})
- func (m *WaitingMock) WaitForMatch(reString string, timeout time.Duration) (string, error)
- func (log *WaitingMock) Warning(msg string)
- func (log *WaitingMock) Warningf(format string, a ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogLineChecksum ¶
Types ¶
type Logger ¶
type Logger interface { Err(msg string) Errf(format string, a ...interface{}) Warning(msg string) Warningf(format string, a ...interface{}) Info(msg string) Infof(format string, a ...interface{}) InfoObject(string, interface{}) Debug(msg string) Debugf(format string, a ...interface{}) AuditInfo(msg string) AuditInfof(format string, a ...interface{}) AuditObject(string, interface{}) AuditErr(string) AuditErrf(format string, a ...interface{}) }
A Logger logs messages with explicit priority levels. It is implemented by a logging back-end as provided by New() or NewMock(). Any additions to this interface with format strings should be added to the govet configuration in .golangci.yml
func Get ¶
func Get() Logger
Get obtains the singleton Logger. If Set has not been called first, this method initializes with basic defaults. The basic defaults cannot error, and subsequent access to an already-set Logger also cannot error, so this method is error-safe.
func New ¶
New returns a new Logger that uses the given syslog.Writer as a backend and also writes to stdout/stderr. It is safe for concurrent use.
func StdoutLogger ¶
StdoutLogger returns a Logger that writes solely to stdout and stderr. It is safe for concurrent use.
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is a logger that stores all log messages in memory to be examined by a test.
func UseMock ¶
func UseMock() *Mock
UseMock sets a mock logger as the default logger, and returns it.
func (*Mock) AuditErr ¶
func (log *Mock) AuditErr(msg string)
AuditErr can format an error for auditing; it does so at ERR level.
func (*Mock) AuditErrf ¶
func (log *Mock) AuditErrf(format string, a ...interface{})
AuditErrf can format an error for auditing; it does so at ERR level.
func (*Mock) AuditInfo ¶
func (log *Mock) AuditInfo(msg string)
AuditInfo sends an INFO-severity message that is prefixed with the audit tag, for special handling at the upstream system logger.
func (*Mock) AuditInfof ¶
func (log *Mock) AuditInfof(format string, a ...interface{})
AuditInfof sends an INFO-severity message that is prefixed with the audit tag, for special handling at the upstream system logger.
func (*Mock) AuditObject ¶
func (log *Mock) AuditObject(msg string, obj interface{})
AuditObject sends an INFO-severity JSON-serialized object message that is prefixed with the audit tag, for special handling at the upstream system logger.
func (*Mock) Debugf ¶
func (log *Mock) Debugf(format string, a ...interface{})
Debugf level messages pass through normally.
func (*Mock) Err ¶
func (log *Mock) Err(msg string)
Err level messages are always marked with the audit tag, for special handling at the upstream system logger.
func (*Mock) Errf ¶
func (log *Mock) Errf(format string, a ...interface{})
Errf level messages are always marked with the audit tag, for special handling at the upstream system logger.
func (*Mock) ExpectMatch ¶
func (*Mock) GetAll ¶
GetAll returns all messages logged since instantiation or the last call to Clear().
The caller must not modify the returned slice or its elements.
func (*Mock) GetAllMatching ¶
GetAllMatching returns all messages logged since instantiation or the last Clear() whose text matches the given regexp. The regexp is accepted as a string and compiled on the fly, because convenience is more important than performance.
The caller must not modify the elements of the returned slice.
func (*Mock) InfoObject ¶
func (log *Mock) InfoObject(msg string, obj interface{})
InfoObject logs an INFO level JSON-serialized object message.
func (*Mock) Infof ¶
func (log *Mock) Infof(format string, a ...interface{})
Infof level messages pass through normally.
type WaitingMock ¶
type WaitingMock struct {
// contains filtered or unexported fields
}
WaitingMock is a logger that stores all messages in memory to be examined by a test with methods
func NewWaitingMock ¶
func NewWaitingMock() *WaitingMock
NewWaitingMock creates a mock logger implementing the writer interface. It stores all logged messages in a buffer for inspection by test functions.
func (*WaitingMock) AuditErr ¶
func (log *WaitingMock) AuditErr(msg string)
AuditErr can format an error for auditing; it does so at ERR level.
func (*WaitingMock) AuditErrf ¶
func (log *WaitingMock) AuditErrf(format string, a ...interface{})
AuditErrf can format an error for auditing; it does so at ERR level.
func (*WaitingMock) AuditInfo ¶
func (log *WaitingMock) AuditInfo(msg string)
AuditInfo sends an INFO-severity message that is prefixed with the audit tag, for special handling at the upstream system logger.
func (*WaitingMock) AuditInfof ¶
func (log *WaitingMock) AuditInfof(format string, a ...interface{})
AuditInfof sends an INFO-severity message that is prefixed with the audit tag, for special handling at the upstream system logger.
func (*WaitingMock) AuditObject ¶
func (log *WaitingMock) AuditObject(msg string, obj interface{})
AuditObject sends an INFO-severity JSON-serialized object message that is prefixed with the audit tag, for special handling at the upstream system logger.
func (*WaitingMock) Debug ¶
func (log *WaitingMock) Debug(msg string)
Debug level messages pass through normally.
func (*WaitingMock) Debugf ¶
func (log *WaitingMock) Debugf(format string, a ...interface{})
Debugf level messages pass through normally.
func (*WaitingMock) Err ¶
func (log *WaitingMock) Err(msg string)
Err level messages are always marked with the audit tag, for special handling at the upstream system logger.
func (*WaitingMock) Errf ¶
func (log *WaitingMock) Errf(format string, a ...interface{})
Errf level messages are always marked with the audit tag, for special handling at the upstream system logger.
func (*WaitingMock) Info ¶
func (log *WaitingMock) Info(msg string)
Info level messages pass through normally.
func (*WaitingMock) InfoObject ¶
func (log *WaitingMock) InfoObject(msg string, obj interface{})
InfoObject logs an INFO level JSON-serialized object message.
func (*WaitingMock) Infof ¶
func (log *WaitingMock) Infof(format string, a ...interface{})
Infof level messages pass through normally.
func (*WaitingMock) WaitForMatch ¶
WaitForMatch returns the first log line matching a regex. It accepts a regexp string and timeout. If the timeout value is met before the matching pattern is read from the channel, an error is returned.