events/notification: improve example

This commit is contained in:
Oleksii Shevchuk 2018-10-22 11:46:57 +03:00
parent a78a5d9a6e
commit 4afc0bb5db
1 changed files with 23 additions and 5 deletions

View File

@ -12,11 +12,29 @@ def execute(event_name, client, server, handler, config, **kwargs):
client_id = ''
if 'id' in kwargs:
client_id = 'client {}'.format(kwargs['id'])
elif 'sid' in kwargs:
client_id = 'session {:08x}'.format(kwargs['sid'])
elif 'node' in kwargs:
client_id = 'node {:12x}'.format(kwargs['node'])
client_id = 'session={}'.format(kwargs['id'])
elif 'node' in kwargs and kwargs['node']:
if type(kwargs['node']) in (int, long):
client_id = '{:012x}'.format(kwargs['node'])
else:
client_id = kwargs['node']
if 'sid' in kwargs:
if client_id:
client_id += '/'
if type(kwargs['sid']) in (int, long):
client_id += 'sid:{:08x}'.format(kwargs['sid'])
else:
client_id += 'sid:'+kwargs['sid']
if 'node' in kwargs:
tags = str(config.tags(kwargs['node']))
if tags:
if client_id:
client_id += '/'
client_id += '{}'.format(tags)
server.info('Event ({}): {} ({})'.format(
datetime.datetime.now(), event_name, client_id))