diff options
author | xudan <xudan16@huawei.com> | 2016-11-08 11:43:28 +0000 |
---|---|---|
committer | xudan <xudan16@huawei.com> | 2016-11-29 01:56:00 +0000 |
commit | 75dd45462f46c711f950c96aac783932cb7ec1a4 (patch) | |
tree | b197eaae13bec2b83abe4e778fce1a0d4a965657 /dovetail/parser.py | |
parent | cd94a6e124ae98f85bc2f7c3c26e052bb3f5e549 (diff) |
dovetail tool: package all logger initialization
1. For container.py, parser.py, report.py and testcase.py, they use functions
in classes to create loggers. So each class will have its own logger.
2. run.py will create all the loggers by create_logs() function before the use
of them. So logs will not be initialized until the call of create_logs().
3. Move logger in run.py into function main().
JIRA: DOVETAIL-56
Change-Id: I53de090df270cc7a34762ff99cbc9115cfb09465
Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/parser.py')
-rw-r--r-- | dovetail/parser.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/dovetail/parser.py b/dovetail/parser.py index 1740944a..d8f9fa0a 100644 --- a/dovetail/parser.py +++ b/dovetail/parser.py @@ -14,28 +14,33 @@ import utils.dovetail_logger as dt_logger import utils.dovetail_utils as dt_utils from conf.dovetail_config import DovetailConfig as dt_config -logger = dt_logger.Logger('parser.py').getLogger() - class Parser: '''preprocess configuration files''' - @staticmethod - def parse_cmd(cmd, testcase): + logger = None + + @classmethod + def create_log(cls): + cls.logger = dt_logger.Logger(__name__+'.Parser').getLogger() + + @classmethod + def parse_cmd(cls, cmd, testcase): cmd_lines = None try: template = jinja2.Template(cmd, undefined=jinja2.StrictUndefined) kwargs = {} for arg in dt_config.dovetail_config['parameters']: path = eval(arg['path']) - logger.debug('name: %s, eval path: %s ' % (arg['name'], path)) + cls.logger.debug('name: %s, eval path: %s ' % + (arg['name'], path)) kwargs[arg['name']] = \ dt_utils.get_obj_by_path(testcase.testcase, path) - logger.debug('kwargs: %s' % kwargs) + cls.logger.debug('kwargs: %s' % kwargs) cmd_lines = template.render(**kwargs) except Exception as e: - logger.error('failed to parse cmd %s, exception:%s' % (cmd, e)) + cls.logger.error('failed to parse cmd %s, exception:%s' % (cmd, e)) return None return cmd_lines |