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)
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)),
"download-time-left", downloadTimeLeft,
"total-download-time", time.Since(downloadStartTime).Round(time.Second).String(),
"time-left", downloadTimeLeft,
"total-time", time.Since(downloadStartTime).Round(time.Second).String(),
"download", common.ByteCount(stats.DownloadRate)+"/s",
"upload", common.ByteCount(stats.UploadRate)+"/s",
)
log.Info(fmt.Sprintf("[%s] download", logPrefix),
"peers", stats.PeersUnique,
"connections", stats.ConnectionsTotal,
"files", stats.FilesTotal,
"connections", stats.ConnectionsTotal,
"alloc", common.ByteCount(m.Alloc), "sys", common.ByteCount(m.Sys),
)
}