Skip to content
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

Merged
merged 2 commits into from
Nov 23, 2024
Merged

Output error and warning log #717

merged 2 commits into from
Nov 23, 2024

Conversation

feiniks
Copy link
Contributor

@feiniks feiniks commented Nov 18, 2024

No description provided.

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上面这些读取 block 失败应该都属于 error 吧。

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数里面,发送通知失败属于不那么重要的错误,可以用 warn。

@@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个错误可以不用打印了,因为这个可能是客户端断开连接。

@@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个日志也不用打印了。

@@ -851,7 +851,7 @@ func getBlockInfo(rsp http.ResponseWriter, r *http.Request) *appError {
rsp.Header().Set("Content-Length", blockLen)
if err := blockmgr.Read(storeID, blockID, rsp); err != nil {
if !isNetworkErr(err) {
log.Printf("failed to read block %s: %v", blockID, err)
log.Warnf("failed to read block %s: %v", blockID, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个也应该是 error.

@@ -914,7 +914,7 @@ func publishStatusEvent(rData *statusEventData) {
rData.eType, rData.user,
rData.repoID, rData.bytes)
if _, err := rpcclient.Call("publish_event", seafileServerChannelStats, buf); err != nil {
log.Printf("Failed to publish event: %v", err)
log.Errorf("Failed to publish event: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 warn 就可以了。

@@ -988,7 +988,7 @@ func getCommitInfo(rsp http.ResponseWriter, r *http.Request) *appError {
return appErr
}
if exists, _ := commitmgr.Exists(repoID, commitID); !exists {
log.Printf("%s:%s is missing", repoID, commitID)
log.Warnf("%s:%s is missing", repoID, commitID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个日志不用打印。

@@ -1246,7 +1246,7 @@ func onRepoOper(eType, repoID, user, ip, clientName string) {
vInfo, err := repomgr.GetVirtualRepoInfo(repoID)

if err != nil {
log.Printf("Failed to get virtual repo info by repo id %s: %v", repoID, err)
log.Warnf("Failed to get virtual repo info by repo id %s: %v", repoID, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个也应该是 error 吧。

}
}

func publishUpdateEvent(repoID string, commitID string) {
buf := fmt.Sprintf("repo-update\t%s\t%s", repoID, commitID)
if _, err := rpcclient.Call("publish_event", seafileServerChannelEvent, buf); err != nil {
log.Printf("Failed to publish event: %v", err)
log.Errorf("Failed to publish event: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上面这两个改为 warn。

@killing killing merged commit 516eac3 into master Nov 23, 2024
6 checks passed
@killing killing deleted the log_level branch November 23, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants