-
Notifications
You must be signed in to change notification settings - Fork 190
fix: standardize logger names in core modules (phase 1) #1119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: standardize logger names in core modules (phase 1) #1119
Conversation
|
Thanks @parth-soni07 for this PR. Findings
RecommendationCan you add a newsfragment file ( |
hey @acul71 , thanks for the feedback, I have added the newsfragment in the PR now. I think for the rest we are good to go! |
|
It looks like this handles everything that was touched in #902 . Can that one be closed once this is merged? Searching for We can also close #84 once this merges. |
|
@pacrob : Thank you so much for your review, inputs and feedback. Appreciate it 👍 Yes — this PR is intended to cover everything touched in #902, so we can definitely close that once this is merged. Did discuss in detail with @parth-soni07 before he started working on this PR. Great catch on the remaining logging.getLogger usages, especially in kad_dht. There’s no strong reason to leave those out. @parth-soni07 : Wish if you could completed the feedback points shared by @pacrob in this PR as well so we end up fully consistent. Appreciate your efforts. Wish to also share that @acul71 and @sumanjeet0012 are in favor of consolidating everything here in this PR. @pacrob : +1, Agreed on closing #84 as well once this lands. Thanks for the careful review. Appreciate your great support. |
|
Hey @pacrob, thanks for the feedback, yes I do have a plan for phase 2 or we can include those changes in this PR as well if you approve as there are some cases including the Logger Standardization: Special CasesCore ObjectiveWe've standardized 31 core modules to use Quick Summary
Total Files to Update: 9 source files + 4 dependent files (if standardizing) 1. Example Loggers (7 files)Current Logger Names
Where These Are Usedkademlia-example. loggers:*
pubsub-example.utils:
What Changes If We StandardizeSource Files (7 files): # Change from:
logger = logging.getLogger("kademlia-example.kad_dht")
# To:
logger = logging.getLogger(__name__) # "libp2p.kad_dht.kad_dht"Dependent Files (need updates):
Questions for Decision
2. Records Validator (1 file)Current Logger Name
What's WrongProblems with current logger name:
Note: The logger is defined but not currently used in the file (no What Changes If We StandardizeSource File (1 file): # Change from:
logger = logging.getLogger("records-validator")
# To:
logger = logging.getLogger(__name__) # "libp2p.records.validator"Result:
Dependent Files:
Questions for Decision
3. Async Service Manager (1 file)Current Logger Name
Where This Is Used
What Changes If We StandardizeSource File (1 file): Option A: Keep class-level, fix name # Change from:
logger = logging.getLogger("async_service.Manager")
# To:
logger = logging.getLogger(f"{__name__}.Manager") # "libp2p.tools.async_service.base.Manager"
# OR
logger = logging.getLogger("libp2p.tools.async_service.Manager")Option B: Move to module-level # At module level:
logger = logging.getLogger(__name__) # "libp2p.tools.async_service.base"
# Use in class: logger.debug(...) instead of self.logger.debug(...)Dependent Files (need updates):
Questions for Decision
Summary: What Needs to Be UpdatedIf We Standardize Everything:Source Files (9 files):
Dependent Files (4 files):
Total: 13 files (9 source + 4 dependent) Next StepsOnce I get feedback on the 3 questions above I'll update all files accordingly. |
What was wrong?
Fix logging standardization in core modules (Phase 1)
Issue #906
Changes
Network & Host (4 files)
libp2p/network/swarm.pylibp2p/host/basic_host.pylibp2p/host/ping.pylibp2p/host/autonat/autonat.pyTransport & Stream Muxer (6 files)
libp2p/transport/tcp/tcp.pylibp2p/transport/websocket/listener.pylibp2p/transport/websocket/autotls.pylibp2p/transport/transport_registry.pylibp2p/stream_muxer/yamux/yamux.pylibp2p/stream_muxer/mplex/mplex.pyPubsub (4 files)
libp2p/pubsub/pubsub.pylibp2p/pubsub/floodsub.pylibp2p/pubsub/gossipsub.pylibp2p/pubsub/validators.pyRelay Circuit v2 (5 files)
libp2p/relay/circuit_v2/transport.pylibp2p/relay/circuit_v2/protocol.pylibp2p/relay/circuit_v2/discovery.pylibp2p/relay/circuit_v2/utils.pylibp2p/relay/circuit_v2/nat.pyDiscovery (8 files)
libp2p/discovery/bootstrap/bootstrap.pylibp2p/discovery/bootstrap/utils.pylibp2p/discovery/mdns/mdns.pylibp2p/discovery/mdns/listener.pylibp2p/discovery/mdns/broadcaster.pylibp2p/discovery/random_walk/random_walk.pylibp2p/discovery/random_walk/rt_refresh_manager.pylibp2p/discovery/upnp/upnp.pyProtocol Muxer (1 file)
libp2p/protocol_muxer/multiselect_client.pyUtils & IO (3 files)
libp2p/io/trio.pylibp2p/utils/version.pylibp2p/utils/varint.pyTest Files Created (1 file)
tests/utils/test_logger_standardization.pyChange Summary
Total Files Changed: 32 files (31 source files + 1 test file)
Change Pattern
Before:
After:
Benefits
Testing
A comprehensive test suite was created in
tests/utils/test_logger_standardization.pythat verifies: