aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-08-26 09:51:20 -0700
committerChris Lu <chris.lu@gmail.com>2020-08-26 09:51:20 -0700
commit50f7e2e89f2e94d9a5252ff6e58bb9a16d171eec (patch)
tree8990cbf9b8c69fb095f07e27fb653b2b4e563ae8
parent6bc618051cee4bd4dae6d220b55b51ff6d9591dd (diff)
downloadseaweedfs-50f7e2e89f2e94d9a5252ff6e58bb9a16d171eec.tar.xz
seaweedfs-50f7e2e89f2e94d9a5252ff6e58bb9a16d171eec.zip
add log messages
-rw-r--r--weed/operation/upload_content.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go
index df86dd173..5c1b946f5 100644
--- a/weed/operation/upload_content.go
+++ b/weed/operation/upload_content.go
@@ -3,7 +3,6 @@ package operation
import (
"bytes"
"encoding/json"
- "errors"
"fmt"
"io"
"io/ioutil"
@@ -210,8 +209,8 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
req, postErr := http.NewRequest("POST", uploadUrl, body_buf)
if postErr != nil {
- glog.V(1).Infof("failing to upload to %s: %v", uploadUrl, postErr)
- return nil, fmt.Errorf("failing to upload to %s: %v", uploadUrl, postErr)
+ glog.V(1).Infof("create upload request %s: %v", uploadUrl, postErr)
+ return nil, fmt.Errorf("create upload request %s: %v", uploadUrl, postErr)
}
req.Header.Set("Content-Type", content_type)
for k, v := range pairMap {
@@ -222,8 +221,8 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
}
resp, post_err := HttpClient.Do(req)
if post_err != nil {
- glog.V(1).Infof("failing to upload to %v: %v", uploadUrl, post_err)
- return nil, fmt.Errorf("failing to upload to %v: %v", uploadUrl, post_err)
+ glog.Errorf("upload to %v: %v", uploadUrl, post_err)
+ return nil, fmt.Errorf("upload to %v: %v", uploadUrl, post_err)
}
defer util.CloseResponse(resp)
@@ -236,16 +235,16 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
resp_body, ra_err := ioutil.ReadAll(resp.Body)
if ra_err != nil {
- return nil, ra_err
+ return nil, fmt.Errorf("read response body %v: %v", uploadUrl, ra_err)
}
unmarshal_err := json.Unmarshal(resp_body, &ret)
if unmarshal_err != nil {
- glog.V(0).Infoln("failing to read upload response", uploadUrl, string(resp_body))
- return nil, unmarshal_err
+ glog.Errorf("unmarshal %s: %v", uploadUrl, string(resp_body))
+ return nil, fmt.Errorf("unmarshal %v: %v", uploadUrl, unmarshal_err)
}
if ret.Error != "" {
- return nil, errors.New(ret.Error)
+ return nil, fmt.Errorf("unmarshalled error %v: %v", uploadUrl, ret.Error)
}
ret.ETag = etag
ret.ContentMd5 = resp.Header.Get("Content-MD5")