# HG changeset patch # User Augie Fackler # Date 2011-05-16 21:59:45 # Node ID 436e5379d7ba13cad3438ef4ca3207235bb09717 # Parent 51f444e857347f6c27819fab686be0f31faec923 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. diff --git a/mercurial/httpconnection.py b/mercurial/httpconnection.py --- a/mercurial/httpconnection.py +++ b/mercurial/httpconnection.py @@ -107,6 +107,7 @@ class HTTPConnection(httpclient.HTTPConn _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 @@ class http2handler(urllib2.HTTPHandler, _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."""