🎨 More details in sync log

This commit is contained in:
Daniel 2023-07-23 19:46:04 +08:00
parent eb97f4c23a
commit 74e8ebeae9
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1007,10 +1007,8 @@ func syncRepoDownload() (err error) {
Conf.Save()
autoSyncErrCount = 0
BootSyncSucc = 0
logging.LogInfof("synced data repo download [provider=%d, ufc=%d, dfc=%d, ucc=%d, dcc=%d, ub=%s, db=%s] in [%.2fs]",
Conf.Sync.Provider, trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)), elapsed.Seconds())
processSyncMergeResult(false, true, start, mergeResult)
processSyncMergeResult(false, true, mergeResult, trafficStat, "d", elapsed)
return
}
@ -1077,8 +1075,8 @@ func syncRepoUpload() (err error) {
Conf.Save()
autoSyncErrCount = 0
BootSyncSucc = 0
logging.LogInfof("synced data repo upload [provider=%d, ufc=%d, dfc=%d, ucc=%d, dcc=%d, ub=%s, db=%s] in [%.2fs]",
Conf.Sync.Provider, trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)), elapsed.Seconds())
processSyncMergeResult(false, true, &dejavu.MergeResult{}, trafficStat, "u", elapsed)
return
}
@ -1246,14 +1244,18 @@ func syncRepo(exit, byHand bool) (dataChanged bool, err error) {
Conf.Sync.Stat = msg
Conf.Save()
autoSyncErrCount = 0
logging.LogInfof("synced data repo [kernel=%s, provider=%d, ufc=%d, dfc=%d, ucc=%d, dcc=%d, ub=%s, db=%s] in [%.2fs]",
KernelID, Conf.Sync.Provider, trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)), elapsed.Seconds())
processSyncMergeResult(exit, byHand, start, mergeResult)
processSyncMergeResult(exit, byHand, mergeResult, trafficStat, "a", elapsed)
return
}
func processSyncMergeResult(exit, byHand bool, start time.Time, mergeResult *dejavu.MergeResult) {
func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult, trafficStat *dejavu.TrafficStat, mode string, elapsed time.Duration) {
logging.LogInfof("synced data repo [kernel=%s, provider=%d, mode=%s/%t, ufc=%d, dfc=%d, ucc=%d, dcc=%d, ub=%s, db=%s] in [%.2fs], merge result [conflicts=%d, upserts=%d, removes=%d]",
KernelID, Conf.Sync.Provider, mode, byHand,
trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)),
elapsed.Seconds(),
len(mergeResult.Conflicts), len(mergeResult.Upserts), len(mergeResult.Removes))
//logSyncMergeResult(mergeResult)
if 0 < len(mergeResult.Conflicts) {
@ -1369,7 +1371,6 @@ func processSyncMergeResult(exit, byHand bool, start time.Time, mergeResult *dej
}
upsertRootIDs, removeRootIDs := incReindex(upserts, removes)
elapsed := time.Since(start)
go func() {
if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container {
// 移动端不推送差异详情
@ -1405,7 +1406,6 @@ func logSyncMergeResult(mergeResult *dejavu.MergeResult) {
return
}
logging.LogInfof("sync merge result [conflicts=%d, upserts=%d, removes=%d]", len(mergeResult.Conflicts), len(mergeResult.Upserts), len(mergeResult.Removes))
if 0 < len(mergeResult.Conflicts) {
logBuilder := bytes.Buffer{}
for i, f := range mergeResult.Conflicts {