From 4b7aba64cbde86e59d3f16b3f09b5cc1be2e3466 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Wed, 17 Feb 2016 21:35:54 +0100 Subject: [PATCH] Minimal logging added to the server --- bin/misp-modules.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/misp-modules.py b/bin/misp-modules.py index 7f3588b..1a7418c 100644 --- a/bin/misp-modules.py +++ b/bin/misp-modules.py @@ -24,9 +24,20 @@ import sys import tornado.web import importlib import json +import logging runPath = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(runPath, '..')) +port = 6666 + +log = logging.getLogger('misp-modules') +formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') +handler = logging.StreamHandler(stream=sys.stdout) +handler.setFormatter(formatter) +handler.setLevel(logging.INFO) + +log.addHandler(handler) +log.setLevel(logging.INFO) modulesdir = '../modules/expansion' @@ -37,6 +48,7 @@ for module in os.listdir(modulesdir): continue modulename = module.split(".")[0] modules.append(modulename) + log.info('MISP modules {0} imported'.format(modulename)) mhandlers[modulename] = importlib.import_module('modules.expansion.'+modulename) class ListModules(tornado.web.RequestHandler): @@ -46,13 +58,14 @@ class ListModules(tornado.web.RequestHandler): x = {} x['name'] = module x['mispattributes'] = mhandlers[module].introspection() - print (x['mispattributes']) ret.append(x) + log.debug('MISP ListModules request') self.write(json.dumps(ret)) class QueryModule(tornado.web.RequestHandler): def post(self): jsonpayload = self.request.body.decode('utf-8') x=json.loads(jsonpayload) + log.debug('MISP QueryModule request {0}'.format(jsonpayload)) ret = mhandlers[x['module']].handler(q=jsonpayload) self.write(json.dumps(ret)) @@ -60,5 +73,6 @@ class QueryModule(tornado.web.RequestHandler): service = [(r'/modules',ListModules), (r'/query',QueryModule)] application = tornado.web.Application(service) -application.listen(6666) +log.info('MISP modules server started on TCP port {0}'.format(port)) +application.listen(port) tornado.ioloop.IOLoop.instance().start()