changeset 14375:436e5379d7ba

httpconnection: improved logging formatting I had to use this debugging output for the first time recently when looking for a problem, and the lack of good formatting made things difficult.
author Augie Fackler <durin42@gmail.com>
date Mon, 16 May 2011 16:59:45 -0500
parents 51f444e85734
children a75e0f4ba0ab
files mercurial/httpconnection.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httpconnection.py	Tue May 17 00:46:52 2011 +0200
+++ b/mercurial/httpconnection.py	Mon May 16 16:59:45 2011 -0500
@@ -107,6 +107,7 @@
 
 
 _configuredlogging = False
+LOGFMT = '%(levelname)s:%(name)s:%(lineno)d:%(message)s'
 # Subclass BOTH of these because otherwise urllib2 "helpfully"
 # reinserts them since it notices we don't include any subclasses of
 # them.
@@ -122,7 +123,9 @@
             _configuredlogging = True
             logger = logging.getLogger('mercurial.httpclient')
             logger.setLevel(getattr(logging, loglevel.upper()))
-            logger.addHandler(logging.StreamHandler())
+            handler = logging.StreamHandler()
+            handler.setFormatter(logging.Formatter(LOGFMT))
+            logger.addHandler(handler)
 
     def close_all(self):
         """Close and remove all connection objects being kept for reuse."""