Bandwidth tracking

This commit is contained in:
Ben Adrian Sarmiento
2024-06-25 00:12:53 +02:00
parent e9e31759c1
commit 7fc8a4e0c5
4 changed files with 16 additions and 8 deletions

View File

@@ -220,7 +220,9 @@ func (dl *Downloader) streamFileToResponse(
}
dl.RequestedBytes.Add(reqBytes)
dl.TotalBytes.Add(uint64(n))
log.Debugf("Served %d MB of the requested %d MB of file %s (range=%s)", bToMb(uint64(n)), bToMb(reqBytes), unrestrict.Filename, req.Header.Get("Range"))
if cfg.ShouldLogRequests() {
log.Debugf("Served %d MB of the requested %d MB of file %s (range=%s)", bToMb(uint64(n)), bToMb(reqBytes), unrestrict.Filename, req.Header.Get("Range"))
}
}
func redirect(resp http.ResponseWriter, req *http.Request, url string) {