Pretty output (#973)

pretty output
This commit is contained in:
Zachary Rice authored and GitHub committed 2022-09-04 08:58:57 -05:00
1 parent 7d9dd260f4
commit 96eed6aa0f
12 files changed
+134 -15

No files matched your search

+11 -2
View File
@@ -112,14 +112,14 @@ func runDetect(cmd *cobra.Command, args []string) {
// log info about the scan
if err == nil {
log.Info().Msgf("scan completed in %s", time.Since(start))
log.Info().Msgf("scan completed in %s", FormatDuration(time.Since(start)))
if len(findings) != 0 {
log.Warn().Msgf("leaks found: %d", len(findings))
} else {
log.Info().Msg("no leaks found")
}
} else {
log.Warn().Msgf("partial scan completed in %s", time.Since(start))
log.Warn().Msgf("partial scan completed in %s", FormatDuration(time.Since(start)))
if len(findings) != 0 {
log.Warn().Msgf("%d leaks found in partial scan", len(findings))
} else {
@@ -159,3 +159,12 @@ func fileExists(fileName string) bool {
}
return false
}
func FormatDuration(d time.Duration) string {
scale := 100 * time.Second
// look for the max scale that is smaller than d
for scale > d {
scale = scale / 10
}
return d.Round(scale / 100).String()
}