summaryrefslogtreecommitdiff
path: root/server/handlers.py
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-10-05 17:50:23 +0200
committerAleš Smodiš <aless@guru.si>2015-10-05 17:50:23 +0200
commit63a852da581bd58975f021ef1adda07312183881 (patch)
tree22f9d8c3e192ed93b7952f3e30c0f88894498f6d /server/handlers.py
parent0818b6655e8fd5ce14febd47470ac0445e3665f1 (diff)
Add logging to file to python server. Configure logfile paths from environment variables CODEQ_SERVER_LOG and CODEQ_WEB_LOG.
Diffstat (limited to 'server/handlers.py')
-rw-r--r--server/handlers.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/server/handlers.py b/server/handlers.py
index 99b021f..0a77e66 100644
--- a/server/handlers.py
+++ b/server/handlers.py
@@ -4,6 +4,7 @@ from concurrent.futures import ThreadPoolExecutor
import traceback
from errors.session import *
import server
+import logging
class CodeqService(object):
@@ -311,15 +312,15 @@ _executor = ThreadPoolExecutor(max_workers=100)
def _invoke_handler(handler, request):
try:
- print('Worker thread processing data={}'.format(str(request.data)))
+ logging.debug('Worker thread processing data={}'.format(str(request.data)))
handler.process(request)
if not request.is_finished:
- print('ERROR: the request was not concluded!')
+ logging.error('ERROR: the request was not concluded!')
request.reply({'code': -1, 'message': 'Request processing did not provide a reply'})
- print('Processing finished')
+ logging.debug('Processing finished')
except Exception as e:
- print('ERROR: data processing failed: ' + str(e))
- traceback.print_exc()
+ logging.critical('ERROR: data processing failed: ' + str(e))
+ logging.critical(traceback.format_exc())
request.reply({'code': -1, 'message': 'Internal error: ' + str(e)})
def serve_request(json_obj):
@@ -335,7 +336,7 @@ def serve_request(json_obj):
handler = incoming_handlers.get(action)
if handler is None:
raise RequestProcessingError('No handler for ' + action)
- print("Attempting to serve action={}".format(action))
+ logging.debug("Attempting to serve action={}".format(action))
session = None
if sid is None:
if not handler.session_is_optional:
@@ -351,7 +352,7 @@ def serve_request(json_obj):
def send(tid, sid, json_obj):
# just a proxy function for now
- print('Sending reply: {}'.format(str(json_obj)))
+ logging.debug('Sending reply: {}'.format(str(json_obj)))
server.socket.sendPacket(tid, sid, json_obj)
def stop():