From 99516a03cf9827e54b262f1c755e834ee1b17662 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 13 Mar 2026 17:33:18 -0700 Subject: [PATCH] fix: restore removed log.Info messages and add info-level logging at key milestones Restore four log.Info messages removed during refactor in verify.go: - Downloading manifest (with path) - Manifest loaded (with blob count and total size) - Downloading encrypted database (with path) - Database loaded (with blob count and total size) Also replaced IIFE for totalSize computation with a local variable. Add info-level logging at key operational milestones: - info.go: log start and completion of remote info gathering - snapshot.go: log snapshot completion with key stats - snapshot.go: log start of ListSnapshots operation --- internal/vaultik/info.go | 7 +++++++ internal/vaultik/snapshot.go | 9 +++++++++ internal/vaultik/verify.go | 23 +++++++++++++++-------- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/internal/vaultik/info.go b/internal/vaultik/info.go index ab3343b..124fc7b 100644 --- a/internal/vaultik/info.go +++ b/internal/vaultik/info.go @@ -149,6 +149,7 @@ type RemoteInfoResult struct { // RemoteInfo displays information about remote storage func (v *Vaultik) RemoteInfo(jsonOutput bool) error { + log.Info("Starting remote storage info gathering") result := &RemoteInfoResult{} storageInfo := v.Storage.Info() @@ -180,6 +181,12 @@ func (v *Vaultik) RemoteInfo(jsonOutput bool) error { return err } + log.Info("Remote info complete", + "snapshots", result.TotalMetadataCount, + "total_blobs", result.TotalBlobCount, + "referenced_blobs", result.ReferencedBlobCount, + "orphaned_blobs", result.OrphanedBlobCount) + if jsonOutput { enc := json.NewEncoder(v.Stdout) enc.SetIndent("", " ") diff --git a/internal/vaultik/snapshot.go b/internal/vaultik/snapshot.go index 2943e6a..6943cd8 100644 --- a/internal/vaultik/snapshot.go +++ b/internal/vaultik/snapshot.go @@ -164,6 +164,14 @@ func (v *Vaultik) createNamedSnapshot(opts *SnapshotCreateOptions, hostname, sna return err } + log.Info("Snapshot complete", + "snapshot_id", snapshotID, + "name", snapName, + "files", stats.totalFiles, + "blobs_uploaded", stats.totalBlobsUploaded, + "bytes_uploaded", stats.totalBytesUploaded, + "duration", time.Since(snapshotStartTime)) + v.printSnapshotSummary(snapshotID, snapshotStartTime, stats) return nil } @@ -359,6 +367,7 @@ func (v *Vaultik) getSnapshotBlobSizes(snapshotID string) (compressed int64, unc // ListSnapshots lists all snapshots func (v *Vaultik) ListSnapshots(jsonOutput bool) error { + log.Info("Listing snapshots") remoteSnapshots, err := v.listRemoteSnapshotIDs() if err != nil { return err diff --git a/internal/vaultik/verify.go b/internal/vaultik/verify.go index a4c8f8a..b5f5a49 100644 --- a/internal/vaultik/verify.go +++ b/internal/vaultik/verify.go @@ -107,10 +107,11 @@ func (v *Vaultik) RunDeepVerify(snapshotID string, opts *VerifyOptions) error { // loadVerificationData downloads manifest, database, and blob list for verification func (v *Vaultik) loadVerificationData(snapshotID string, opts *VerifyOptions, result *VerifyResult) (*snapshot.Manifest, *tempDB, []snapshot.BlobInfo, error) { // Download manifest + manifestPath := fmt.Sprintf("metadata/%s/manifest.json.zst", snapshotID) + log.Info("Downloading manifest", "path", manifestPath) if !opts.JSON { v.printfStdout("Downloading manifest...\n") } - manifestPath := fmt.Sprintf("metadata/%s/manifest.json.zst", snapshotID) manifestReader, err := v.Storage.Get(v.ctx, manifestPath) if err != nil { return nil, nil, nil, v.deepVerifyFailure(result, opts, @@ -126,6 +127,9 @@ func (v *Vaultik) loadVerificationData(snapshotID string, opts *VerifyOptions, r fmt.Errorf("failed to decode manifest: %w", err)) } + log.Info("Manifest loaded", + "manifest_blob_count", manifest.BlobCount, + "manifest_total_size", humanize.Bytes(uint64(manifest.TotalCompressedSize))) if !opts.JSON { v.printfStdout("Manifest loaded: %d blobs (%s)\n", manifest.BlobCount, humanize.Bytes(uint64(manifest.TotalCompressedSize))) v.printfStdout("Downloading and decrypting database...\n") @@ -133,6 +137,7 @@ func (v *Vaultik) loadVerificationData(snapshotID string, opts *VerifyOptions, r // Download and decrypt database dbPath := fmt.Sprintf("metadata/%s/db.zst.age", snapshotID) + log.Info("Downloading encrypted database", "path", dbPath) dbReader, err := v.Storage.Get(v.ctx, dbPath) if err != nil { return nil, nil, nil, v.deepVerifyFailure(result, opts, @@ -156,14 +161,16 @@ func (v *Vaultik) loadVerificationData(snapshotID string, opts *VerifyOptions, r fmt.Errorf("failed to get blobs from database: %w", err)) } + var dbTotalSize int64 + for _, b := range dbBlobs { + dbTotalSize += b.CompressedSize + } + + log.Info("Database loaded", + "db_blob_count", len(dbBlobs), + "db_total_size", humanize.Bytes(uint64(dbTotalSize))) if !opts.JSON { - v.printfStdout("Database loaded: %d blobs (%s)\n", len(dbBlobs), humanize.Bytes(uint64(func() int64 { - var s int64 - for _, b := range dbBlobs { - s += b.CompressedSize - } - return s - }()))) + v.printfStdout("Database loaded: %d blobs (%s)\n", len(dbBlobs), humanize.Bytes(uint64(dbTotalSize))) } return manifest, tdb, dbBlobs, nil