diff options
author | Edward MacGillivray <edward.s.macgillivray@intel.com> | 2017-09-15 16:45:41 -0700 |
---|---|---|
committer | Edward MacGillivray <edward.s.macgillivray@intel.com> | 2017-09-26 20:03:04 +0000 |
commit | 3de95504a9a329cefcdec2ea9508709118bbf94e (patch) | |
tree | 246df74d6323ec4e00207a5f02dbb57674774ce3 /yardstick/__init__.py | |
parent | c84187fc404d44082826f98b47c28d3d8f6690e5 (diff) |
Ensure that at least one handler is available
https://jira.opnfv.org/browse/YARDSTICK-773?filter=-3
Remove dependency of yardstick on utils methods
Change-Id: Iadf502364a7f08c279a8f0d17d7e45e8047f4066
Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com>
Diffstat (limited to 'yardstick/__init__.py')
-rw-r--r-- | yardstick/__init__.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/yardstick/__init__.py b/yardstick/__init__.py index b673e7c4a..f95b0a906 100644 --- a/yardstick/__init__.py +++ b/yardstick/__init__.py @@ -10,11 +10,22 @@ from __future__ import absolute_import import logging import os +import errno +# this module must only import other modules that do +# not require loggers to be created, so this cannot +# include yardstick.common.utils from yardstick.common import constants -from yardstick.common import utils as yardstick_utils -yardstick_utils.makedirs(constants.LOG_DIR) +try: + # do not use yardstick.common.utils.makedirs + # since yardstick.common.utils creates a logger + # and so it cannot be imported before this code + os.makedirs(constants.LOG_DIR) +except OSError as e: + if e.errno != errno.EEXIST: + raise + LOG_FILE = os.path.join(constants.LOG_DIR, 'yardstick.log') LOG_FORMATTER = '%(asctime)s [%(levelname)s] %(name)s %(filename)s:%(lineno)d %(message)s' @@ -34,6 +45,7 @@ def _init_logging(): _LOG_STREAM_HDLR.setLevel(logging.DEBUG) else: _LOG_STREAM_HDLR.setLevel(logging.INFO) + # don't append to log file, clobber _LOG_FILE_HDLR.setFormatter(_LOG_FORMATTER) _LOG_FILE_HDLR.setLevel(logging.DEBUG) |