Skip to content

Commit

Permalink
Add some comments to blade package
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerBrock committed Jun 30, 2018
1 parent 333771c commit c867c89
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions blade/blade.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import (
"github.com/fatih/color"
)

// A Blade is a Saw execution instance
type Blade struct {
config *config.Configuration
aws *config.AWSConfiguration
output *config.OutputConfiguration
cwl *cloudwatchlogs.CloudWatchLogs
}

// NewBlade creates a new Blade with CloudWatchLogs instance from provided config
func NewBlade(
config *config.Configuration,
awsConfig *config.AWSConfiguration,
Expand Down Expand Up @@ -53,6 +55,7 @@ func NewBlade(
return &blade
}

// GetLogGroups gets the log groups from AWS given the blade configuration
func (b *Blade) GetLogGroups() []*cloudwatchlogs.LogGroup {
input := b.config.DescribeLogGroupsInput()
groups := make([]*cloudwatchlogs.LogGroup, 0)
Expand All @@ -68,6 +71,7 @@ func (b *Blade) GetLogGroups() []*cloudwatchlogs.LogGroup {
return groups
}

// GetLogStreams gets the log streams from AWS given the blade configuration
func (b *Blade) GetLogStreams() []*cloudwatchlogs.LogStream {
input := b.config.DescribeLogStreamsInput()
streams := make([]*cloudwatchlogs.LogStream, 0)
Expand All @@ -84,6 +88,7 @@ func (b *Blade) GetLogStreams() []*cloudwatchlogs.LogStream {
return streams
}

// GetEvents gets events from AWS given the blade configuration
func (b *Blade) GetEvents() {
input := b.config.FilterLogEventsInput()

Expand All @@ -100,6 +105,7 @@ func (b *Blade) GetEvents() {
}
}

// StreamEvents continuously prints log events to the console
func (b *Blade) StreamEvents() {
var lastSeenTime *int64
var seenEventIDs map[string]bool
Expand Down Expand Up @@ -145,6 +151,7 @@ func (b *Blade) StreamEvents() {
}
}

// printEvent prints a filtered CloudWatch log event using the provided formatter
func printEvent(formatter *colorjson.Formatter, event *cloudwatchlogs.FilteredLogEvent) {
red := color.New(color.FgRed).SprintFunc()
white := color.New(color.FgWhite).SprintFunc()
Expand Down

0 comments on commit c867c89

Please sign in to comment.