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/v1/volume.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'openstackclient/volume/v1') diff --git a/openstackclient/volume/v1/volume.py b/openstackclient/volume/v1/volume.py index 7a3bfb97..e11aa1a7 100644 --- a/openstackclient/volume/v1/volume.py +++ b/openstackclient/volume/v1/volume.py @@ -16,6 +16,7 @@ """Volume v1 Volume action implementations""" import argparse +import logging from osc_lib.cli import parseractions from osc_lib.command import command @@ -25,6 +26,9 @@ import six from openstackclient.i18n import _ +LOG = logging.getLogger(__name__) + + class CreateVolume(command.ShowOne): """Create new volume""" @@ -343,13 +347,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) -- cgit v1.2.1