diff options
author | Philipp Hörist <philipp@hoerist.com> | 2019-02-02 19:04:13 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2019-02-02 19:31:12 +0300 |
commit | 40ff2a82fffb708da1b0e5cb916b680dba0667ea (patch) | |
tree | ddc61d4dc0faa876edd0fa232a486d9cf9d7fba0 /nbxmpp/modules | |
parent | 45b02fd2e2de462bad0a8857d8df23e7e8fbe1a4 (diff) |
Improve pubsub event logging
Diffstat (limited to 'nbxmpp/modules')
-rw-r--r-- | nbxmpp/modules/activity.py | 9 | ||||
-rw-r--r-- | nbxmpp/modules/location.py | 9 | ||||
-rw-r--r-- | nbxmpp/modules/mood.py | 9 | ||||
-rw-r--r-- | nbxmpp/modules/nickname.py | 5 | ||||
-rw-r--r-- | nbxmpp/modules/tune.py | 9 |
5 files changed, 24 insertions, 17 deletions
diff --git a/nbxmpp/modules/activity.py b/nbxmpp/modules/activity.py index 3b4f289..f2143e6 100644 --- a/nbxmpp/modules/activity.py +++ b/nbxmpp/modules/activity.py @@ -49,7 +49,8 @@ class Activity: activity_node = item.getTag('activity', namespace=NS_ACTIVITY) if not activity_node.getChildren(): - data = properties.pubsub_event._replace(empty=True) + pubsub_event = properties.pubsub_event._replace(empty=True) + log.info('Received activity: %s - no activity set', properties.jid) else: activity, subactivity, text = None, None, None for child in activity_node.getChildren(): @@ -66,10 +67,10 @@ class Activity: raise NodeProcessed data = ActivityData(activity, subactivity, text) - data = properties.pubsub_event._replace(data=data) + pubsub_event = properties.pubsub_event._replace(data=data) + log.info('Received activity: %s - %s', properties.jid, data) - log.info('Received activity: %s - %s', properties.jid, data) - properties.pubsub_event = data + properties.pubsub_event = pubsub_event @staticmethod def _parse_sub_activity(activity): diff --git a/nbxmpp/modules/location.py b/nbxmpp/modules/location.py index fd0959d..0d87775 100644 --- a/nbxmpp/modules/location.py +++ b/nbxmpp/modules/location.py @@ -48,16 +48,17 @@ class Location: location_node = item.getTag('geoloc', namespace=NS_LOCATION) if not location_node.getChildren(): - data = properties.pubsub_event._replace(empty=True) + pubsub_event = properties.pubsub_event._replace(empty=True) + log.info('Received location: %s - no location set', properties.jid) else: location_dict = {} for node in LOCATION_DATA: location_dict[node] = location_node.getTagData(node) data = LocationData(**location_dict) - data = properties.pubsub_event._replace(data=data) + pubsub_event = properties.pubsub_event._replace(data=data) + log.info('Received location: %s - %s', properties.jid, data) - log.info('Received location: %s - %s', properties.jid, data) - properties.pubsub_event = data + properties.pubsub_event = pubsub_event def set_location(self, data): item = Node('geoloc', {'xmlns': NS_LOCATION}) diff --git a/nbxmpp/modules/mood.py b/nbxmpp/modules/mood.py index 8eeb5f8..e414430 100644 --- a/nbxmpp/modules/mood.py +++ b/nbxmpp/modules/mood.py @@ -49,7 +49,8 @@ class Mood: mood_node = item.getTag('mood', namespace=NS_MOOD) if not mood_node.getChildren(): - data = properties.pubsub_event._replace(empty=True) + pubsub_event = properties.pubsub_event._replace(empty=True) + log.info('Received mood: %s - no mood set', properties.jid) else: mood, text = None, None for child in mood_node.getChildren(): @@ -65,10 +66,10 @@ class Mood: raise NodeProcessed data = MoodData(mood, text) - data = properties.pubsub_event._replace(data=data) + pubsub_event = properties.pubsub_event._replace(data=data) + log.info('Received mood: %s - %s', properties.jid, data) - log.info('Received mood: %s - %s', properties.jid, data) - properties.pubsub_event = data + properties.pubsub_event = pubsub_event def set_mood(self, data): item = Node('mood', {'xmlns': NS_MOOD}) diff --git a/nbxmpp/modules/nickname.py b/nbxmpp/modules/nickname.py index d2fa33e..e6422bc 100644 --- a/nbxmpp/modules/nickname.py +++ b/nbxmpp/modules/nickname.py @@ -65,7 +65,10 @@ class Nickname: return nick = self._parse_nickname(properties.pubsub_event.item) - log.info('Received nickname: %s - %s', properties.jid, nick) + if nick is None: + log.info('Received nickname: %s - no nickname set', properties.jid) + else: + log.info('Received nickname: %s - %s', properties.jid, nick) properties.pubsub_event = properties.pubsub_event._replace(data=nick) diff --git a/nbxmpp/modules/tune.py b/nbxmpp/modules/tune.py index 32f1253..b1388b5 100644 --- a/nbxmpp/modules/tune.py +++ b/nbxmpp/modules/tune.py @@ -48,17 +48,18 @@ class Tune: tune_node = item.getTag('tune', namespace=NS_TUNE) if not tune_node.getChildren(): - data = properties.pubsub_event._replace(empty=True) + pubsub_event = properties.pubsub_event._replace(empty=True) + log.info('Received tune: %s - no tune set', properties.jid) else: tune_dict = {} for attr in TUNE_DATA: tune_dict[attr] = tune_node.getTagData(attr) data = TuneData(**tune_dict) - data = properties.pubsub_event._replace(data=data) + pubsub_event = properties.pubsub_event._replace(data=data) + log.info('Received tune: %s - %s', properties.jid, data) - log.info('Received tune: %s - %s', properties.jid, data) - properties.pubsub_event = data + properties.pubsub_event = pubsub_event def set_tune(self, data): item = Node('tune', {'xmlns': NS_TUNE}) |