-
Notifications
You must be signed in to change notification settings - Fork 287
chore: Replace print statements with logger #2452
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| import secrets | ||
| import time | ||
| from typing import Any | ||
|
|
@@ -15,6 +16,9 @@ | |
| from hiero_sdk_python.node import _Node | ||
|
|
||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class Network: | ||
| """Manages the network configuration for connecting to the Hedera network.""" | ||
|
|
||
|
|
@@ -188,7 +192,7 @@ def _fetch_nodes_from_mirror_node(self) -> list[_Node]: | |
| """ | ||
| base_url: str | None = self.MIRROR_NODE_URLS.get(self.network) | ||
| if not base_url: | ||
| print(f"No known mirror node URL for network='{self.network}'. Skipping fetch.") | ||
| logger.warning("No known mirror node URL for network='%s'. Skipping fetch.", self.network) | ||
| return [] | ||
|
|
||
| url: str = f"{base_url}/api/v1/network/nodes?limit=100&order=desc" | ||
|
|
@@ -209,7 +213,10 @@ def _fetch_nodes_from_mirror_node(self) -> list[_Node]: | |
|
|
||
| return nodes | ||
| except requests.RequestException as e: | ||
| print(f"Error fetching nodes from mirror node API: {e}") | ||
| logger.error("Error fetching nodes from mirror node API: %s", e) | ||
| return [] | ||
|
Comment on lines
215
to
+217
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win MINOR — Preserve traceback context for mirror-node request failures. This branch logs only |
||
| except (ValueError, KeyError, TypeError, IndexError, AttributeError) as e: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can just fall back to a generic
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This problem comes from NodeAddress._from_dict, where missing keys pass None thus you get the variety of type erorrs/attribute errors/etc |
||
| logger.error("Error parsing mirror node API response: %s", e, exc_info=True) | ||
| return [] | ||
|
|
||
| def _fetch_nodes_from_default_nodes(self) -> list[_Node]: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.