events: add simple notifications handler

This commit is contained in:
Oleksii Shevchuk 2018-10-19 16:04:34 +03:00
parent 0f3a0246e3
commit 4a68111ad6
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
# -*- encoding: utf-8 -*-
IGNORED_EVENTS = (
'start', 'exit', 'connect', 'disconnect', 'job completed'
)
import datetime
def execute(event_name, client, server, handler, config, **kwargs):
if event_name in IGNORED_EVENTS:
return
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'])
server.info('Event ({}): {} ({})'.format(
datetime.datetime.now(), event_name, client_id))