-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output error and warning log #717
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -408,7 +408,7 @@ func doFile(rsp http.ResponseWriter, r *http.Request, repo *repomgr.Repo, fileID | |
err := blockmgr.Read(repo.StoreID, blkID, rsp) | ||
if err != nil { | ||
if !isNetworkErr(err) { | ||
log.Printf("failed to read block %s: %v", blkID, err) | ||
log.Warnf("failed to read block %s: %v", blkID, err) | ||
} | ||
return nil | ||
} | ||
|
@@ -523,7 +523,7 @@ func doFileRange(rsp http.ResponseWriter, r *http.Request, repo *repomgr.Repo, f | |
err := blockmgr.Read(repo.StoreID, blkID, &buf) | ||
if err != nil { | ||
if !isNetworkErr(err) { | ||
log.Printf("failed to read block %s: %v", blkID, err) | ||
log.Warnf("failed to read block %s: %v", blkID, err) | ||
} | ||
return nil | ||
} | ||
|
@@ -535,7 +535,7 @@ func doFileRange(rsp http.ResponseWriter, r *http.Request, repo *repomgr.Repo, f | |
err := blockmgr.Read(repo.StoreID, blkID, &buf) | ||
if err != nil { | ||
if !isNetworkErr(err) { | ||
log.Printf("failed to read block %s: %v", blkID, err) | ||
log.Warnf("failed to read block %s: %v", blkID, err) | ||
} | ||
return nil | ||
} | ||
|
@@ -557,7 +557,7 @@ func doFileRange(rsp http.ResponseWriter, r *http.Request, repo *repomgr.Repo, f | |
err := blockmgr.Read(repo.StoreID, blkID, &buf) | ||
if err != nil { | ||
if !isNetworkErr(err) { | ||
log.Printf("failed to read block %s: %v", blkID, err) | ||
log.Warnf("failed to read block %s: %v", blkID, err) | ||
} | ||
return nil | ||
} | ||
|
@@ -571,7 +571,7 @@ func doFileRange(rsp http.ResponseWriter, r *http.Request, repo *repomgr.Repo, f | |
err := blockmgr.Read(repo.StoreID, blkID, rsp) | ||
if err != nil { | ||
if !isNetworkErr(err) { | ||
log.Printf("failed to read block %s: %v", blkID, err) | ||
log.Warnf("failed to read block %s: %v", blkID, err) | ||
} | ||
return nil | ||
} | ||
|
@@ -763,7 +763,7 @@ func doBlock(rsp http.ResponseWriter, r *http.Request, repo *repomgr.Repo, fileI | |
err = blockmgr.Read(repo.StoreID, blkID, rsp) | ||
if err != nil { | ||
if !isNetworkErr(err) { | ||
log.Printf("failed to read block %s: %v", blkID, err) | ||
log.Warnf("failed to read block %s: %v", blkID, err) | ||
} | ||
} | ||
|
||
|
@@ -861,7 +861,7 @@ func downloadZipFile(rsp http.ResponseWriter, r *http.Request, data, repoID, use | |
|
||
err := packDir(ar, repo, objID, dirName, cryptKey) | ||
if err != nil { | ||
log.Printf("failed to pack dir %s: %v", dirName, err) | ||
log.Errorf("failed to pack dir %s: %v", dirName, err) | ||
return nil | ||
} | ||
} else { | ||
|
@@ -885,14 +885,14 @@ func downloadZipFile(rsp http.ResponseWriter, r *http.Request, data, repoID, use | |
if fsmgr.IsDir(v.Mode) { | ||
if err := packDir(ar, repo, v.ID, uniqueName, cryptKey); err != nil { | ||
if !isNetworkErr(err) { | ||
log.Printf("failed to pack dir %s: %v", v.Name, err) | ||
log.Errorf("failed to pack dir %s: %v", v.Name, err) | ||
} | ||
return nil | ||
} | ||
} else { | ||
if err := packFiles(ar, &v, repo, "", uniqueName, cryptKey); err != nil { | ||
if !isNetworkErr(err) { | ||
log.Printf("failed to pack file %s: %v", v.Name, err) | ||
log.Errorf("failed to pack file %s: %v", v.Name, err) | ||
} | ||
return nil | ||
} | ||
|
@@ -1232,7 +1232,7 @@ func doUpload(rsp http.ResponseWriter, r *http.Request, fsm *recvData, isAjax bo | |
success := "{\"success\": true}" | ||
_, err := rsp.Write([]byte(success)) | ||
if err != nil { | ||
log.Printf("failed to write data to response") | ||
log.Warnf("failed to write data to response") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个错误可以不用打印了,因为这个可能是客户端断开连接。 |
||
} | ||
|
||
return nil | ||
|
@@ -2154,23 +2154,23 @@ func notifRepoUpdate(repoID string, commitID string) error { | |
event.Content = content | ||
msg, err := json.Marshal(event) | ||
if err != nil { | ||
log.Printf("failed to encode repo update event: %v", err) | ||
log.Errorf("failed to encode repo update event: %v", err) | ||
return err | ||
} | ||
|
||
url := fmt.Sprintf("http://%s/events", option.NotificationURL) | ||
exp := time.Now().Add(time.Second * 300).Unix() | ||
token, err := utils.GenNotifJWTToken(repoID, "", exp) | ||
if err != nil { | ||
log.Printf("failed to generate jwt token: %v", err) | ||
log.Errorf("failed to generate jwt token: %v", err) | ||
return err | ||
} | ||
header := map[string][]string{ | ||
"Authorization": {"Token " + token}, | ||
} | ||
_, _, err = utils.HttpCommon("POST", url, header, bytes.NewReader(msg)) | ||
if err != nil { | ||
log.Printf("failed to send repo update event: %v", err) | ||
log.Errorf("failed to send repo update event: %v", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个函数里面,发送通知失败属于不那么重要的错误,可以用 warn。 |
||
return err | ||
} | ||
|
||
|
@@ -2340,7 +2340,7 @@ func nameExists(entries []*fsmgr.SeafDirent, fileName string) bool { | |
|
||
func shouldIgnoreFile(fileName string) bool { | ||
if !utf8.ValidString(fileName) { | ||
log.Printf("file name %s contains non-UTF8 characters, skip", fileName) | ||
log.Warnf("file name %s contains non-UTF8 characters, skip", fileName) | ||
return true | ||
} | ||
|
||
|
@@ -2473,7 +2473,7 @@ type chunkingResult struct { | |
func createChunkPool(ctx context.Context, n int, chunkJobs chan chunkingData, res chan chunkingResult) { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
log.Printf("panic: %v\n%s", err, debug.Stack()) | ||
log.Errorf("panic: %v\n%s", err, debug.Stack()) | ||
} | ||
}() | ||
var wg sync.WaitGroup | ||
|
@@ -2488,7 +2488,7 @@ func createChunkPool(ctx context.Context, n int, chunkJobs chan chunkingData, re | |
func chunkingWorker(ctx context.Context, wg *sync.WaitGroup, chunkJobs chan chunkingData, res chan chunkingResult) { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
log.Printf("panic: %v\n%s", err, debug.Stack()) | ||
log.Errorf("panic: %v\n%s", err, debug.Stack()) | ||
} | ||
}() | ||
for job := range chunkJobs { | ||
|
@@ -3015,7 +3015,7 @@ func doUpdate(rsp http.ResponseWriter, r *http.Request, fsm *recvData, isAjax bo | |
success := "{\"success\": true}" | ||
_, err := rsp.Write([]byte(success)) | ||
if err != nil { | ||
log.Printf("failed to write data to response.\n") | ||
log.Warnf("failed to write data to response.\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个日志也不用打印了。 |
||
} | ||
|
||
return nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
上面这些读取 block 失败应该都属于 error 吧。