← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~allenap/launchpad/silence-amqplib-logger into lp:launchpad

 

Gavin Panella has proposed merging lp:~allenap/launchpad/silence-amqplib-logger into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~allenap/launchpad/silence-amqplib-logger/+merge/77310

I noticed the following problem in buildbot:

{{{
lib/lp/bugs/doc/checkwatches-cli-switches.txtDEBUG Start from server,
 version: 8.0, properties: {u'platform': 'Erlang/OTP', u'product':
 'RabbitMQ', u'version': '1.7.2', u'copyright': 'Copyright (C)
 2007-2010 LShift Ltd., Cohesive Financial Technologies LLC., and
 Rabbit Technologies Ltd.', u'information': 'Licensed under the MPL.
 See http://www.rabbitmq.com/'}, mechanisms: ['PLAIN', 'AMQPLAIN'],
 locales: ['en_US']
DEBUG   Open OK! known_hosts [pigeonpea.canonical.com:35971]
DEBUG   using channel_id: 1
DEBUG   Channel open
DEBUG   using channel_id: 2
DEBUG   Channel open
DEBUG   using channel_id: 3
DEBUG   Channel open
DEBUG   using channel_id: 4
DEBUG   Channel open
DEBUG   using channel_id: 5
DEBUG   Channel open
DEBUG   Closed channel #1
DEBUG   Closed channel #2
DEBUG   Closed channel #3
DEBUG   Closed channel #4
DEBUG   Closed channel #5

in 0.507 seconds.
}}}

Something - amqplib - was spewing out log information during the test
run, though it wasn't causing a test failure. I had previously
silenced the amqplib logger in LaunchpadScript._init_logging() but
this was not working here.

Like other miscreant loggers, like bzr, I've simply silenced the
amqplib logger in lp_sitecustomize.py now.

-- 
https://code.launchpad.net/~allenap/launchpad/silence-amqplib-logger/+merge/77310
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/silence-amqplib-logger into lp:launchpad.
=== modified file 'lib/lp/services/scripts/base.py'
--- lib/lp/services/scripts/base.py	2011-09-27 07:53:02 +0000
+++ lib/lp/services/scripts/base.py	2011-09-28 11:37:25 +0000
@@ -321,7 +321,6 @@
             isolation = 'read_committed'
         self._init_zca(use_web_security=use_web_security)
         self._init_db(isolation=isolation)
-        self._init_logging()
 
         # XXX wgrant 2011-09-24 bug=29744: initZopeless used to do this.
         # Should be called directly by scripts that actually need it.
@@ -368,10 +367,6 @@
         dbconfig.override(dbuser=dbuser, isolation_level=isolation)
         self.txn = transaction
 
-    def _init_logging(self):
-        # Suppress debug messages from amqplib.
-        logging.getLogger("amqplib").setLevel(logging.INFO)
-
     def record_activity(self, date_started, date_completed):
         """Hook to record script activity."""
 

=== modified file 'lib/lp_sitecustomize.py'
--- lib/lp_sitecustomize.py	2011-06-15 14:49:04 +0000
+++ lib/lp_sitecustomize.py	2011-09-28 11:37:25 +0000
@@ -6,25 +6,25 @@
 
 from collections import defaultdict
 import itertools
+import logging
 import os
 import warnings
-import logging
 
+from bzrlib.branch import Branch
 from twisted.internet.defer import (
     Deferred,
     DeferredList,
     )
+from zope.interface import alsoProvides
+import zope.publisher.browser
+from zope.security import checker
 
-from bzrlib.branch import Branch
 from canonical.launchpad.webapp.interfaces import IUnloggedException
 from lp.services.log import loglevels
 from lp.services.log.logger import LaunchpadLogger
 from lp.services.log.mappingfilter import MappingFilter
 from lp.services.log.nullhandler import NullHandler
 from lp.services.mime import customizeMimetypes
-from zope.interface import alsoProvides
-from zope.security import checker
-import zope.publisher.browser
 
 
 def add_custom_loglevels():
@@ -74,6 +74,13 @@
             logger.parent = new_root
 
 
+def silence_amqplib_logger():
+    """Install the NullHandler on the amqplib logger to silence logs."""
+    amqplib_logger = logging.getLogger('amqplib')
+    amqplib_logger.addHandler(NullHandler())
+    amqplib_logger.propagate = False
+
+
 def silence_bzr_logger():
     """Install the NullHandler on the bzr logger to silence logs."""
     bzr_logger = logging.getLogger('bzr')
@@ -134,6 +141,7 @@
     This function is also invoked by the test infrastructure to reset
     logging between tests.
     """
+    silence_amqplib_logger()
     silence_bzr_logger()
     silence_zcml_logger()
     silence_transaction_logger()