Commit 40ff2a82 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Improve pubsub event logging

parent 45b02fd2
......@@ -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):
......
......@@ -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})
......
......@@ -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})
......
......@@ -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)
......
......@@ -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})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment