summaryrefslogtreecommitdiff
path: root/server/socket.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/socket.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/socket.py')
-rw-r--r--server/socket.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/server/socket.py b/server/socket.py
index 121c6a4..bdf99bf 100644
--- a/server/socket.py
+++ b/server/socket.py
@@ -6,9 +6,9 @@ import json
import threading
import traceback
from server.handlers import serve_request
+import logging
# TODO: add a whole lot of try..except blocks, and just make it overall error resistant
-# TODO: add logging
_mapping_lock = threading.Lock() # the lock guarding access to the two mappings below
@@ -18,7 +18,7 @@ _transactions_to_socket = {} # keyed by tid, used only when there is no sid ava
def processIncomingPacket(receiving_socket, packet):
- print('Decoding JSON: {}'.format(packet))
+ logging.debug('Decoding JSON: {}'.format(packet))
obj = json.loads(packet)
req_type = obj.get('type') # private (meta) requests have the 'type'
if req_type == 'connect':
@@ -125,7 +125,7 @@ class JsonClientSocket(SocketHandler):
self.destroy()
else:
# packet decode loop
- print("received: {}".format(data))
+ logging.debug("received: {}".format(data))
offset = 0
N = len(data)
while (offset < N):
@@ -160,7 +160,7 @@ class JsonClientSocket(SocketHandler):
processIncomingPacket(self, s.decode('utf-8'))
except Exception as e:
# any exception that propagates to here means a possible protocol error, we have to disconnect
- traceback.print_exc()
+ logging.critical(traceback.format_exc())
self.destroy()
return
else: