Add a hacking rule for string interpolation at logging
String interpolation should be delayed to be handled by the logging code, rather than being done at the point of the logging call. See the oslo i18n guideline * https://docs.openstack.org/oslo.i18n/latest/user/guidelines.html#adding-variables-to-log-messages and * https://github.com/openstack-dev/hacking/blob/master/hacking/checks/other.py#L39 Closes-Bug: #1596829 Change-Id: Iba231be2476dcbeeb0edd76d6a921e549d183758
This commit is contained in:
parent
33b0ec1397
commit
d02a66d6bf
@ -504,10 +504,10 @@ class DbSync(BaseApp):
|
||||
LOG.info('The latest installed migration script version is: '
|
||||
'%(script)d.\nCurrent repository versions:\nExpand: '
|
||||
'%(expand)d \nMigrate: %(migrate)d\nContract: '
|
||||
'%(contract)d' % {'script': migration_script_version,
|
||||
'expand': expand_version,
|
||||
'migrate': migrate_version,
|
||||
'contract': contract_version})
|
||||
'%(contract)d', {'script': migration_script_version,
|
||||
'expand': expand_version,
|
||||
'migrate': migrate_version,
|
||||
'contract': contract_version})
|
||||
return status
|
||||
|
||||
@staticmethod
|
||||
|
@ -96,7 +96,7 @@ class FernetUtils(object):
|
||||
LOG.warning(
|
||||
'Unable to change the ownership of key_repository without '
|
||||
'a keystone user ID and keystone group ID both being '
|
||||
'provided: %s' % self.key_repository)
|
||||
'provided: %s', self.key_repository)
|
||||
|
||||
def _create_new_key(self, keystone_user_id, keystone_group_id):
|
||||
"""Securely create a new encryption key.
|
||||
@ -128,8 +128,7 @@ class FernetUtils(object):
|
||||
LOG.warning(
|
||||
'Unable to change the ownership of the new key without a '
|
||||
'keystone user ID and keystone group ID both being provided: '
|
||||
'%s' %
|
||||
self.key_repository)
|
||||
'%s', self.key_repository)
|
||||
# Determine the file name of the new key
|
||||
key_file = os.path.join(self.key_repository, '0.tmp')
|
||||
create_success = False
|
||||
|
@ -214,7 +214,7 @@ class Resource(base.ResourceDriverBase):
|
||||
if (project_id not in project_ids_from_bd or
|
||||
project_id == base.NULL_DOMAIN_ID):
|
||||
LOG.warning('Project %s does not exist and was not '
|
||||
'deleted.' % project_id)
|
||||
'deleted.', project_id)
|
||||
query.delete(synchronize_session=False)
|
||||
|
||||
|
||||
|
@ -1353,7 +1353,7 @@ class DomainConfigManager(manager.Manager):
|
||||
'value: %(value)s.')
|
||||
|
||||
if warning_msg:
|
||||
LOG.warning(warning_msg % {
|
||||
LOG.warning(warning_msg, {
|
||||
'domain': domain_id,
|
||||
'group': each_whitelisted['group'],
|
||||
'option': each_whitelisted['option'],
|
||||
|
@ -347,7 +347,7 @@ class FakeLdap(common.LDAPHandler):
|
||||
id_attr_in_modlist = True
|
||||
|
||||
if not id_attr_in_modlist:
|
||||
LOG.debug('id_attribute=%(attr)s missing, attributes=%(attrs)s' %
|
||||
LOG.debug('id_attribute=%(attr)s missing, attributes=%(attrs)s',
|
||||
{'attr': id_attr, 'attrs': modlist})
|
||||
raise ldap.NAMING_VIOLATION
|
||||
key = self.key(dn)
|
||||
|
@ -557,7 +557,7 @@ class DomainConfigTests(object):
|
||||
with mock.patch('keystone.resource.core.LOG', mock_log):
|
||||
res = self.domain_config_api.get_config_with_sensitive_info(
|
||||
self.domain['id'])
|
||||
mock_log.warning.assert_any_call(mock.ANY)
|
||||
mock_log.warning.assert_any_call(mock.ANY, mock.ANY)
|
||||
self.assertEqual(
|
||||
invalid_option_config['ldap']['url'], res['ldap']['url'])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user