Skip to content

Commit 2b097cc

Browse files
author
Jeff Carter
committed
update logging to aid with debugging
1 parent e416a9a commit 2b097cc

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

cmd/awsets/cmd/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ var listCmd = &cli.Command{
134134
switch update.Type {
135135
case option.StatusLogInfo:
136136
if verbose {
137-
fmt.Fprintln(os.Stdout, update.Message)
137+
fmt.Fprintf(os.Stdout, "%s - %s - %s\n", update.Region, update.Lister, update.Message)
138138
}
139139
case option.StatusLogDebug:
140140
if verbose {
141-
fmt.Fprintln(os.Stdout, update.Message)
141+
fmt.Fprintf(os.Stdout, "%s - %s - %s\n", update.Region, update.Lister, update.Message)
142142
}
143143
case option.StatusLogError:
144-
fmt.Fprintf(os.Stderr, update.Message)
144+
fmt.Fprintf(os.Stderr, "%s - %s - %s\n", update.Region, update.Lister, update.Message)
145145
case option.StatusProcessing:
146146
case option.StatusComplete:
147147
fallthrough

lister/cloudformation_stack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (l AWSCloudFormationStack) List(cfg option.AWSetsConfig) (*resource.Group,
7070
return res.NextToken, nil
7171
})
7272
if len(unmapped) > 0 {
73-
stacksMsg := fmt.Sprintf("unmapped cf types for region %s:\n", cfg.Region())
73+
stacksMsg := fmt.Sprintf("unmapped cf types:\n")
7474
for k, v := range unmapped {
7575
stacksMsg += fmt.Sprintf("%s,%03d\n", k, v)
7676
}

main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,12 @@ func List(cfg aws.Config, regions []string, listers []ListerName, cache Cacher,
200200
if err != nil {
201201
workerCfg.SendStatus(option.StatusCompleteWithError, err.Error())
202202
} else {
203-
// Merge the new results in with the rest
204-
rg.Merge(group)
203+
if group == nil {
204+
workerCfg.SendStatus(option.StatusLogError, "rg is nil after processing")
205+
} else {
206+
// Merge the new results in with the rest
207+
rg.Merge(group)
208+
}
205209
workerCfg.SendStatus(option.StatusComplete, "")
206210
}
207211
}
@@ -230,7 +234,7 @@ func processJob(awsetsCfg *option.AWSetsConfig, id int, job listjob, cache Cache
230234
defer func() {
231235
if r := recover(); r != nil {
232236
jobError = fmt.Errorf("panicked: %v", r)
233-
awsetsCfg.SendStatus(option.StatusLogDebug, fmt.Sprintf("%d: stacktrace from panic: %v\n", id, string(debug.Stack())))
237+
awsetsCfg.SendStatus(option.StatusLogError, fmt.Sprintf("%d: stacktrace from panic: %v\n", id, string(debug.Stack())))
234238
}
235239
}()
236240

0 commit comments

Comments
 (0)