Add logging to controller

This commit is contained in:
Bálint Bokros 2018-02-09 14:06:11 +01:00
parent e39b8b9283
commit eed3006055
2 changed files with 7 additions and 0 deletions

View File

@ -5,6 +5,8 @@ from tfw.config import CRP_LISTENER_PORT, AVATAO_SECRET
from handlers import SolutionCheckHandler, TestHandler from handlers import SolutionCheckHandler, TestHandler
from tfw.networking.solvable_connector import SolvableConnector from tfw.networking.solvable_connector import SolvableConnector
from tfw.config.logs import logging
log = logging.getLogger(__name__)
if __name__ == '__main__': if __name__ == '__main__':
solvable_connector = SolvableConnector() solvable_connector = SolvableConnector()
@ -16,4 +18,5 @@ if __name__ == '__main__':
routes routes
) )
app.listen(CRP_LISTENER_PORT) app.listen(CRP_LISTENER_PORT)
log.debug('Controller listening on {}'.format(CRP_LISTENER_PORT))
IOLoop.instance().start() IOLoop.instance().start()

View File

@ -1,11 +1,15 @@
from tornado.web import RequestHandler from tornado.web import RequestHandler
from tfw.config.logs import logging
log = logging.getLogger(__name__)
class SolutionCheckHandler(RequestHandler): class SolutionCheckHandler(RequestHandler):
def initialize(self, solvable_connector): def initialize(self, solvable_connector):
self.solvable_connector = solvable_connector self.solvable_connector = solvable_connector
def get(self): def get(self):
log.debug('Sending request to solvable')
self.solvable_connector.send('solution_check', {}) self.solvable_connector.send('solution_check', {})
resp_key, resp_data = self.solvable_connector.recv() resp_key, resp_data = self.solvable_connector.recv()
log.debug('Received answer from solvable')
self.write(resp_data) self.write(resp_data)