From 2dcc31e84ae7f1d4e1a2fb411dc4dd4689341fa0 Mon Sep 17 00:00:00 2001 From: Mandeep Dhami <mandeep.dhami@bigswitch.com> Date: Mon, 23 Jan 2012 15:23:12 -0800 Subject: [PATCH] Fixed thread names to make logs easier to understand --- .../java/net/floodlightcontroller/jython/Server.java | 1 + src/main/python/debugserver.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/jython/Server.java b/src/main/java/net/floodlightcontroller/jython/Server.java index 2f909ab84..47ec1a52a 100644 --- a/src/main/java/net/floodlightcontroller/jython/Server.java +++ b/src/main/java/net/floodlightcontroller/jython/Server.java @@ -32,6 +32,7 @@ public class Server extends Thread { this.locals = new HashMap<String, Object>(); } this.locals.put("log", Server.log); + this.setName("debugserver"); } /** diff --git a/src/main/python/debugserver.py b/src/main/python/debugserver.py index 5eb3f60a4..d8c81f9d4 100644 --- a/src/main/python/debugserver.py +++ b/src/main/python/debugserver.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import sys +from threading import currentThread from SocketServer import BaseRequestHandler, TCPServer from code import InteractiveConsole @@ -37,7 +38,8 @@ class DebugConsole(InteractiveConsole): class DebugServerHandler(BaseRequestHandler): def __init__(self, request, client_address, server): - _log.debug('Open connection to DebugServer from: %s' % str(client_address)) + currentThread()._thread.setName("debugserver-%s:%d" % client_address) + _log.debug('Open connection to DebugServer from %s:%d' % client_address) BaseRequestHandler.__init__(self, request, client_address, server) def handle(self): @@ -51,13 +53,14 @@ class DebugServer(TCPServer): allow_reuse_address = True def handle_error(self, request, client_address): - _log.debug('Closing connection to DebugServer from: %s' % str(client_address)) + _log.debug('Closing connection to DebugServer from %s:%d' % client_address) request.close() def run_server(port=6655, host='0.0.0.0', locals=locals()): + currentThread()._thread.setName("debugserver-main") + global _locals _locals = locals - if "log" in locals.keys(): global _log _log = locals["log"] -- GitLab