Skip to content
Snippets Groups Projects
Commit 92ce5db3 authored by jkerdreu's avatar jkerdreu
Browse files

Added support to log notification without attributes (click..)



git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2670 b32b6428-25c9-4566-ad07-03861ab6144f
parent 1e3fafa3
No related branches found
No related tags found
No related merge requests found
......@@ -52,17 +52,30 @@ class WARP10Logger:
def parse_msg(self,msg):
global DATA_BUF
if msg.is_attributes_change():
base = self.cfg['topic'] + '.' + msg.dev_type
# only deal w/ notification (not alive)
if not msg.is_notify():
return
if msg.is_alive():
return
buf = ''
base = self.cfg['topic'] + '.' + msg.dev_type
now = round(time.time() * 1000000)
tags = '{devid=%s}' % str(msg.source)
# log attributes change
if msg.is_attributes_change():
for k in msg.body:
name = '%s.%s' % (base,k)
tags = '{devid=%s}' % str(msg.source)
value = msg.body[k]
if value != None and type(value)!=list:
buf = buf +"%s// %s%s %s\n" % (now,name,tags,value)
# log notification with no body (click...)
else:
name = '%s.%s' % (base,msg.action)
buf = buf +"%s// %s%s %s\n" % (now,name,tags,True)
buf = buf +"%s// %s%s %s\n" % (now+1,name,tags,False)
DATA_BUF = DATA_BUF + buf
print(DATA_BUF)
def setup(engine):
WARP10Logger(engine)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment