← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~thumper/launchpad/moar-request-build-logging into lp:launchpad

 

Tim Penhey has proposed merging lp:~thumper/launchpad/moar-request-build-logging into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~thumper/launchpad/moar-request-build-logging/+merge/45803

Adds more logging to the request_daily_build script.

This would have been really useful in some debugging I was just doing.
-- 
https://code.launchpad.net/~thumper/launchpad/moar-request-build-logging/+merge/45803
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~thumper/launchpad/moar-request-build-logging into lp:launchpad.
=== modified file 'lib/lp/code/model/sourcepackagerecipebuild.py'
--- lib/lp/code/model/sourcepackagerecipebuild.py	2010-12-20 20:36:16 +0000
+++ lib/lp/code/model/sourcepackagerecipebuild.py	2011-01-11 01:11:59 +0000
@@ -11,6 +11,7 @@
     ]
 
 import datetime
+import logging
 import sys
 
 from psycopg2 import ProgrammingError
@@ -185,25 +186,30 @@
     def makeDailyBuilds(logger=None):
         from lp.code.model.sourcepackagerecipe import SourcePackageRecipe
         recipes = SourcePackageRecipe.findStaleDailyBuilds()
+        if logger is None:
+            logger = logging.getLogger()
         builds = []
         for recipe in recipes:
+            logger.debug(
+                'Recipe %s/%s is stale', recipe.owner.name, recipe.name)
             for distroseries in recipe.distroseries:
+                series_name = distroseries.named_version
                 try:
                     build = recipe.requestBuild(
                         recipe.daily_build_archive, recipe.owner,
                         distroseries, PackagePublishingPocket.RELEASE)
                 except BuildAlreadyPending:
+                    logger.debug(
+                        ' - build already pending for %s', series_name)
                     continue
                 except ProgrammingError:
                     raise
                 except:
+                    logger.exception(' - problem with %s', series_name)
                     info = sys.exc_info()
                     errorlog.globalErrorUtility.raising(info)
                 else:
-                    if logger is not None:
-                        logger.debug(
-                            'Build for %s/%s requested',
-                            recipe.owner.name, recipe.name)
+                    logger.debug(' - build requested for %s', series_name)
                     builds.append(build)
             recipe.is_stale = False
         return builds

=== modified file 'lib/lp/code/model/tests/test_sourcepackagerecipebuild.py'
--- lib/lp/code/model/tests/test_sourcepackagerecipebuild.py	2010-12-23 00:38:29 +0000
+++ lib/lp/code/model/tests/test_sourcepackagerecipebuild.py	2011-01-11 01:11:59 +0000
@@ -251,7 +251,8 @@
         logger = BufferLogger()
         SourcePackageRecipeBuild.makeDailyBuilds(logger)
         self.assertEqual(
-            'DEBUG Build for eric/funky-recipe requested\n',
+            'DEBUG Recipe eric/funky-recipe is stale\n'
+            'DEBUG  - build requested for Warty (4.10)\n',
             logger.getLogBuffer())
 
     def test_makeDailyBuilds_clears_is_stale(self):