Documentation ¶
Overview ¶
Package event implements support for Aptomi Event Logs and saving them to console, memory, and external stores (BoltDB). Event logs are user-friendly logs (e.g. policy resolution log, policy apply log), which eventually get shown to the end-users through UI. Unlike standard logs, event logs are fully stored in memory before they get persisted. This is required in order for the engine to attach "details" to every log record. This package also provides a mock logger, which can be useful in unit tests.
Index ¶
- type APIEvent
- type Fields
- type HookAPIEvents
- type HookBoltDB
- type HookConsole
- type HookLogger
- type HookMemory
- type Log
- func (eventLog *Log) Append(that *Log)
- func (eventLog *Log) AsAPIEvents() []*APIEvent
- func (eventLog *Log) AttachTo(object interface{})
- func (eventLog *Log) GetScope() string
- func (eventLog *Log) IsLog() bool
- func (eventLog *Log) LogError(err error)
- func (eventLog *Log) LogWarning(err error)
- func (eventLog *Log) Save(hook logrus.Hook)
- func (eventLog *Log) WithFields(fields Fields) *logrus.Entry
- type LogVerifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIEvent ¶ added in v0.1.12
APIEvent represents simplified Event object to be returned from the API
type Fields ¶
type Fields map[string]interface{}
Fields is a set of named fields. Fields are attached to every log record
type HookAPIEvents ¶ added in v0.1.12
type HookAPIEvents struct {
// contains filtered or unexported fields
}
HookAPIEvents saves all events as APIEvents that holds only time, level and message
func (*HookAPIEvents) Fire ¶ added in v0.1.12
func (hook *HookAPIEvents) Fire(e *logrus.Entry) error
Fire processes a single log entry
func (*HookAPIEvents) Levels ¶ added in v0.1.12
func (hook *HookAPIEvents) Levels() []logrus.Level
Levels defines on which log levels this hook should be fired
type HookBoltDB ¶
type HookBoltDB struct { }
HookBoltDB implements event log hook, which persists all event log entries in BoltDB
func (*HookBoltDB) Fire ¶
func (buf *HookBoltDB) Fire(e *logrus.Entry) error
Fire processes a single log entry
func (*HookBoltDB) Levels ¶
func (buf *HookBoltDB) Levels() []logrus.Level
Levels defines on which log levels this hook should be fired
type HookConsole ¶
type HookConsole struct { }
HookConsole implements event log hook, which prints all event log entries to the console (stdout)
func (*HookConsole) Fire ¶
func (buf *HookConsole) Fire(e *logrus.Entry) error
Fire processes a single log entry
func (*HookConsole) Levels ¶
func (buf *HookConsole) Levels() []logrus.Level
Levels defines on which log levels this hook should be fired
type HookLogger ¶
type HookLogger struct { }
HookLogger is a hook for logrus that prints messages to console using logger
func (*HookLogger) Fire ¶
func (hook *HookLogger) Fire(entry *logrus.Entry) error
Fire processes a single log entry
func (*HookLogger) Levels ¶
func (hook *HookLogger) Levels() []logrus.Level
Levels defines on which log levels this hook should be fired
type HookMemory ¶
type HookMemory struct {
// contains filtered or unexported fields
}
HookMemory implements event log hook, which buffers all event log entries in hookMemory
func (*HookMemory) Fire ¶
func (buf *HookMemory) Fire(e *logrus.Entry) error
Fire processes a single log entry
func (*HookMemory) Levels ¶
func (buf *HookMemory) Levels() []logrus.Level
Levels defines on which log levels this hook should be fired
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is an buffered event log. It stores all log entries in memory first, then allows them to be processed and stored
func NewLog ¶
NewLog creates a new instance of event log. Initially it just buffers all entries and doesn't write them. It needs to buffer all entries, so that the context can be later attached to them before they get serialized and written to an external source
func (*Log) AsAPIEvents ¶ added in v0.1.12
AsAPIEvents takes all buffered event log entries and saves them as APIEvents
func (*Log) AttachTo ¶
func (eventLog *Log) AttachTo(object interface{})
AttachTo attaches all entries in this event log to a certain object E.g. dependency, user, contract, context, serviceKey
func (*Log) LogError ¶
LogError logs an error. Errors with details are processed specially, their details get unfolded as record fields
func (*Log) LogWarning ¶
LogWarning logs a warning. Errors with details are processed specially, their details get unfolded as record fields
type LogVerifier ¶
type LogVerifier struct {
// contains filtered or unexported fields
}
LogVerifier is a mock logger and a unit test helper for verifying event log messages
func NewLogVerifier ¶
func NewLogVerifier(expectedMessage string, isError bool) *LogVerifier
NewLogVerifier creates a new LogVerifier which searches for a given error message
func (*LogVerifier) Fire ¶
func (verifier *LogVerifier) Fire(e *logrus.Entry) error
Fire processes a log entry. If it contains a given error message, it increments verifier.cnt
func (*LogVerifier) Levels ¶
func (verifier *LogVerifier) Levels() []logrus.Level
Levels returns a set of levels for the mock logger. Returns all levels
func (*LogVerifier) MatchedErrorsCount ¶
func (verifier *LogVerifier) MatchedErrorsCount() int
MatchedErrorsCount returns verifier.cnt, which represent the number of found errors matching a given string