Change Python servers to use the standard logging module.

Previously Thrift was using `print` to report errors.  Thrift is infrastructure
and should not impose its error logging mechanism on the apps that use it.  For
example, [elided] uses the logging module to send logs to a particular file.

I ran the unit test.  That exercises most of the error handling routines.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666364 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/py/src/server/TServer.py b/lib/py/src/server/TServer.py
index 21a90c8..b656b49 100644
--- a/lib/py/src/server/TServer.py
+++ b/lib/py/src/server/TServer.py
@@ -6,6 +6,7 @@
 # See accompanying file LICENSE or visit the Thrift site at:
 # http://developers.facebook.com/thrift/
 
+import logging
 import sys
 import os
 import traceback
@@ -72,7 +73,7 @@
       except TTransport.TTransportException, tx:
         pass
       except Exception, x:
-        print '%s, %s, %s' % (type(x), x, traceback.format_exc())
+        logging.exception(x)
 
       itrans.close()
       otrans.close()
@@ -94,7 +95,7 @@
       except KeyboardInterrupt:
         raise
       except Exception, x:
-        print '%s, %s, %s,' % (type(x), x, traceback.format_exc())
+        logging.exception(x)
 
   def handle(self, client):
     itrans = self.inputTransportFactory.getTransport(client)
@@ -107,7 +108,7 @@
     except TTransport.TTransportException, tx:
       pass
     except Exception, x:
-      print '%s, %s, %s' % (type(x), x, traceback.format_exc())
+      logging.exception(x)
 
     itrans.close()
     otrans.close()
@@ -132,7 +133,7 @@
         client = self.clients.get()
         self.serveClient(client)
       except Exception, x:
-        print '%s, %s, %s' % (type(x), x, traceback.format_exc())
+        logging.exception(x)
 
   def serveClient(self, client):
     """Process input/output from a client for as long as possible"""
@@ -146,7 +147,7 @@
     except TTransport.TTransportException, tx:
       pass
     except Exception, x:
-      print '%s, %s, %s' % (type(x), x, traceback.format_exc())
+      logging.exception(x)
 
     itrans.close()
     otrans.close()
@@ -158,7 +159,7 @@
         t = threading.Thread(target = self.serveThread)
         t.start()
       except Exception, x:
-        print '%s, %s, %s,' % (type(x), x, traceback.format_exc())
+        logging.exception(x)
 
     # Pump the socket for clients
     self.serverTransport.listen()
@@ -167,7 +168,7 @@
         client = self.serverTransport.accept()
         self.clients.put(client)
       except Exception, x:
-        print '%s, %s, %s' % (type(x), x, traceback.format_exc())
+        logging.exception(x)
 
 
 class TForkingServer(TServer):
@@ -194,7 +195,7 @@
       try:
         file.close()
       except IOError, e:
-        print '%s, %s, %s' % (type(e), e, traceback.format_exc())
+        logging.warning(e, exc_info=True)
 
 
     self.serverTransport.listen()
@@ -228,7 +229,7 @@
           except TTransport.TTransportException, tx:
             pass
           except Exception, e:
-            print '%s, %s, %s' % (type(e), e, traceback.format_exc())
+            logging.exception(e)
             ecode = 1
           finally:
             try_close(itrans)
@@ -239,7 +240,7 @@
       except TTransport.TTransportException, tx:
         pass
       except Exception, x:
-        print '%s, %s, %s' % (type(x), x, traceback.format_exc())
+        logging.exception(x)
 
 
   def collect_children(self):