Display bytes written to response instead of size of files being served in logs

This commit is contained in:
Seednode 2023-09-15 15:30:52 -05:00
parent 7d49a86e70
commit 16d1428a52
4 changed files with 7 additions and 9 deletions

View File

@ -11,7 +11,7 @@ import (
) )
const ( const (
ReleaseVersion string = "0.90.1" ReleaseVersion string = "0.90.3"
) )
var ( var (

View File

@ -96,9 +96,7 @@ func serveStaticFile(paths []string, cache *fileCache, errorChannel chan<- error
return return
} }
w.Write(buf) written, _ := w.Write(buf)
fileSize := humanReadableSize(len(buf))
refererUri, err := stripQueryParams(refererToUri(r.Referer())) refererUri, err := stripQueryParams(refererToUri(r.Referer()))
if err != nil { if err != nil {
@ -124,7 +122,7 @@ func serveStaticFile(paths []string, cache *fileCache, errorChannel chan<- error
fmt.Printf("%s | Serve: %s (%s) to %s in %s\n", fmt.Printf("%s | Serve: %s (%s) to %s in %s\n",
startTime.Format(logDate), startTime.Format(logDate),
filePath, filePath,
fileSize, humanReadableSize(written),
realIP(r), realIP(r),
time.Since(startTime).Round(time.Microsecond), time.Since(startTime).Round(time.Microsecond),
) )
@ -296,7 +294,7 @@ func serveMedia(paths []string, regexes *regexes, cache *fileCache, formats *typ
formattedPage := gohtml.Format(htmlBody.String()) formattedPage := gohtml.Format(htmlBody.String())
_, err = io.WriteString(w, formattedPage) written, err := io.WriteString(w, formattedPage)
if err != nil { if err != nil {
errorChannel <- err errorChannel <- err
@ -310,7 +308,7 @@ func serveMedia(paths []string, regexes *regexes, cache *fileCache, formats *typ
fmt.Printf("%s | Serve: %s (%s) to %s in %s\n", fmt.Printf("%s | Serve: %s (%s) to %s in %s\n",
startTime.Format(logDate), startTime.Format(logDate),
path, path,
humanReadableSize(len(formattedPage)), humanReadableSize(written),
realIP(r), realIP(r),
time.Since(startTime).Round(time.Microsecond), time.Since(startTime).Round(time.Microsecond),
) )

View File

@ -222,7 +222,7 @@ func (t Format) Validate(filePath string) bool {
} }
func (t Format) Type() string { func (t Format) Type() string {
return "html" return "inline"
} }
func New(theme string) Format { func New(theme string) Format {

View File

@ -77,7 +77,7 @@ func (t Format) Validate(filePath string) bool {
} }
func (t Format) Type() string { func (t Format) Type() string {
return "html" return "inline"
} }
func New() Format { func New() Format {