lib

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MaxEventsPerCall is the maximum number events from a filter call
	MaxEventsPerCall = 10000
	// MaxStreams is the maximum number of streams you can give to a filter call
	MaxStreams = 100
)
View Source
const (
	// ShortTimeFormat is a short format for printing timestamps
	ShortTimeFormat = "01-02 15:04:05"
)

Variables

View Source
var (
	Red     = color.New(color.FgRed).SprintFunc()
	Green   = color.New(color.FgGreen).SprintFunc()
	Yellow  = color.New(color.FgYellow).SprintFunc()
	Blue    = color.New(color.FgBlue).SprintFunc()
	Magenta = color.New(color.FgMagenta).SprintFunc()
	Cyan    = color.New(color.FgCyan).SprintFunc()
	White   = color.New(color.FgWhite).SprintFunc()
)

These color functions are used by output templates to control text color

View Source
var TaskUUIDPattern = regexp.MustCompile(`^[[:alnum:]]{8}-[[:alnum:]]{4}-[[:alnum:]]{4}-[[:alnum:]]{4}-[[:alnum:]]{12}$`)

TaskUUIDPattern is used to match task UUIDs

Functions

func ColorLevel

func ColorLevel(l ecslogs.Level) string

ColorLevel takes a log level and colors it based on severity

func GetTime

func GetTime(value string, reference time.Time) (time.Time, error)

GetTime tries to parse given string as golang duration, then RFC3339 time and finally as a Unix timestamp. If any of these were successful, it returns a time.Time object. In case of duration input, the returned Time is computed as the given reference time minus the amount of the duration.

func ParseAWSTimestamp

func ParseAWSTimestamp(i *int64) time.Time

ParseAWSTimestamp takes the time stamp format given by AWS and returns an equivalent time.Time value

func Unique

func Unique(args ...string) string

Unique takes a string (or series of strings) and colors that string uniquely based on the string contents. Calling this function with the same string input should always return the same color.

Types

type ByCreationTime

type ByCreationTime []Event

ByCreationTime is used to sort events by their creation time

func (ByCreationTime) Len

func (b ByCreationTime) Len() int

func (ByCreationTime) Less

func (b ByCreationTime) Less(i, j int) bool

func (ByCreationTime) Swap

func (b ByCreationTime) Swap(i, j int)

type ByLastEvent

type ByLastEvent []*cloudwatchlogs.LogStream

ByLastEvent is used to sort log streams by last event timestamp

func (ByLastEvent) Len

func (b ByLastEvent) Len() int

func (ByLastEvent) Less

func (b ByLastEvent) Less(i, j int) bool

func (ByLastEvent) Swap

func (b ByLastEvent) Swap(i, j int)

type CloudwatchLogsReader

type CloudwatchLogsReader struct {
	// contains filtered or unexported fields
}

CloudwatchLogsReader is responsible for fetching logs for a particular log group

func NewCloudwatchLogsReader

func NewCloudwatchLogsReader(group string, streamPrefix string, start time.Time, end time.Time) (*CloudwatchLogsReader, error)

NewCloudwatchLogsReader takes a group and optionally a stream prefix, start and end time, and returns a reader for any logs that match those parameters.

func (*CloudwatchLogsReader) Error

func (c *CloudwatchLogsReader) Error() error

Error returns an error if one occured while streaming events.

func (*CloudwatchLogsReader) ListStreams

func (c *CloudwatchLogsReader) ListStreams() ([]*cloudwatchlogs.LogStream, error)

ListStreams returns any log streams that match the params given in the reader's constructor. Will return at most `MaxStreams` streams

func (*CloudwatchLogsReader) StreamEvents

func (c *CloudwatchLogsReader) StreamEvents(follow bool) <-chan Event

StreamEvents returns a channel where you can read events matching the params given in the readers constructor. The channel will be closed once all events are read or an error occurs. You can check for errors after the channel is closed by calling Error()

type Event

type Event struct {
	ecslogs.Event
	Stream       string
	Group        string
	ID           string
	IngestTime   time.Time
	CreationTime time.Time
}

Event represents a log event

func NewEvent

func NewEvent(cwEvent cloudwatchlogs.FilteredLogEvent, group string) Event

NewEvent takes a cloudwatch log event and returns an Event

func (Event) DataFlat

func (e Event) DataFlat() map[string]interface{}

func (Event) PrettyPrint

func (e Event) PrettyPrint() string

func (Event) TaskShort

func (e Event) TaskShort() string

TaskShort attempts to shorten a stream name if it is a task UUID, leaving the stream name intact if it is not a UUID

func (Event) TimeShort

func (e Event) TimeShort() string

TimeShort gives the timestamp of an event in a readable format

Jump to

Keyboard shortcuts

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