diff options
author | Erik Olof Gunnar Andersson <eandersson@blizzard.com> | 2018-03-12 10:08:53 -0700 |
---|---|---|
committer | Erik Olof Gunnar Andersson <eandersson@blizzard.com> | 2018-03-14 12:54:05 -0700 |
commit | 6ad30a39e6bdcaefa2f9ed68b8951012710e7661 (patch) | |
tree | 3f72515d1cb9d9be4cb157e02ccb58775ed75d78 /designate/manage | |
parent | 9a89306b89850b675459de77d083f5f7b8daa073 (diff) | |
download | designate-6ad30a39e6bdcaefa2f9ed68b8951012710e7661.tar.gz |
Remove translation of log messages
* Removed all log translation.
* Always lazy-load logging.
* Fixed broken log lines and updated tests.
Logs should no longer be translated (starting with Pike)[1].
Also, according to OpenStack Guideline[2], logged string message should be
interpolated by the logger.
[1]: http://lists.openstack.org/pipermail/openstack-dev/2017-March/thread.html#113365
[2]: https://docs.openstack.org/oslo.i18n/latest/user/guidelines.html#adding-variables-to-log-messages
Change-Id: I07825694f173a8bebd7d62ade089c38d3c666283
Diffstat (limited to 'designate/manage')
-rw-r--r-- | designate/manage/akamai.py | 7 | ||||
-rw-r--r-- | designate/manage/pool.py | 34 | ||||
-rw-r--r-- | designate/manage/tlds.py | 10 |
3 files changed, 23 insertions, 28 deletions
diff --git a/designate/manage/akamai.py b/designate/manage/akamai.py index 14007288..6dbc5fa5 100644 --- a/designate/manage/akamai.py +++ b/designate/manage/akamai.py @@ -22,7 +22,6 @@ from designate import exceptions from designate import policy from designate import rpc from designate.i18n import _ # noqa -from designate.i18n import _LI from designate.objects import pool as pool_object from designate.backend import impl_akamai from designate.central import rpcapi as central_rpcapi @@ -79,7 +78,7 @@ class AkamaiCommands(base.Commands): client = impl_akamai.EnhancedDNSClient( target.options.get("username"), target.options.get("password")) - LOG.info(_LI("Doing batches of %i"), batch_size) + LOG.info("Doing batches of %i", batch_size) criterion = {"pool_id": pool_id} marker = None @@ -94,7 +93,7 @@ class AkamaiCommands(base.Commands): update = [] if len(zones) == 0: - LOG.info(_LI("Stopping as there are no more zones.")) + LOG.info("Stopping as there are no more zones.") break else: marker = zones[-1]['id'] @@ -103,6 +102,6 @@ class AkamaiCommands(base.Commands): z = impl_akamai.build_zone(client, target, zone) update.append(z) - LOG.info(_LI('Uploading %d Zones'), len(update)) + LOG.info('Uploading %d Zones', len(update)) client.setZones(update) diff --git a/designate/manage/pool.py b/designate/manage/pool.py index 59026d80..7311c0d0 100644 --- a/designate/manage/pool.py +++ b/designate/manage/pool.py @@ -22,8 +22,6 @@ import oslo_messaging as messaging from designate import exceptions from designate import rpc -from designate.i18n import _LI -from designate.i18n import _LC from designate import objects from designate.central import rpcapi as central_rpcapi from designate.manage import base @@ -53,8 +51,8 @@ class PoolCommands(base.Commands): try: pools = self.central_api.find_pools(self.context) except messaging.exceptions.MessagingTimeout: - LOG.critical(_LC("No response received from designate-central. " - "Check it is running, and retry")) + LOG.critical("No response received from designate-central. " + "Check it is running, and retry") sys.exit(1) with open(file, 'w') as stream: yaml.dump( @@ -71,8 +69,8 @@ class PoolCommands(base.Commands): try: pools = self.central_api.find_pools(self.context) except messaging.exceptions.MessagingTimeout: - LOG.critical(_LC("No response received from designate-central. " - "Check it is running, and retry")) + LOG.critical("No response received from designate-central. " + "Check it is running, and retry") sys.exit(1) r_pools = objects.PoolList() for pool in pools: @@ -102,8 +100,8 @@ class PoolCommands(base.Commands): default_flow_style=False)) except messaging.exceptions.MessagingTimeout: - LOG.critical(_LC("No response received from designate-central. " - "Check it is running, and retry")) + LOG.critical("No response received from designate-central. " + "Check it is running, and retry") sys.exit(1) @base.args('--file', help='The path to the yaml file describing the pools', @@ -137,14 +135,14 @@ class PoolCommands(base.Commands): pool = self.central_api.get_pool( self.context, xpool['id']) except Exception: - LOG.critical( - _LC("Bad ID Supplied for pool %s"), xpool['name']) + LOG.critical("Bad ID Supplied for pool %s", + xpool['name']) continue else: pool = self.central_api.find_pool( self.context, {"name": xpool['name']}) - LOG.info(_LI('Updating existing pool: %s'), pool) + LOG.info('Updating existing pool: %s', pool) # TODO(kiall): Move the below into the pool object @@ -176,11 +174,11 @@ class PoolCommands(base.Commands): if dry_run: output_msg.append("Create Pool: %s" % pool) else: - LOG.info(_LI('Creating new pool: %s'), pool) + LOG.info('Creating new pool: %s', pool) self.central_api.create_pool(self.context, pool) except messaging.exceptions.MessagingTimeout: - LOG.critical(_LC("No response received from designate-central." - " Check it is running, and retry")) + LOG.critical("No response received from designate-central. " + "Check it is running, and retry") sys.exit(1) if delete: @@ -200,13 +198,13 @@ class PoolCommands(base.Commands): output_msg.append("Delete Pool: %s" % p) else: - LOG.info(_LI('Deleting %s'), p) + LOG.info('Deleting %s', p) self.central_api.delete_pool(self.context, p.id) except messaging.exceptions.MessagingTimeout: - LOG.critical(_LC("No response received from " - "designate-central. " - "Check it is running, and retry")) + LOG.critical( + "No response received from designate-central. " + "Check it is running, and retry") sys.exit(1) for line in output_msg: diff --git a/designate/manage/tlds.py b/designate/manage/tlds.py index f6cf0f77..fc6a6509 100644 --- a/designate/manage/tlds.py +++ b/designate/manage/tlds.py @@ -22,8 +22,6 @@ from designate import exceptions from designate import objects from designate import rpc from designate.central import rpcapi as central_rpcapi -from designate.i18n import _LI -from designate.i18n import _LE from designate.manage import base from designate.schema import format @@ -116,7 +114,7 @@ class TLDCommands(base.Commands): if not os.path.exists(input_file): raise Exception('TLD Input file Not Found') - LOG.info(_LI("Importing TLDs from %s"), input_file) + LOG.info("Importing TLDs from %s", input_file) error_lines = [] tlds_added = 0 @@ -136,11 +134,11 @@ class TLDCommands(base.Commands): tlds_added += self._validate_and_create_tld(line, error_lines) - LOG.info(_LI("Number of tlds added: %d"), tlds_added) + LOG.info("Number of tlds added: %d", tlds_added) errors = len(error_lines) if errors > 0: - LOG.error(_LE("Number of errors: %d") % errors) + LOG.error("Number of errors: %d", errors) # Sorting the errors and printing them so that it is easier to # read the errors - LOG.error(_LE("Error Lines:\n%s") % '\n'.join(sorted(error_lines))) + LOG.error("Error Lines:\n%s", '\n'.join(sorted(error_lines))) |