From ef32ac699195ce179865b6070164b67cdf0c1485 Mon Sep 17 00:00:00 2001 From: Alvaro Lopez Garcia Date: Mon, 24 Sep 2018 08:21:32 +0200 Subject: [PATCH] Use oslo.log for osc plugin If we do not use oslo.log for logging in the openstackclient plugin, all the errors and messages that are generated by other parts of the client (cliff, openstackclient) may be lost. Change-Id: Ie9aec900e477f3f319ee34873018c15e10dafb4a --- lower-constraints.txt | 1 + requirements.txt | 2 ++ translator/osc/v1/translate.py | 12 ++++-------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index a1652169..6cae1499 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -41,6 +41,7 @@ os-client-config==1.28.0 os-service-types==1.2.0 osc-lib==1.8.0 oslo.i18n==3.15.3 +oslo.log==3.36.0 oslo.serialization==2.18.0 oslo.utils==3.33.0 oslosphinx==4.7.0 diff --git a/requirements.txt b/requirements.txt index 4b1b43cc..24744928 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,3 +13,5 @@ python-novaclient>=9.1.0 # Apache-2.0 python-heatclient>=1.10.0 # Apache-2.0 python-glanceclient>=2.8.0 # Apache-2.0 requests>=2.14.2 # Apache-2.0 + +oslo.log>=3.36.0 # Apache-2.0 diff --git a/translator/osc/v1/translate.py b/translator/osc/v1/translate.py index afe3ba26..926d42a1 100644 --- a/translator/osc/v1/translate.py +++ b/translator/osc/v1/translate.py @@ -12,25 +12,21 @@ """Translate action implementations""" -import logging -import logging.config import os import sys from cliff import command +from oslo_log import log as logging from toscaparser.tosca_template import ToscaTemplate from toscaparser.utils.gettextutils import _ from translator.common import flavors from translator.common import images from translator.common.utils import UrlUtils -from translator.conf.config import ConfigProvider from translator.hot.tosca_translator import TOSCATranslator from translator.osc import utils -conf_file = ConfigProvider.get_translator_logging_file() -logging.config.fileConfig(conf_file) -log = logging.getLogger('heat-translator') +LOG = logging.getLogger('heat-translator') class TranslateTemplate(command.Command): @@ -71,7 +67,7 @@ class TranslateTemplate(command.Command): return parser def take_action(self, parsed_args): - log.debug(_('Translating the template with input parameters' + LOG.debug(_('Translating the template with input parameters' '(%s).'), parsed_args) output = None @@ -101,7 +97,7 @@ class TranslateTemplate(command.Command): output = translator.translate() else: msg = _('Could not find template file.\n') - log.error(msg) + LOG.error(msg) sys.stdout.write(msg) raise SystemExit