aboutsummaryrefslogtreecommitdiff
path: root/snapshot.go
diff options
context:
space:
mode:
Diffstat (limited to 'snapshot.go')
-rw-r--r--snapshot.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/snapshot.go b/snapshot.go
index fb17056..63402ea 100644
--- a/snapshot.go
+++ b/snapshot.go
@@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ logger "log"
"net/http"
"os"
"time"
@@ -27,7 +28,7 @@ func snapshot(opts options) error {
return err
}
- fmt.Fprintf(os.Stderr, "INFO: updating metadata file\n")
+ logger.Printf("INFO: updating metadata file\n")
source := metadata.NewHTTPSource(metadata.HTTPSourceOptions{Name: "google"})
msg, sig, md, err := source.Load(ctx)
if err != nil {
@@ -44,7 +45,7 @@ func snapshot(opts options) error {
return err
}
- fmt.Fprintf(os.Stderr, "INFO: updating signed tree heads\n")
+ logger.Printf("INFO: updating signed tree heads\n")
for _, log := range utils.Logs(md) {
id, _ := log.Key.ID()
der, _ := x509.MarshalPKIXPublicKey(log.Key)
@@ -55,7 +56,7 @@ func snapshot(opts options) error {
}
// Fetch next STH
- cli, err := client.New(string(log.URL), &http.Client{}, jsonclient.Options{PublicKeyDER: der, UserAgent: "wip"})
+ cli, err := client.New(string(log.URL), &http.Client{}, jsonclient.Options{PublicKeyDER: der, UserAgent: opts.HTTPAgent})
if err != nil {
return fmt.Errorf("%s: %v", *log.Description, err)
}
@@ -81,7 +82,7 @@ func snapshot(opts options) error {
return fmt.Errorf("%s: %v", *log.Description, err)
}
- fmt.Fprintf(os.Stderr, "INFO: bootstrapped %s at tree size %d\n", *log.Description, nextSTH.TreeSize)
+ logger.Printf("INFO: bootstrapped %s at tree size %d\n", *log.Description, nextSTH.TreeSize)
continue
}
@@ -102,7 +103,7 @@ func snapshot(opts options) error {
return fmt.Errorf("%s: split-view: %s", *log.Description, nextSTHBytes)
}
- fmt.Fprintf(os.Stderr, "INFO: %s is already up-to-date at size %d\n", *log.Description, nextSTH.TreeSize)
+ logger.Printf("INFO: %s is already up-to-date at size %d\n", *log.Description, nextSTH.TreeSize)
continue
}
hashes, err := cli.GetSTHConsistency(ctx, currSTH.TreeSize, nextSTH.TreeSize)
@@ -119,8 +120,7 @@ func snapshot(opts options) error {
if err := os.WriteFile(sthFile, nextSTHBytes, 0644); err != nil {
return fmt.Errorf("%s: %v", *log.Description, err)
}
- fmt.Fprintf(os.Stderr, "INFO: updated %s to tree size %d\n", *log.Description, nextSTH.TreeSize)
+ logger.Printf("INFO: updated %s to tree size %d\n", *log.Description, nextSTH.TreeSize)
}
-
return nil
}