From e3973b240e6a602fdad0904a9c48966aa389862a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 20 Apr 2026 17:37:01 -0600 Subject: [PATCH] feat(check-ip): print 'Loading X...' before each stage starts Split the stage-timing lines into a pre-stage 'Loading X... ' (shown before the work starts) and a post-stage ' ()'. Makes it obvious something is happening during the ~1s cold-start parse instead of going silent and printing everything at the end. --- cmd/check-ip/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/check-ip/main.go b/cmd/check-ip/main.go index a003531..772cce3 100644 --- a/cmd/check-ip/main.go +++ b/cmd/check-ip/main.go @@ -134,11 +134,13 @@ func main() { repo.FilePath("tables/outbound/networks.txt"), ) }) + fmt.Fprint(os.Stderr, "Loading blocklists... ") t := time.Now() if err := blocklists.Load(context.Background()); err != nil { + fmt.Fprintln(os.Stderr) log.Fatalf("blocklists: %v", err) } - fmt.Fprintf(os.Stderr, "Loading blocklists... %s (inbound=%d, outbound=%d)\n", + fmt.Fprintf(os.Stderr, "%s (inbound=%d, outbound=%d)\n", time.Since(t).Round(time.Millisecond), cfg.inbound.Value().Size(), cfg.outbound.Value().Size(), @@ -176,11 +178,13 @@ func main() { cfg.geo = dataset.Add(geoSet, func() (*geoip.Databases, error) { return geoip.Open(maxmindDir) }) + fmt.Fprint(os.Stderr, "Loading geoip... ") t = time.Now() if err := geoSet.Load(context.Background()); err != nil { + fmt.Fprintln(os.Stderr) log.Fatalf("geoip: %v", err) } - fmt.Fprintf(os.Stderr, "Loading geoip... %s\n", time.Since(t).Round(time.Millisecond)) + fmt.Fprintf(os.Stderr, "%s\n", time.Since(t).Round(time.Millisecond)) defer func() { _ = cfg.geo.Value().Close() }() // Whitelist: combined IPs + CIDRs in one file, polled for mtime changes. @@ -191,11 +195,13 @@ func main() { cfg.whitelist = dataset.Add(whitelistSet, func() (*ipcohort.Cohort, error) { return ipcohort.LoadFile(cfg.WhitelistPath) }) + fmt.Fprint(os.Stderr, "Loading whitelist... ") t = time.Now() if err := whitelistSet.Load(context.Background()); err != nil { + fmt.Fprintln(os.Stderr) log.Fatalf("whitelist: %v", err) } - fmt.Fprintf(os.Stderr, "Loading whitelist... %s (entries=%d)\n", + fmt.Fprintf(os.Stderr, "%s (entries=%d)\n", time.Since(t).Round(time.Millisecond), cfg.whitelist.Value().Size(), )