Formatters ConfigParser NoSectionError

Added logic to fetch the log configuration file from conf path.

    Closes-bug: #1566567

Change-Id: I0af8d7a77a73e7865976bfb17dddddbc65eab432
This commit is contained in:
Lakshmi 2016-04-14 14:05:47 +05:30
parent 8f1e028b53
commit cf78251b8b
4 changed files with 15 additions and 4 deletions

View File

@ -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

View File

@ -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')

View File

@ -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")