Replace root logger calls with module-specific loggers

This commit is contained in:
Ian Renton
2026-08-15 08:35:06 +01:00
parent 74bcd9cded
commit dd89ff4af7
64 changed files with 328 additions and 216 deletions
+12 -10
View File
@@ -16,6 +16,8 @@ from providers.callsigndata.api_query_callsign_data_provider import (
APIQueryCallsignDataProvider,
)
logger = logging.getLogger(__name__)
class QRZ(APIQueryCallsignDataProvider):
"""Callsign data provider for QRZ.com."""
@@ -53,10 +55,10 @@ class QRZ(APIQueryCallsignDataProvider):
session_key = str(session["Key"])
else:
# Log this failure at debug level only, not our problem if user entered the wrong password.
logging.debug("QRZ.com login details incorrect, failed to look up with QRZ.")
logger.debug("QRZ.com login details incorrect, failed to look up with QRZ.")
return None
except Exception:
logging.error("Exception when getting QRZ.com session key")
logger.error("Exception when getting QRZ.com session key")
return None
if not session_key:
@@ -69,7 +71,7 @@ class QRZ(APIQueryCallsignDataProvider):
if home_call != callsign:
calls_to_try.append(home_call)
except ValueError:
logging.debug(f"Could not look up home call for callsign {callsign}")
logger.debug(f"Could not look up home call for callsign {callsign}")
# Try looking up each call using the API
for lookup_call in calls_to_try:
@@ -93,25 +95,25 @@ class QRZ(APIQueryCallsignDataProvider):
elif "Session" in qrz_response and "Error" in qrz_response.get("Session"):
# Errors here are normally just "callsign not in database", no need to log that ourselves
# above debug level.
logging.debug(
logger.debug(
f"QRZ returned an error looking up callsign {lookup_call}: {qrz_response.get('Session').get('Error')}"
)
elif not response.from_cache:
logging.warning(f"QRZ returned a malformed response looking up callsign {lookup_call}")
logger.warning(f"QRZ returned a malformed response looking up callsign {lookup_call}")
elif not response.from_cache:
logging.warning(f"HTTP {response.status_code} looking up callsign {lookup_call} using QRZ")
logger.warning(f"HTTP {response.status_code} looking up callsign {lookup_call} using QRZ")
except (KeyError, ValueError):
continue
except ConnectionError:
logging.warning(f"Connection error when looking up callsign {lookup_call} using QRZ")
logger.warning(f"Connection error when looking up callsign {lookup_call} using QRZ")
continue
except (ConnectTimeout, ReadTimeout):
logging.warning(f"Timeout when looking up callsign {lookup_call} using QRZ.")
logger.warning(f"Timeout when looking up callsign {lookup_call} using QRZ.")
continue
except Exception:
logging.exception(f"Exception when looking up callsign {lookup_call} using QRZ")
logger.exception(f"Exception when looking up callsign {lookup_call} using QRZ")
continue
# Not found in QRZ; return a Callsign object with no data so we cache that and don't keep retrying
@@ -119,7 +121,7 @@ class QRZ(APIQueryCallsignDataProvider):
except Exception:
self.status = "Error"
logging.exception("Exception when looking up data from QRZ.com")
logger.exception("Exception when looking up data from QRZ.com")
# Return None, this won't be cached so we will be asked to query data again for this call next time.
return None