Skip to content

Commit

Permalink
fix(subsys/broker): write errors using the error logging level
Browse files Browse the repository at this point in the history
  • Loading branch information
guendto committed Oct 3, 2021
1 parent 9ed3d5c commit b25a06f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/jomiel/subsys/broker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,22 @@
from zmq import ZMQError


def log(text, msgtype="debug"):
"""Write a new (debug) entry to the logger."""
def _log(text, msgtype):
"""Write a new entry to the logger."""
logger = getattr(lg(), msgtype)
logger("subsystem/broker: %s", text)


def log(text):
"""Write a new "debug" entry to the logger."""
_log(text, "debug")


def log_error(text):
"""Write a new "error" entry to the logger."""
_log(text, "error")


def init():
"""Initiates the broker."""

Expand All @@ -41,7 +51,7 @@ def bind_endpoint(device, endpoint, setup_curve=False):
try:
sck.bind(endpoint)
except ZMQError as error:
log(f"{error}: {endpoint}")
log_error(f"{error}: {endpoint}")
exit_error()
return (sck, auth)

Expand Down Expand Up @@ -91,9 +101,9 @@ def start_workers():
try:
proxy(router, dealer)
except KeyboardInterrupt:
log("<sigint> signal interrupt")
log_error("<sigint> signal interrupt")
except ZMQError as error:
log(error)
log_error(error)
finally:
dealer.close()
router.close()
Expand Down

0 comments on commit b25a06f

Please sign in to comment.