Skip to content

Commit

Permalink
Improve exception logging in context functions
Browse files Browse the repository at this point in the history
Observing programming errors happening within the `is_filtered`,
`get_topic_data`, and `get_all_data` functions, and their callees, was
painful. Let's be more verbose now.
  • Loading branch information
amotl committed Apr 12, 2023
1 parent 58f716d commit c258840
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ in progress
===========

- Fix: Don't crash when receiving non-UTF8 payloads. Thanks, @sevmonster.
- Improve exception logging in ``is_filtered``, ``get_topic_data``, and
``get_all_data`` context functions. Thanks, @sevmonster.


2023-04-11 0.33.0
Expand Down
6 changes: 3 additions & 3 deletions mqttwarn/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def is_filtered(self, section, topic, payload):
try:
return self.invoker.filter(filterfunc, topic, payload, section)
except Exception as e:
logger.warning("Cannot invoke filter function '%s' defined in '%s': %s" % (filterfunc, section, e))
logger.exception("Cannot invoke filter function '%s' defined in '%s': %s" % (filterfunc, section, e))
return False

def get_topic_data(self, section, topic):
Expand All @@ -71,7 +71,7 @@ def get_topic_data(self, section, topic):
try:
return self.invoker.datamap(name, topic)
except Exception as e:
logger.warning("Cannot invoke datamap function '%s' defined in '%s': %s" % (name, section, e))
logger.exception("Cannot invoke datamap function '%s' defined in '%s': %s" % (name, section, e))
return None

def get_all_data(self, section, topic, data):
Expand All @@ -80,7 +80,7 @@ def get_all_data(self, section, topic, data):
try:
return self.invoker.alldata(name, topic, data)
except Exception as e:
logger.warning("Cannot invoke alldata function '%s' defined in '%s': %s" % (name, section, e))
logger.exception("Cannot invoke alldata function '%s' defined in '%s': %s" % (name, section, e))
return None

def get_topic_targets(self, section, topic, data):
Expand Down

0 comments on commit c258840

Please sign in to comment.