diff --git a/translator/conf/config.py b/translator/conf/config.py index 4e8fe87c..52ac4589 100644 --- a/translator/conf/config.py +++ b/translator/conf/config.py @@ -12,6 +12,7 @@ # under the License. ''' Provide a global configuration for the TOSCA translator''' +import os from six.moves import configparser @@ -65,3 +66,11 @@ class ConfigProvider(object): raise exception.ConfSectionNotDefined(section=section) return values + + @classmethod + def get_translator_logging_file(cls): + conf_file = '' + CONF_FILENAME = 'heat_translator_logging.conf' + conf_path = os.path.dirname(os.path.abspath(__file__)) + conf_file = os.path.join(conf_path, CONF_FILENAME) + return conf_file diff --git a/heat_translator_logging.conf b/translator/conf/heat_translator_logging.conf similarity index 100% rename from heat_translator_logging.conf rename to translator/conf/heat_translator_logging.conf diff --git a/translator/osc/v1/translate.py b/translator/osc/v1/translate.py index eeaaa18f..ef005e2d 100644 --- a/translator/osc/v1/translate.py +++ b/translator/osc/v1/translate.py @@ -22,11 +22,12 @@ from cliff import command from toscaparser.tosca_template import ToscaTemplate from toscaparser.utils.gettextutils import _ from translator.common.utils import UrlUtils +from translator.conf.config import ConfigProvider from translator.hot.tosca_translator import TOSCATranslator from translator.osc import utils - -logging.config.fileConfig('heat_translator_logging.conf') +conf_file = ConfigProvider.get_translator_logging_file() +logging.config.fileConfig(conf_file) log = logging.getLogger('heat-translator') diff --git a/translator/shell.py b/translator/shell.py index 92d92d96..ca98efa6 100644 --- a/translator/shell.py +++ b/translator/shell.py @@ -26,6 +26,7 @@ from toscaparser.tosca_template import ToscaTemplate from toscaparser.utils.gettextutils import _ from toscaparser.utils.urlutils import UrlUtils from translator.common import utils +from translator.conf.config import ConfigProvider from translator.hot.tosca_translator import TOSCATranslator """ @@ -44,8 +45,8 @@ without actual translation, pass --validate-only=true along with other required arguments. """ - -logging.config.fileConfig('heat_translator_logging.conf') +conf_file = ConfigProvider.get_translator_logging_file() +logging.config.fileConfig(conf_file) log = logging.getLogger("heat-translator")