Log accesses to /_/stats and reduce verbosity of GenerateCache()

This commit is contained in:
Seednode 2023-01-21 16:37:32 -06:00
parent 66f6069d96
commit 04d253c1e6
2 changed files with 13 additions and 3 deletions

View File

@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var Version = "0.33.2" var Version = "0.33.3"
func init() { func init() {
rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(versionCmd)

View File

@ -86,7 +86,6 @@ func (i *Index) GenerateCache(args []string) {
i.List = []string{} i.List = []string{}
i.Mutex.Unlock() i.Mutex.Unlock()
fmt.Printf("%v | Preparing image cache...\n", time.Now().Format(LogDate))
getFileList(args, &Filters{}, "", i) getFileList(args, &Filters{}, "", i)
} }
@ -446,12 +445,23 @@ func serveStatsHandler(args []string, stats *ServeStats) http.HandlerFunc {
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
startTime := time.Now()
response, err := stats.ListImages() response, err := stats.ListImages()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
w.Write([]byte(response)) w.Write(response)
if Verbose {
fmt.Printf("%v | Served statistics page (%v) to %v in %v\n",
startTime.Format(LogDate),
humanReadableSize(len(response)),
getRealIp(r),
time.Since(startTime).Round(time.Microsecond),
)
}
} }
} }