utils

package
v0.0.0-...-5394570 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLogCollectorMaxItems defines default maximum size of LogCollector.
	DefaultLogCollectorMaxItems = 50
	// DefaultLogCollectorItemLifetime is the default time after which LogItem will be removed from LogCollector.
	DefaultLogCollectorItemLifetime = 15 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LogCollector

type LogCollector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LogCollector keeps recent log events. It is automatically truncated on each access based on predefined set of conditions.

func NewLogCollector

func NewLogCollector() *LogCollector

NewLogCollector creates new LogCollector.

func (*LogCollector) GetLogs

func (lc *LogCollector) GetLogs() []LogItem

GetLogs returns a copy of messages in log. This is an actual copy, so it will not reflect any future changes in log.

func (*LogCollector) Log

func (lc *LogCollector) Log(msg string, level LogLevel)

Log logs a single provided message in LogCollector.

type LogItem

type LogItem struct {
	// Log is the logged message body.
	Log string
	// Level describes log severity.
	Level LogLevel
	// Timestamp when the Log was created.
	Timestamp time.Time
}

LogItem is a single entry in log managed by LogCollector.

type LogLevel

type LogLevel string

LogLevel describes severity of log entry.

const (
	// Debug log level.
	Debug LogLevel = "DEBUG"
	// Info log level.
	Info LogLevel = "INFO"
	// Warning log level.
	Warning LogLevel = "WARNING"
	// Error log level.
	Error LogLevel = "ERROR"
)

Jump to

Keyboard shortcuts

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