Display time spent displaying image when running in verbose mode
This commit is contained in:
parent
35b46ed9e8
commit
de398093b5
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "0.4.2"
|
var Version = "0.5.0"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(versionCmd)
|
rootCmd.AddCommand(versionCmd)
|
||||||
|
|
|
@ -94,8 +94,12 @@ func serveStaticFile(w http.ResponseWriter, r http.Request, paths []string) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var startTime time.Time
|
||||||
|
var stopTime time.Time
|
||||||
|
|
||||||
if Verbose {
|
if Verbose {
|
||||||
fmt.Printf("%v Serving file: %v", time.Now().Format(LOGDATE), filePath)
|
fmt.Printf("%v Serving file: %v", time.Now().Format(LOGDATE), filePath)
|
||||||
|
startTime = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := os.ReadFile(filePath)
|
buf, err := os.ReadFile(filePath)
|
||||||
|
@ -106,7 +110,9 @@ func serveStaticFile(w http.ResponseWriter, r http.Request, paths []string) erro
|
||||||
w.Write(buf)
|
w.Write(buf)
|
||||||
|
|
||||||
if Verbose {
|
if Verbose {
|
||||||
fmt.Println(" - DONE")
|
stopTime = time.Now()
|
||||||
|
timeElapsed := stopTime.Sub(startTime).Round(time.Microsecond)
|
||||||
|
fmt.Printf("%v %v\n", " - Finished in", timeElapsed)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue