From c10a9103f959498c360be002b2621e978bb82e19 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Thu, 5 May 2022 22:45:13 +0200 Subject: replace glog with sigsum-go's log package --- pkg/db/trillian.go | 4 ++-- pkg/instance/experimental.go | 4 ++-- pkg/instance/handler.go | 18 +++++++++--------- pkg/state/single.go | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) (limited to 'pkg') diff --git a/pkg/db/trillian.go b/pkg/db/trillian.go index 024a021..3147c8d 100644 --- a/pkg/db/trillian.go +++ b/pkg/db/trillian.go @@ -5,9 +5,9 @@ import ( "fmt" "time" + "git.sigsum.org/sigsum-go/pkg/log" "git.sigsum.org/sigsum-go/pkg/requests" "git.sigsum.org/sigsum-go/pkg/types" - "github.com/golang/glog" "github.com/google/trillian" trillianTypes "github.com/google/trillian/types" "google.golang.org/grpc/codes" @@ -33,7 +33,7 @@ func (c *TrillianClient) AddLeaf(ctx context.Context, req *requests.Leaf) error } serialized := leaf.ToBinary() - glog.V(3).Infof("queueing leaf request: %x", types.LeafHash(serialized)) + log.Debug("queueing leaf request: %x", types.LeafHash(serialized)) rsp, err := c.GRPC.QueueLeaf(ctx, &trillian.QueueLeafRequest{ LogId: c.TreeID, Leaf: &trillian.LogLeaf{ diff --git a/pkg/instance/experimental.go b/pkg/instance/experimental.go index 3db11e9..24feeaf 100644 --- a/pkg/instance/experimental.go +++ b/pkg/instance/experimental.go @@ -11,8 +11,8 @@ import ( "fmt" "net/http" + "git.sigsum.org/sigsum-go/pkg/log" "git.sigsum.org/sigsum-go/pkg/types" - "github.com/golang/glog" ) // algEd25519 identifies a checkpoint signature algorithm @@ -21,7 +21,7 @@ const algEd25519 byte = 1 // getCheckpoint is an experimental endpoint that is not part of the official // Sigsum API. Documentation can be found in the transparency-dev repo. func getCheckpoint(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) { - glog.V(3).Info("handling get-checkpoint request") + log.Debug("handling get-checkpoint request") sth, err := i.Stateman.ToCosignTreeHead(ctx) if err != nil { return http.StatusInternalServerError, err diff --git a/pkg/instance/handler.go b/pkg/instance/handler.go index ecc22e2..fa465ee 100644 --- a/pkg/instance/handler.go +++ b/pkg/instance/handler.go @@ -6,8 +6,8 @@ import ( "net/http" "time" + "git.sigsum.org/sigsum-go/pkg/log" "git.sigsum.org/sigsum-go/pkg/types" - "github.com/golang/glog" ) // Handler implements the http.Handler interface, and contains a reference @@ -72,14 +72,14 @@ func (h Handler) handle(w http.ResponseWriter, r *http.Request) int { code, err := h.Handler(ctx, h.Instance, w, r) if err != nil { - glog.V(3).Infof("%s/%s: %v", h.Instance.Prefix, h.Endpoint, err) + log.Debug("%s/%s: %v", h.Instance.Prefix, h.Endpoint, err) http.Error(w, fmt.Sprintf("error=%s", err.Error()), code) } return code } func addLeaf(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) { - glog.V(3).Info("handling add-entry request") + log.Debug("handling add-leaf request") req, err := i.leafRequestFromHTTP(ctx, r) if err != nil { return http.StatusBadRequest, err @@ -91,7 +91,7 @@ func addLeaf(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Re } func addCosignature(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) { - glog.V(3).Info("handling add-cosignature request") + log.Debug("handling add-cosignature request") req, err := i.cosignatureRequestFromHTTP(r) if err != nil { return http.StatusBadRequest, err @@ -104,7 +104,7 @@ func addCosignature(ctx context.Context, i *Instance, w http.ResponseWriter, r * } func getTreeHeadToCosign(ctx context.Context, i *Instance, w http.ResponseWriter, _ *http.Request) (int, error) { - glog.V(3).Info("handling get-tree-head-to-cosign request") + log.Debug("handling get-tree-head-to-cosign request") sth, err := i.Stateman.ToCosignTreeHead(ctx) if err != nil { return http.StatusInternalServerError, err @@ -116,7 +116,7 @@ func getTreeHeadToCosign(ctx context.Context, i *Instance, w http.ResponseWriter } func getTreeHeadCosigned(ctx context.Context, i *Instance, w http.ResponseWriter, _ *http.Request) (int, error) { - glog.V(3).Info("handling get-tree-head-cosigned request") + log.Debug("handling get-tree-head-cosigned request") cth, err := i.Stateman.CosignedTreeHead(ctx) if err != nil { return http.StatusInternalServerError, err @@ -128,7 +128,7 @@ func getTreeHeadCosigned(ctx context.Context, i *Instance, w http.ResponseWriter } func getConsistencyProof(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) { - glog.V(3).Info("handling get-consistency-proof request") + log.Debug("handling get-consistency-proof request") req, err := i.consistencyProofRequestFromHTTP(r) if err != nil { return http.StatusBadRequest, err @@ -146,7 +146,7 @@ func getConsistencyProof(ctx context.Context, i *Instance, w http.ResponseWriter } func getInclusionProof(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) { - glog.V(3).Info("handling get-proof-by-hash request") + log.Debug("handling get-inclusion-proof request") req, err := i.inclusionProofRequestFromHTTP(r) if err != nil { return http.StatusBadRequest, err @@ -164,7 +164,7 @@ func getInclusionProof(ctx context.Context, i *Instance, w http.ResponseWriter, } func getLeaves(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) { - glog.V(3).Info("handling get-leaves request") + log.Debug("handling get-leaves request") req, err := i.leavesRequestFromHTTP(r) if err != nil { return http.StatusBadRequest, err diff --git a/pkg/state/single.go b/pkg/state/single.go index e1f0e75..695f0e3 100644 --- a/pkg/state/single.go +++ b/pkg/state/single.go @@ -9,8 +9,8 @@ import ( "time" "git.sigsum.org/log-go/pkg/db" + "git.sigsum.org/sigsum-go/pkg/log" "git.sigsum.org/sigsum-go/pkg/types" - "github.com/golang/glog" ) // StateManagerSingle implements a single-instance StateManager @@ -50,7 +50,7 @@ func (sm *StateManagerSingle) Run(ctx context.Context) { rotation := func() { nextSTH, err := sm.latestSTH(ctx) if err != nil { - glog.Warningf("cannot rotate without tree head: %v", err) + log.Warning("cannot rotate without tree head: %v", err) return } sm.rotate(nextSTH) @@ -108,21 +108,21 @@ func (sm *StateManagerSingle) rotate(nextSTH *types.SignedTreeHead) { sm.Lock() defer sm.Unlock() - glog.V(3).Infof("rotating tree heads") + log.Debug("rotating tree heads") sm.handleEvents() sm.setCosignedTreeHead() sm.setToCosignTreeHead(nextSTH) } func (sm *StateManagerSingle) handleEvents() { - glog.V(3).Infof("handling any outstanding events") + log.Debug("handling any outstanding events") for i, n := 0, len(sm.events); i < n; i++ { sm.handleEvent(<-sm.events) } } func (sm *StateManagerSingle) handleEvent(ev *event) { - glog.V(3).Infof("handling event from witness %x", ev.keyHash[:]) + log.Debug("handling event from witness %x", ev.keyHash[:]) sm.cosignatures[*ev.keyHash] = ev.cosignature } -- cgit v1.2.3