downloader: better logging (#8183)

This commit is contained in:
Alex Sharov 2023-09-13 13:42:24 +07:00 committed by GitHub
parent 2158b4916d
commit 3813a5ea10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -200,17 +200,19 @@ Loop:
} }
dbg.ReadMemStats(&m) dbg.ReadMemStats(&m)
downloadTimeLeft := calculateTime(stats.BytesTotal-stats.BytesCompleted, stats.DownloadRate) downloadTimeLeft := calculateTime(stats.BytesTotal-stats.BytesCompleted, stats.DownloadRate)
log.Info(fmt.Sprintf("[%s] download", logPrefix), suffix := "downloading archives"
if stats.Progress > 0 && stats.DownloadRate == 0 {
suffix += "verifying archives"
}
log.Info(fmt.Sprintf("[%s] %s", logPrefix, suffix),
"progress", fmt.Sprintf("%.2f%% %s/%s", stats.Progress, common.ByteCount(stats.BytesCompleted), common.ByteCount(stats.BytesTotal)), "progress", fmt.Sprintf("%.2f%% %s/%s", stats.Progress, common.ByteCount(stats.BytesCompleted), common.ByteCount(stats.BytesTotal)),
"download-time-left", downloadTimeLeft, "time-left", downloadTimeLeft,
"total-download-time", time.Since(downloadStartTime).Round(time.Second).String(), "total-time", time.Since(downloadStartTime).Round(time.Second).String(),
"download", common.ByteCount(stats.DownloadRate)+"/s", "download", common.ByteCount(stats.DownloadRate)+"/s",
"upload", common.ByteCount(stats.UploadRate)+"/s", "upload", common.ByteCount(stats.UploadRate)+"/s",
)
log.Info(fmt.Sprintf("[%s] download", logPrefix),
"peers", stats.PeersUnique, "peers", stats.PeersUnique,
"connections", stats.ConnectionsTotal,
"files", stats.FilesTotal, "files", stats.FilesTotal,
"connections", stats.ConnectionsTotal,
"alloc", common.ByteCount(m.Alloc), "sys", common.ByteCount(m.Sys), "alloc", common.ByteCount(m.Alloc), "sys", common.ByteCount(m.Sys),
) )
} }