]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
bigswitch: Use lazy logging interpolation
authorAngus Lees <gus@inodes.org>
Mon, 22 Dec 2014 04:38:40 +0000 (15:38 +1100)
committerAngus Lees <gus@inodes.org>
Mon, 22 Dec 2014 06:12:54 +0000 (17:12 +1100)
There are a small number of examples of "eager" interpolation in
neutron:
  logging.debug("foo %s" % arg)

These should be converted to perform the interpolation lazily within
the logging function, since if the severity is below the logging level
then the interpolation can be skipped entirely.

This change addresses all such examples found in bigswitch via a pylint
test.  Other occurrences are addressed elsewhere.

Change-Id: I23fd4e7d0e4173e753a124d62a1563ce6ac674ca
Partial-Bug: #1404788

neutron/plugins/bigswitch/db/consistency_db.py

index f9dd8d1eacbc18635885bd823b4ce40bb123648b..641e1b3235a0a4cbae4156d18f2b5e38de93f616 100644 (file)
@@ -155,7 +155,7 @@ class HashHandler(object):
                     # for new lock ID to be removed
                     LOG.debug(
                         "Failed to acquire lock. Restarting lock wait. "
-                        "Previous hash: %(prev)s. Attempted update: %(new)s" %
+                        "Previous hash: %(prev)s. Attempted update: %(new)s",
                         {'prev': res.hash, 'new': new})
                     time.sleep(0.25)
                     continue
@@ -163,7 +163,7 @@ class HashHandler(object):
                 return res.hash
 
             LOG.debug("This request's lock ID is %(this)s. "
-                      "DB lock held by %(that)s" %
+                      "DB lock held by %(that)s",
                       {'this': self.random_lock_id,
                        'that': current_lock_owner})
 
@@ -197,7 +197,7 @@ class HashHandler(object):
                              "the DB first."))
 
     def clear_lock(self):
-        LOG.debug("Clearing hash record lock of id %s" % self.random_lock_id)
+        LOG.debug("Clearing hash record lock of id %s", self.random_lock_id)
         with self.session.begin(subtransactions=True):
             res = (self.session.query(ConsistencyHash).
                    filter_by(hash_id=self.hash_id).first())