event

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: May 30, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIEvent added in v0.1.12

type APIEvent struct {
	Time     time.Time
	LogLevel string `yaml:"level"`
	Message  string
}

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

func NewLog(level logrus.Level, scope string) *Log

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

func (eventLog *Log) AddConsoleHook(level logrus.Level) *Log

AddConsoleHook puts an additional hook to an existing event log, to mirror logs to the console

func (*Log) AddFixedField added in v0.1.14

func (eventLog *Log) AddFixedField(name string, value string)

AddFixedField adds field with name=values to add following entries in the log

func (*Log) AddHook added in v0.1.14

func (eventLog *Log) AddHook(hook logrus.Hook) *Log

AddHook puts an additional hook to an existing event log

func (*Log) Append

func (eventLog *Log) Append(that *Log)

Append adds entries to the event logs

func (*Log) AsAPIEvents added in v0.1.12

func (eventLog *Log) AsAPIEvents() []*APIEvent

AsAPIEvents takes all buffered event log entries and saves them as APIEvents

func (*Log) GetLevel added in v0.1.14

func (eventLog *Log) GetLevel() logrus.Level

GetLevel returns log level for the event log

func (*Log) GetScope

func (eventLog *Log) GetScope() string

GetScope returns scope for event log

func (*Log) NewEntry added in v0.1.14

func (eventLog *Log) NewEntry() *logrus.Entry

NewEntry creates a new log entry

func (*Log) Save

func (eventLog *Log) Save(hook logrus.Hook)

Save takes all buffered event log entries and saves them

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

Jump to

Keyboard shortcuts

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