Skip to content

Commit 4120609

Browse files
committed
better log for HTTP response writing errors
1 parent e47edce commit 4120609

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

apricot/local/servicehttp.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,10 @@ func (httpsvc *HttpService) ApiPrintClusterInformation(w http.ResponseWriter, r
617617
}
618618
_, err = fmt.Fprintln(w, string(result))
619619
if err != nil {
620-
log.WithError(err).Warn("Error, could not write response.")
620+
log.WithField("result", string(result)).
621+
WithField(infologger.Level, infologger.IL_Support).
622+
WithError(err).
623+
Warn("Error, could not write a part of HTTP response to response writer.")
621624
}
622625
case "text":
623626
fallthrough
@@ -628,19 +631,25 @@ func (httpsvc *HttpService) ApiPrintClusterInformation(w http.ResponseWriter, r
628631
for _, hostname := range hosts {
629632
_, err := fmt.Fprintf(w, "%s\n", hostname)
630633
if err != nil {
631-
log.WithError(err).Warn("Error, could not write response.")
634+
log.WithField(infologger.Level, infologger.IL_Support).
635+
WithError(err).
636+
Warn("Error, could not write a part of HTTP response to response writer.")
632637
}
633638
}
634639
} else if inventory != nil {
635640
for detector, flps := range inventory {
636641
_, err := fmt.Fprintf(w, "%s\n", detector)
637642
if err != nil {
638-
log.WithError(err).Warn("Error, could not write response.")
643+
log.WithField(infologger.Level, infologger.IL_Support).
644+
WithError(err).
645+
Warn("Error, could not write a part of HTTP response to response writer.")
639646
}
640647
for _, hostname := range flps {
641648
_, err = fmt.Fprintf(w, "\t%s\n", hostname)
642649
if err != nil {
643-
log.WithError(err).Warn("Error, could not write response.")
650+
log.WithField(infologger.Level, infologger.IL_Support).
651+
WithError(err).
652+
Warn("Error, could not write a part of HTTP response to response writer.")
644653
}
645654
}
646655
}

0 commit comments

Comments
 (0)