Browse Source

Fix string interpolation at logging call

Skip creating the formatted log message
if the message is not going to be emitted
because of the log level.

Change-Id: I19d985addb2bdc1b5e17ecd5ac90223e5347d7b2
Closes-Bug: #1596829
tags/5.0.0^0
Takashi NATSUME 3 years ago
parent
commit
ec20f7f85c

+ 1
- 1
neutronclient/neutron/v2_0/lb/v2/loadbalancer.py View File

@@ -168,7 +168,7 @@ class RetrieveLoadBalancerStatus(neutronV20.NeutronCommand):
168 168
         return parser
169 169
 
170 170
     def take_action(self, parsed_args):
171
-        self.log.debug('run(%s)' % parsed_args)
171
+        self.log.debug('run(%s)', parsed_args)
172 172
         neutron_client = self.get_client()
173 173
         lb_id = neutronV20.find_resourceid_by_name_or_id(
174 174
             neutron_client, self.resource, parsed_args.loadbalancer)

+ 3
- 3
neutronclient/neutron/v2_0/subnet.py View File

@@ -237,9 +237,9 @@ class CreateSubnet(neutronV20.CreateCommand):
237 237
                 self.log.warning(_("An IPv%(ip)d subnet with a %(cidr)s CIDR "
238 238
                                    "will have only one usable IP address so "
239 239
                                    "the device attached to it will not have "
240
-                                   "any IP connectivity.")
241
-                                 % {"ip": ip_version,
242
-                                    "cidr": unusable_cidr})
240
+                                   "any IP connectivity."),
241
+                                 {"ip": ip_version,
242
+                                  "cidr": unusable_cidr})
243 243
 
244 244
         updatable_args2body(parsed_args, body, ip_version=ip_version)
245 245
         if parsed_args.tenant_id:

+ 1
- 1
neutronclient/tests/unit/test_cli20_subnet.py View File

@@ -402,7 +402,7 @@ class CLITestV20SubnetJSON(test_cli20.CLITestV20Base):
402 402
         position_names = ['ip_version', 'network_id', 'cidr', 'gateway_ip']
403 403
         position_values = [4, netid, cidr, gateway]
404 404
         self.mox.StubOutWithMock(cmd.log, 'warning')
405
-        cmd.log.warning(mox.IgnoreArg())
405
+        cmd.log.warning(mox.IgnoreArg(), {'ip': 4, 'cidr': '/32'})
406 406
         self._test_create_resource(resource, cmd, name, myid, args,
407 407
                                    position_names, position_values)
408 408
         self.mox.VerifyAll()

Loading…
Cancel
Save