From e604a3d749be413a35e2cb44d5ee29b33eb9db66 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 14 Aug 2023 14:08:18 +0300 Subject: [PATCH] [#607] *: Use zap.Stringer() where possible Semantic patch: ``` @@ var f expression var t expression var a expression @@ f( ..., - zap.String(t, a.String()), + zap.Stringer(t, a), ..., ) ``` Signed-off-by: Evgenii Stratonikov --- cmd/frostfs-node/grpc.go | 4 ++-- pkg/innerring/processors/frostfs/process_assets.go | 2 +- pkg/local_object_storage/engine/remove_copies.go | 2 +- pkg/local_object_storage/shard/id.go | 2 +- pkg/services/tree/signature.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/frostfs-node/grpc.go b/cmd/frostfs-node/grpc.go index 10d387b1..42059ec0 100644 --- a/cmd/frostfs-node/grpc.go +++ b/cmd/frostfs-node/grpc.go @@ -104,14 +104,14 @@ func serveGRPC(c *cfg) { go func() { defer func() { c.log.Info(logs.FrostFSNodeStopListeningGRPCEndpoint, - zap.String("endpoint", lis.Addr().String()), + zap.Stringer("endpoint", lis.Addr()), ) c.wg.Done() }() c.log.Info(logs.FrostFSNodeStartListeningGRPCEndpoint, - zap.String("endpoint", lis.Addr().String()), + zap.Stringer("endpoint", lis.Addr()), ) if err := srv.Serve(lis); err != nil { diff --git a/pkg/innerring/processors/frostfs/process_assets.go b/pkg/innerring/processors/frostfs/process_assets.go index 327a4a3a..c72aecee 100644 --- a/pkg/innerring/processors/frostfs/process_assets.go +++ b/pkg/innerring/processors/frostfs/process_assets.go @@ -45,7 +45,7 @@ func (np *Processor) processDeposit(deposit frostfsEvent.Deposit) bool { val, ok := np.mintEmitCache.Get(receiver.String()) if ok && val+np.mintEmitThreshold >= curEpoch { np.log.Warn(logs.FrostFSDoubleMintEmissionDeclined, - zap.String("receiver", receiver.String()), + zap.Stringer("receiver", receiver), zap.Uint64("last_emission", val), zap.Uint64("current_epoch", curEpoch)) diff --git a/pkg/local_object_storage/engine/remove_copies.go b/pkg/local_object_storage/engine/remove_copies.go index 4b48d179..57315326 100644 --- a/pkg/local_object_storage/engine/remove_copies.go +++ b/pkg/local_object_storage/engine/remove_copies.go @@ -55,7 +55,7 @@ func (e *StorageEngine) RemoveDuplicates(ctx context.Context, prm RemoveDuplicat // This is not currently the case, because `FreeSpace` metric used by weight sorting is always 0. // However we could change weights in future and easily forget this function. for _, sh := range e.shards { - e.log.Debug(logs.EngineStartedDuplicatesRemovalRoutine, zap.String("shard_id", sh.ID().String())) + e.log.Debug(logs.EngineStartedDuplicatesRemovalRoutine, zap.Stringer("shard_id", sh.ID())) ch := make(chan oid.Address) errG, ctx := errgroup.WithContext(ctx) diff --git a/pkg/local_object_storage/shard/id.go b/pkg/local_object_storage/shard/id.go index e2ac423f..49f9a304 100644 --- a/pkg/local_object_storage/shard/id.go +++ b/pkg/local_object_storage/shard/id.go @@ -49,7 +49,7 @@ func (s *Shard) UpdateID() (err error) { } } - s.log = &logger.Logger{Logger: s.log.With(zap.String("shard_id", s.info.ID.String()))} + s.log = &logger.Logger{Logger: s.log.With(zap.Stringer("shard_id", s.info.ID))} s.metaBase.SetLogger(s.log) s.blobStor.SetLogger(s.log) if s.hasWriteCache() { diff --git a/pkg/services/tree/signature.go b/pkg/services/tree/signature.go index 7a466955..6dad2277 100644 --- a/pkg/services/tree/signature.go +++ b/pkg/services/tree/signature.go @@ -89,7 +89,7 @@ func (s *Service) verifyClient(req message, cid cidSDK.ID, rawBearer []byte, op if !basicACL.AllowedBearerRules(op) { s.log.Debug(logs.TreeBearerPresentedButNotAllowedByACL, zap.String("cid", cid.EncodeToString()), - zap.String("op", op.String()), + zap.Stringer("op", op), ) } else { useBearer = true