From efa3e36aa603dfe909dbf464b4b8458f0d850307 Mon Sep 17 00:00:00 2001 From: Panu Lahtinen Date: Fri, 15 Nov 2024 12:51:59 +0200 Subject: [PATCH] Rename LOGGER to logger --- posttroll/address_receiver.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/posttroll/address_receiver.py b/posttroll/address_receiver.py index 42c0d4c..689410b 100644 --- a/posttroll/address_receiver.py +++ b/posttroll/address_receiver.py @@ -44,7 +44,7 @@ __all__ = ("AddressReceiver", "getaddress") -LOGGER = logging.getLogger(__name__) +logger = logging.getLogger(__name__) debug = os.environ.get("DEBUG", False) @@ -123,7 +123,7 @@ def get(self, name=""): mda = copy.copy(metadata) mda["receive_time"] = mda["receive_time"].isoformat() addrs.append(mda) - LOGGER.debug("return address %s", str(addrs)) + logger.debug("return address %s", str(addrs)) return addrs def _check_age(self, pub, min_interval=zero_seconds): @@ -132,7 +132,7 @@ def _check_age(self, pub, min_interval=zero_seconds): if (now - self._last_age_check) <= min_interval: return - LOGGER.debug("%s - checking addresses", str(dt.datetime.utcnow())) + logger.debug("%s - checking addresses", str(dt.datetime.utcnow())) self._last_age_check = now to_del = [] with self._address_lock: @@ -144,7 +144,7 @@ def _check_age(self, pub, min_interval=zero_seconds): "service": metadata["service"]} msg = Message("/address/" + metadata["name"], "info", mda) to_del.append(addr) - LOGGER.info(f"publish remove '{msg}'") + logger.info(f"publish remove '{msg}'") pub.send(str(msg.encode())) for addr in to_del: del self._addresses[addr] @@ -164,7 +164,7 @@ def _run(self): except TimeoutError: if self._do_run: if self._multicast_enabled: - LOGGER.debug("Multicast socket timed out on recv!") + logger.debug("Multicast socket timed out on recv!") continue else: raise @@ -178,9 +178,9 @@ def _run(self): ip_, port = fromaddr if self._restrict_to_localhost and ip_ not in self._local_ips: # discard external message - LOGGER.debug("Discard external message") + logger.debug("Discard external message") continue - LOGGER.debug("data %s", data) + logger.debug("data %s", data) msg = Message.decode(data) name = msg.subject.split("/")[1] if msg.type == "info" and msg.subject.lower().startswith(self._subject): @@ -189,10 +189,10 @@ def _run(self): metadata = copy.copy(msg.data) metadata["name"] = name - LOGGER.debug("receiving address %s %s %s", str(addr), + logger.debug("receiving address %s %s %s", str(addr), str(name), str(metadata)) if addr not in self._addresses: - LOGGER.info("nameserver: publish add '%s'", + logger.info("nameserver: publish add '%s'", str(msg)) pub.send(msg.encode()) self._add(addr, metadata) @@ -209,7 +209,7 @@ def set_up_address_receiver(self, port): recv = MulticastReceiver(port) except IOError as err: if err.errno == errno.ENODEV: - LOGGER.error("Receiver initialization failed " + logger.error("Receiver initialization failed " "(no such device). " "Trying again in %d s", 10) @@ -218,7 +218,7 @@ def set_up_address_receiver(self, port): raise else: recv.settimeout(tout=2.0) - LOGGER.info("Receiver initialized.") + logger.info("Receiver initialized.") break else: