← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~matsubara/launchpad/silence-bzr-output-on-ec2 into lp:launchpad/devel

 

Diogo Matsubara has proposed merging lp:~matsubara/launchpad/silence-bzr-output-on-ec2 into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


This branch fixes two spurious "No handlers could be found for logger..." messages in the LP code base.

The goal behind this change is to remove messages that clutter the output when submitting branches to be tested on ec2 and in the test suite itself. These issues[1] were recorded on a tomboy note in Maris computer as "Broken windows" and are so small that are not worth a bug report. This branch has also the incidental goal of having the QA team helping fix issues in the build system.

= QA =

Run `ec2 test --attached` and see that the message 'No handlers could be found for logger "bzr"' doesn't appear.


[1]:
- ec2 test --attached is missing a NullLogger, prints 'No handlers could be found for logger "bzr"'. 
- from the test logs: testSMTPServerIsAvailable (canonical.testing.ftests.test_layers.LayerProcessControllerInvariantsTestCase)No handlers could be found for logger "lazr.smtptest"
-- 
https://code.launchpad.net/~matsubara/launchpad/silence-bzr-output-on-ec2/+merge/30111
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~matsubara/launchpad/silence-bzr-output-on-ec2 into lp:launchpad/devel.
=== modified file 'lib/lp_sitecustomize.py'
--- lib/lp_sitecustomize.py	2010-06-09 20:59:25 +0000
+++ lib/lp_sitecustomize.py	2010-07-16 14:31:42 +0000
@@ -6,12 +6,23 @@
 
 import os
 import warnings
+import logging
 
 from bzrlib.branch import Branch
 from lp.services.mime import customizeMimetypes
 from zope.security import checker
 
 
+# XXX matsubara 2010-07-16 bug=606303: NullHandler class is available on
+# python 2.7 so when LP is running with it, this class can be removed.
+class NullHandler(logging.Handler):
+    def emit(self, record):
+        pass
+
+def silence_root_logger():
+    """Install the NullHandler on the root logger to silence logs."""
+    logging.getLogger().addHandler(NullHandler())
+
 def dont_wrap_class_and_subclasses(cls):
     checker.BasicTypes.update({cls: checker.NoProxy})
     for subcls in cls.__subclasses__():
@@ -40,5 +51,6 @@
     customizeMimetypes()
     dont_wrap_class_and_subclasses(Branch)
     silence_warnings()
+    silence_root_logger()
 
 main()