From 0e9862be7af9a88c9c0e6a9ef4e11e48a1192727 Mon Sep 17 00:00:00 2001 From: Tang Chen Date: Tue, 7 Jun 2016 14:29:41 +0800 Subject: Standardize logger usage in volume self.app.log is the logger in class OpenStackShell, which should be used to record logs that have nothing to do with any specific command. So, use the file logger instead. This patch also fixes some usage that doesn't follow rules in: http://docs.openstack.org/developer/oslo.i18n/guidelines.html 1. add variables to logger as an argument 2. do not wrap variables with str() Change-Id: I248861a38a4de0412a080046aa7a6f6473c3e082 Implements: blueprint log-usage --- openstackclient/volume/v2/volume.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'openstackclient/volume/v2/volume.py') diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py index b1a3af2e..e54395fa 100644 --- a/openstackclient/volume/v2/volume.py +++ b/openstackclient/volume/v2/volume.py @@ -15,6 +15,7 @@ """Volume V2 Volume action implementations""" import copy +import logging from osc_lib.cli import parseractions from osc_lib.command import command @@ -25,6 +26,9 @@ from openstackclient.i18n import _ from openstackclient.identity import common as identity_common +LOG = logging.getLogger(__name__) + + class CreateVolume(command.ShowOne): """Create new volume""" @@ -361,13 +365,12 @@ class SetVolume(command.Command): if parsed_args.size: if volume.status != 'available': - self.app.log.error(_("Volume is in %s state, it must be " - "available before size can be extended") % - volume.status) + LOG.error(_("Volume is in %s state, it must be available " + "before size can be extended"), volume.status) return if parsed_args.size <= volume.size: - self.app.log.error(_("New size must be greater than %s GB") % - volume.size) + LOG.error(_("New size must be greater than %s GB"), + volume.size) return volume_client.volumes.extend(volume.id, parsed_args.size) @@ -456,4 +459,4 @@ class UnsetVolume(command.Command): volume.id, parsed_args.image_property) if (not parsed_args.image_property and not parsed_args.property): - self.app.log.error(_("No changes requested\n")) + LOG.error(_("No changes requested")) -- cgit v1.2.1