From 72512b503387e6825cd33b77b82c90b1ecdc7634 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Thu, 10 Mar 2022 13:28:41 +0000 Subject: [PATCH] Clearer logging for createAndInitTree Signed-off-by: Priya Wadhwa --- pkg/api/api.go | 2 +- pkg/api/trillian_client.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index 0b464800b..3755f21b9 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -80,12 +80,12 @@ func NewAPI(ranges sharding.LogRanges) (*API, error) { tLogID := viper.GetInt64("trillian_log_server.tlog_id") if tLogID == 0 { + log.Logger.Info("No tree ID specified, attempting to intitialize one") t, err := createAndInitTree(ctx, logAdminClient, logClient) if err != nil { return nil, errors.Wrap(err, "create and init tree") } tLogID = t.TreeId - log.Logger.Infof("Creating new tree with ID: %v", t.TreeId) } // append the active treeID to the API's logRangeMap for lookups ranges.Ranges = append(ranges.Ranges, sharding.LogRange{TreeID: tLogID}) diff --git a/pkg/api/trillian_client.go b/pkg/api/trillian_client.go index d570d08eb..e3a4f7a6b 100644 --- a/pkg/api/trillian_client.go +++ b/pkg/api/trillian_client.go @@ -330,6 +330,7 @@ func createAndInitTree(ctx context.Context, adminClient trillian.TrillianAdminCl } } + log.Logger.Infof("No existing tree found, attempting to create a new one") // Otherwise create and initialize one t, err := adminClient.CreateTree(ctx, &trillian.CreateTreeRequest{ Tree: &trillian.Tree{ @@ -345,5 +346,6 @@ func createAndInitTree(ctx context.Context, adminClient trillian.TrillianAdminCl if err := client.InitLog(ctx, t, logClient); err != nil { return nil, errors.Wrap(err, "init log") } + log.Logger.Infof("Created new tree with ID: %v", t.TreeId) return t, nil }