@@ -73,7 +73,7 @@ func getLokiError(resp []byte, code int) string {
7373 }
7474 err := json .Unmarshal (resp , & f )
7575 if err != nil {
76- hlog .Errorf ("Cannot unmarshal (%v). Response was: %s" , err , string (resp ))
76+ hlog .WithError ( err ). Errorf ("cannot unmarshal, response was: %v" , string (resp ))
7777 return fmt .Sprintf ("Unknown error from Loki\n cannot unmarshal\n %s" , resp )
7878 }
7979 message , ok := f ["message" ]
@@ -116,7 +116,7 @@ func fetchSingle(lokiClient httpclient.Caller, flowsURL string, merger loki.Merg
116116 }
117117 var qr model.QueryResponse
118118 if err := json .Unmarshal (resp , & qr ); err != nil {
119- hlog .Errorf ("Cannot unmarshal (%v). Response was: %s" , err , string (resp ))
119+ hlog .WithError ( err ). Errorf ("cannot unmarshal, response was: %v" , string (resp ))
120120 return http .StatusInternalServerError , err
121121 }
122122 if _ , err := merger .Add (qr .Data ); err != nil {
@@ -148,7 +148,7 @@ func fetchParallel(lokiClient httpclient.Caller, queries []string, merger loki.M
148148 var qr model.QueryResponse
149149 err := json .Unmarshal (resp , & qr )
150150 if err != nil {
151- hlog .Errorf ("Cannot unmarshal (%v). Response was: %s" , err , string (resp ))
151+ hlog .WithError ( err ). Errorf ("cannot unmarshal, response was: %v" , string (resp ))
152152 errChan <- errorWithCode {err : err , code : http .StatusInternalServerError }
153153 } else {
154154 resChan <- qr
@@ -243,7 +243,7 @@ func LokiConfig(cfg *loki.Config, param string) func(w http.ResponseWriter, r *h
243243 cfg := make (map [string ]interface {})
244244 err = yaml .Unmarshal (resp , & cfg )
245245 if err != nil {
246- hlog .Errorf ("Cannot unmarshal (%v). Response was: %s" , err , string (resp ))
246+ hlog .WithError ( err ). Errorf ("cannot unmarshal, response was: %v" , string (resp ))
247247 writeError (w , code , err .Error ())
248248 return
249249 }
0 commit comments