diff options
| author | Tang Chen <chen.tang@easystack.cn> | 2016-06-16 20:01:15 +0800 |
|---|---|---|
| committer | Steve Martinelli <s.martinelli@gmail.com> | 2016-06-20 15:16:51 +0000 |
| commit | 047cb6849354f4fdf8d365bd109a0ed56a77d200 (patch) | |
| tree | dc7372f6e90946e82606c2f1a1d974bd02879201 /openstackclient/image/v1 | |
| parent | ba825a4d5c04e2e6fd8a82ebbfb2f71a85e683aa (diff) | |
| download | python-openstackclient-047cb6849354f4fdf8d365bd109a0ed56a77d200.tar.gz | |
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
Diffstat (limited to 'openstackclient/image/v1')
| -rw-r--r-- | openstackclient/image/v1/image.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/openstackclient/image/v1/image.py b/openstackclient/image/v1/image.py index 1644809d..27467b0c 100644 --- a/openstackclient/image/v1/image.py +++ b/openstackclient/image/v1/image.py @@ -17,6 +17,7 @@ import argparse import io +import logging import os import sys @@ -39,6 +40,9 @@ DEFAULT_CONTAINER_FORMAT = 'bare' DEFAULT_DISK_FORMAT = 'raw' +LOG = logging.getLogger(__name__) + + def _format_visibility(data): """Return a formatted visibility string @@ -189,10 +193,8 @@ class CreateImage(command.ShowOne): image_client = self.app.client_manager.image if getattr(parsed_args, 'owner', None) is not None: - self.log.warning(_( - 'The --owner option is deprecated, ' - 'please use --project instead.' - )) + LOG.warning(_('The --owner option is deprecated, ' + 'please use --project instead.')) # Build an attribute dict from the parsed args, only include # attributes that were actually set on the command line @@ -608,10 +610,8 @@ class SetImage(command.Command): image_client = self.app.client_manager.image if getattr(parsed_args, 'owner', None) is not None: - self.log.warning(_( - 'The --owner option is deprecated, ' - 'please use --project instead.' - )) + LOG.warning(_('The --owner option is deprecated, ' + 'please use --project instead.')) kwargs = {} copy_attrs = ('name', 'owner', 'min_disk', 'min_ram', 'properties', @@ -684,16 +684,15 @@ class SetImage(command.Command): # will do a chunked transfer kwargs["data"] = sys.stdin else: - self.log.warning(_('Use --stdin to enable read ' - 'image data from standard ' - 'input')) + LOG.warning(_('Use --stdin to enable read image ' + 'data from standard input')) if image.properties and parsed_args.properties: image.properties.update(kwargs['properties']) kwargs['properties'] = image.properties if not kwargs: - self.log.warning('no arguments specified') + LOG.warning(_('no arguments specified')) return image = image_client.images.update(image.id, **kwargs) |
