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 HookConsole
- type HookMemory
- type Log
- func (eventLog *Log) AddConsoleHook(level logrus.Level) *Log
- func (eventLog *Log) AddFixedField(name string, value string)
- func (eventLog *Log) AddHook(hook logrus.Hook) *Log
- func (eventLog *Log) Append(that *Log)
- func (eventLog *Log) AsAPIEvents() []*APIEvent
- func (eventLog *Log) GetLevel() logrus.Level
- func (eventLog *Log) GetScope() string
- func (eventLog *Log) NewEntry() *logrus.Entry
- func (eventLog *Log) Save(hook logrus.Hook)
- 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 HookConsole ¶
type HookConsole struct {
// contains filtered or unexported fields
}
HookConsole implements event log hook, which prints entries to the console
func NewHookConsole ¶ added in v0.1.14
func NewHookConsole(level logrus.Level) *HookConsole
NewHookConsole creates a new HookConsole
func (*HookConsole) Fire ¶
func (hook *HookConsole) Fire(e *logrus.Entry) error
Fire processes a single log entry
func (*HookConsole) Levels ¶
func (hook *HookConsole) 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) AddConsoleHook ¶ added in v0.1.14
AddConsoleHook puts an additional hook to an existing event log, to mirror logs to the console
func (*Log) AddFixedField ¶ added in v0.1.14
AddFixedField adds field with name=values to add following entries in the log
func (*Log) AsAPIEvents ¶ added in v0.1.12
AsAPIEvents takes all buffered event log entries and saves them as APIEvents
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