From 047cb6849354f4fdf8d365bd109a0ed56a77d200 Mon Sep 17 00:00:00 2001 From: Tang Chen Date: Thu, 16 Jun 2016 20:01:15 +0800 Subject: Standardize logger usage Use file logger for all command specific logs. This patch also fixes some usage that doesn't follow rules in: http://docs.openstack.org/developer/oslo.i18n/guidelines.html After this patch, all self.log and self.app.log will be standardized to LOG(). NOTE: In shell.py, we got the log in class OpenStackShell, which is also known as self.app.log in other classes. This logger is used to record non-command-specific logs. So we leave it as-is. Change-Id: I114f73ee6c7e84593d71e724bc1ad00d343c1896 Implements: blueprint log-usage --- openstackclient/common/availability_zone.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'openstackclient/common/availability_zone.py') diff --git a/openstackclient/common/availability_zone.py b/openstackclient/common/availability_zone.py index af161d1f..89d77d15 100644 --- a/openstackclient/common/availability_zone.py +++ b/openstackclient/common/availability_zone.py @@ -14,6 +14,7 @@ """Availability Zone action implementations""" import copy +import logging from novaclient import exceptions as nova_exceptions from osc_lib.command import command @@ -23,6 +24,9 @@ import six from openstackclient.i18n import _ +LOG = logging.getLogger(__name__) + + def _xform_common_availability_zone(az, zone_info): if hasattr(az, 'zoneState'): zone_info['zone_status'] = ('available' if az.zoneState['available'] @@ -136,11 +140,11 @@ class ListAvailabilityZone(command.Lister): try: data = volume_client.availability_zones.list() except Exception as e: - self.log.debug('Volume availability zone exception: ' + str(e)) + LOG.debug('Volume availability zone exception: %s', e) if parsed_args.volume: - message = "Availability zones list not supported by " \ - "Block Storage API" - self.log.warning(message) + message = _("Availability zones list not supported by " + "Block Storage API") + LOG.warning(message) result = [] for zone in data: @@ -154,11 +158,11 @@ class ListAvailabilityZone(command.Lister): network_client.find_extension('Availability Zone', ignore_missing=False) except Exception as e: - self.log.debug('Network availability zone exception: ' + str(e)) + LOG.debug('Network availability zone exception: ', e) if parsed_args.network: - message = "Availability zones list not supported by " \ - "Network API" - self.log.warning(message) + message = _("Availability zones list not supported by " + "Network API") + LOG.warning(message) return [] result = [] -- cgit v1.2.1