Improve logging in designate.network_api

We should delegate (when possible) formatting to the logger in order to
perform formatting only when needed, by using:

 LOG.<level>(message, data)

instead of:

 LOG.<level>(message % data)

Change-Id: Ie6e9e18ea13affbb9321fb899d88a2290c56c71f
This commit is contained in:
Bertrand Lallau 2015-11-12 11:06:55 +01:00
parent e84810500f
commit 74fa2407e3
4 changed files with 11 additions and 11 deletions

View File

@ -28,7 +28,7 @@ cfg.CONF.register_opts([
def get_network_api(network_api_driver):
LOG.debug("Loading network_api driver: %s" % network_api_driver)
LOG.debug("Loading network_api driver: %s", network_api_driver)
cls = NetworkAPI.get_driver(network_api_driver)

View File

@ -57,7 +57,7 @@ class NetworkAPI(DriverPlugin):
msg = 'No service_catalog and no configured endpoints'
raise exceptions.ConfigurationError(msg)
LOG.debug('Returning endpoints: %s' % endpoints)
LOG.debug('Returning endpoints: %s', endpoints)
return endpoints
def _endpoints_from_catalog(self, service_catalog, service_type,

View File

@ -46,7 +46,7 @@ def allocate_floatingip(tenant_id, floatingip_id=None):
ALLOCATIONS[tenant_id][id_] = POOL.pop(id_)
values = _format_floatingip(id_, ALLOCATIONS[tenant_id][id_])
LOG.debug("Allocated to id_ %s to %s - %s" % (id_, tenant_id, values))
LOG.debug("Allocated to id_ %s to %s - %s", id_, tenant_id, values)
return values
@ -54,7 +54,7 @@ def deallocate_floatingip(id_):
"""
Deallocate a floatingip
"""
LOG.debug('De-allocating %s' % id_)
LOG.debug('De-allocating %s', id_)
for tenant_id, allocated in list(ALLOCATIONS.items()):
if id_ in allocated:
POOL[id_] = allocated.pop(id_)
@ -82,6 +82,6 @@ class FakeNetworkAPI(NetworkAPI):
data = list(ALLOCATIONS.get(context.tenant, {}).items())
formatted = [_format_floatingip(k, v) for k, v in data]
LOG.debug('Returning %i FloatingIPs: %s' %
(len(formatted), formatted))
LOG.debug('Returning %i FloatingIPs: %s',
len(formatted), formatted)
return formatted

View File

@ -110,8 +110,8 @@ class NeutronNetworkAPI(NetworkAPI):
def _call(endpoint, region, *args, **kw):
client = get_client(context, endpoint=endpoint)
LOG.debug("Attempting to fetch FloatingIPs from %s @ %s" %
(endpoint, region))
LOG.debug("Attempting to fetch FloatingIPs from %s @ %s",
endpoint, region)
try:
fips = client.list_floatingips(*args, **kw)
except neutron_exceptions.Unauthorized as e:
@ -124,7 +124,7 @@ class NeutronNetworkAPI(NetworkAPI):
return
except Exception as e:
LOG.error(_LE('Failed calling Neutron '
'%(region)s - %(endpoint)s') %
'%(region)s - %(endpoint)s'),
{'region': region, 'endpoint': endpoint})
LOG.exception(e)
failed.append((e, endpoint, region))
@ -137,8 +137,8 @@ class NeutronNetworkAPI(NetworkAPI):
'region': region
})
LOG.debug("Added %i FloatingIPs from %s @ %s" %
(len(data), endpoint, region))
LOG.debug("Added %i FloatingIPs from %s @ %s",
len(data), endpoint, region)
for endpoint, region in endpoints:
tg.add_thread(_call, endpoint, region,