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 tfw.networking.solvable_connector import SolvableConnector
from tfw.config.logs import logging
log = logging.getLogger(__name__)
if __name__ == '__main__':
solvable_connector = SolvableConnector()
@ -16,4 +18,5 @@ if __name__ == '__main__':
routes
)
app.listen(CRP_LISTENER_PORT)
log.debug('Controller listening on {}'.format(CRP_LISTENER_PORT))
IOLoop.instance().start()

View File

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