Log item parse error messages
This commit is contained in:
parent
154a4fc904
commit
b2f2cd0cef
@ -71,6 +71,11 @@ func Execute(
|
||||
|
||||
makeErrorItem := makeMakeErrItem(source, argv)
|
||||
var logs []string
|
||||
addLog := func(format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
log.Print(msg)
|
||||
logs = append(logs, msg)
|
||||
}
|
||||
|
||||
if source == "" {
|
||||
err = fmt.Errorf("empty source")
|
||||
@ -172,15 +177,14 @@ monitor:
|
||||
var item Item
|
||||
err := json.Unmarshal(data, &item)
|
||||
if err != nil || item.Id == "" {
|
||||
msg := fmt.Sprintf("[%s: stdout] %s", source, strings.TrimSpace(string(data)))
|
||||
log.Print(msg)
|
||||
logs = append(logs, msg)
|
||||
if err != nil {
|
||||
addLog("[%s: item] parse error: %v", source, err)
|
||||
}
|
||||
addLog("[%s: stdout] %s", source, strings.TrimSpace(string(data)))
|
||||
parseError = true
|
||||
} else {
|
||||
if itemIds[item.Id] {
|
||||
msg := fmt.Sprintf("[%s: item] %s (duplicate)", source, item.Id)
|
||||
log.Print(msg)
|
||||
logs = append(logs, msg)
|
||||
addLog("[%s: item] %s (duplicate)", source, item.Id)
|
||||
duplicateItem = item.Id
|
||||
cmd.Cancel()
|
||||
break monitor
|
||||
@ -193,16 +197,12 @@ monitor:
|
||||
item.Active = true // These fields aren't up to
|
||||
item.Created = 0 // the action to set and
|
||||
item.Source = source // shouldn't be overrideable
|
||||
msg := fmt.Sprintf("[%s: item] %s", source, item.Id)
|
||||
log.Print(msg)
|
||||
logs = append(logs, msg)
|
||||
addLog("[%s: item] %s", source, item.Id)
|
||||
items = append(items, item)
|
||||
}
|
||||
|
||||
case data := <-cerr:
|
||||
msg := fmt.Sprintf("[%s: stderr] %s", source, strings.TrimSpace(string(data)))
|
||||
log.Print(msg)
|
||||
logs = append(logs, msg)
|
||||
addLog("[%s: stderr] %s", source, strings.TrimSpace(string(data)))
|
||||
|
||||
case <-coutDone:
|
||||
stdoutDone = true
|
||||
|
Loading…
Reference in New Issue
Block a user