rpc: swap fmt to log for response handling

This commit is contained in:
Vsevolod Brekelov 2019-10-15 16:15:07 +03:00
parent 67219b9439
commit 31212676f2

View file

@ -2,7 +2,6 @@ package rpc
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"net/http" "net/http"
@ -114,7 +113,12 @@ func (r Request) writeServerResponse(w http.ResponseWriter, response Response) {
encoder := json.NewEncoder(w) encoder := json.NewEncoder(w)
err := encoder.Encode(response) err := encoder.Encode(response)
logFields := log.Fields{
"err": err,
"method": r.Method,
}
if err != nil { if err != nil {
fmt.Println(err) log.WithFields(logFields).Error("Error encountered while encoding response")
} }
} }