From 2816b715439a3472ccf7d78e04d5db3b22952728 Mon Sep 17 00:00:00 2001 From: Andrew Gillis <11790789+gammazero@users.noreply.github.com> Date: Tue, 9 Jul 2024 09:06:15 -0700 Subject: [PATCH] refactor(bitswap): unify logger names (#637) * Unify bitswap logger names Use uniform pattern for logger naming: bitswap/pkgname Slash delimiters are used to separate path segments used in logger names. This follows the conventios used most commonly in other parts of boxo. * Update CHANGELOG --- CHANGELOG.md | 1 + bitswap/client/client.go | 2 +- bitswap/client/internal/getter/getter.go | 2 +- bitswap/client/internal/messagequeue/messagequeue.go | 2 +- bitswap/client/internal/peermanager/peermanager.go | 2 +- .../internal/providerquerymanager/providerquerymanager.go | 2 +- bitswap/client/internal/session/session.go | 2 +- .../client/internal/sessionpeermanager/sessionpeermanager.go | 2 +- bitswap/network/ipfs_impl.go | 2 +- bitswap/server/internal/decision/engine.go | 2 +- bitswap/server/server.go | 2 +- 11 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85176369f..8cf7a40ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The following emojis are used to highlight certain changes: ### Changed - `bitswap/server` minor memory use and performance improvements +- `bitswap` unify logger names to use uniform format bitswap/path/pkgname ### Removed diff --git a/bitswap/client/client.go b/bitswap/client/client.go index aa9ab78fa..0a5bdeb9e 100644 --- a/bitswap/client/client.go +++ b/bitswap/client/client.go @@ -38,7 +38,7 @@ import ( "go.opentelemetry.io/otel/trace" ) -var log = logging.Logger("bitswap-client") +var log = logging.Logger("bitswap/client") // Option defines the functional option type that can be used to configure // bitswap instances diff --git a/bitswap/client/internal/getter/getter.go b/bitswap/client/internal/getter/getter.go index 822d319b7..c03b2aecc 100644 --- a/bitswap/client/internal/getter/getter.go +++ b/bitswap/client/internal/getter/getter.go @@ -13,7 +13,7 @@ import ( ipld "github.com/ipfs/go-ipld-format" ) -var log = logging.Logger("bitswap") +var log = logging.Logger("bitswap/client/getter") // GetBlocksFunc is any function that can take an array of CIDs and return a // channel of incoming blocks. diff --git a/bitswap/client/internal/messagequeue/messagequeue.go b/bitswap/client/internal/messagequeue/messagequeue.go index 4f90f239b..fac72f7cd 100644 --- a/bitswap/client/internal/messagequeue/messagequeue.go +++ b/bitswap/client/internal/messagequeue/messagequeue.go @@ -19,7 +19,7 @@ import ( ) var ( - log = logging.Logger("bitswap") + log = logging.Logger("bitswap/client/msgq") sflog = log.Desugar() ) diff --git a/bitswap/client/internal/peermanager/peermanager.go b/bitswap/client/internal/peermanager/peermanager.go index f26b8fbec..25cdd605f 100644 --- a/bitswap/client/internal/peermanager/peermanager.go +++ b/bitswap/client/internal/peermanager/peermanager.go @@ -11,7 +11,7 @@ import ( peer "github.com/libp2p/go-libp2p/core/peer" ) -var log = logging.Logger("bs:peermgr") +var log = logging.Logger("bitswap/client/peermgr") // PeerQueue provides a queue of messages to be sent for a single peer. type PeerQueue interface { diff --git a/bitswap/client/internal/providerquerymanager/providerquerymanager.go b/bitswap/client/internal/providerquerymanager/providerquerymanager.go index 9bba5211f..ea10a40e5 100644 --- a/bitswap/client/internal/providerquerymanager/providerquerymanager.go +++ b/bitswap/client/internal/providerquerymanager/providerquerymanager.go @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/otel/trace" ) -var log = logging.Logger("bitswap") +var log = logging.Logger("bitswap/client/provqrymgr") const ( maxProviders = 10 diff --git a/bitswap/client/internal/session/session.go b/bitswap/client/internal/session/session.go index b77a82283..6f99dec0e 100644 --- a/bitswap/client/internal/session/session.go +++ b/bitswap/client/internal/session/session.go @@ -20,7 +20,7 @@ import ( ) var ( - log = logging.Logger("bs:sess") + log = logging.Logger("bitswap/session") sflog = log.Desugar() ) diff --git a/bitswap/client/internal/sessionpeermanager/sessionpeermanager.go b/bitswap/client/internal/sessionpeermanager/sessionpeermanager.go index f15be86b4..1832e9c7f 100644 --- a/bitswap/client/internal/sessionpeermanager/sessionpeermanager.go +++ b/bitswap/client/internal/sessionpeermanager/sessionpeermanager.go @@ -9,7 +9,7 @@ import ( peer "github.com/libp2p/go-libp2p/core/peer" ) -var log = logging.Logger("bs:sprmgr") +var log = logging.Logger("bitswap/client/sesspeermgr") const ( // Connection Manager tag value for session peers. Indicates to connection diff --git a/bitswap/network/ipfs_impl.go b/bitswap/network/ipfs_impl.go index 422249952..ac9ab66a6 100644 --- a/bitswap/network/ipfs_impl.go +++ b/bitswap/network/ipfs_impl.go @@ -26,7 +26,7 @@ import ( "github.com/multiformats/go-multistream" ) -var log = logging.Logger("bitswap_network") +var log = logging.Logger("bitswap/network") var connectTimeout = time.Second * 5 diff --git a/bitswap/server/internal/decision/engine.go b/bitswap/server/internal/decision/engine.go index bc934db5a..7114a1a41 100644 --- a/bitswap/server/internal/decision/engine.go +++ b/bitswap/server/internal/decision/engine.go @@ -60,7 +60,7 @@ import ( // whatever it sees fit to produce desired outcomes (get wanted keys // quickly, maintain good relationships with peers, etc). -var log = logging.Logger("engine") +var log = logging.Logger("bitswap/server/decision") const ( // outboxChanBuffer must be 0 to prevent stale messages from being sent diff --git a/bitswap/server/server.go b/bitswap/server/server.go index 1e723ddce..85651a5ef 100644 --- a/bitswap/server/server.go +++ b/bitswap/server/server.go @@ -29,7 +29,7 @@ import ( var provideKeysBufferSize = 2048 var ( - log = logging.Logger("bitswap-server") + log = logging.Logger("bitswap/server") sflog = log.Desugar() )