event

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2018 License: Apache-2.0 Imports: 6 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 Fields

type Fields map[string]interface{}

Fields is a set of named fields. Fields are attached to every log record

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

func NewLog(scope string, log bool) *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) Append

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

Append adds entries to the event logs

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) GetScope

func (eventLog *Log) GetScope() string

GetScope returns scope for event log

func (*Log) IsLog

func (eventLog *Log) IsLog() bool

IsLog returns true if current event log writes logs on the go

func (*Log) LogError

func (eventLog *Log) LogError(err error)

LogError logs an error. Errors with details are processed specially, their details get unfolded as record fields

func (*Log) LogWarning

func (eventLog *Log) LogWarning(err error)

LogWarning logs a warning. Errors with details are processed specially, their details get unfolded as record fields

func (*Log) Save

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

Save takes all buffered event log entries and saves them

func (*Log) WithFields

func (eventLog *Log) WithFields(fields Fields) *logrus.Entry

WithFields creates a new log entry with a given set of 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

Jump to

Keyboard shortcuts

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