Skip to content

Commit

Permalink
Rename LOGGER to logger
Browse files Browse the repository at this point in the history
  • Loading branch information
lahtinep committed Nov 15, 2024
1 parent f53efb2 commit efa3e36
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions posttroll/address_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

__all__ = ("AddressReceiver", "getaddress")

LOGGER = logging.getLogger(__name__)
logger = logging.getLogger(__name__)

debug = os.environ.get("DEBUG", False)

Expand Down Expand Up @@ -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):
Expand All @@ -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:
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit efa3e36

Please sign in to comment.