X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2F__init__.py;h=b673e7c4a9a56783e963f39be7f639067ed01009;hb=a99e33c3d866da0de7be6f3c5ecdf9a33aedd12e;hp=5c279c800943e1f99a4b94db91b2e7391b33443d;hpb=3c3ac5d9e89af36bb609017e69f6d03b52d8b251;p=yardstick.git diff --git a/yardstick/__init__.py b/yardstick/__init__.py index 5c279c800..b673e7c4a 100644 --- a/yardstick/__init__.py +++ b/yardstick/__init__.py @@ -7,20 +7,16 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import logging import os -import sys -import yardstick.vTC.apexlake as apexlake +from yardstick.common import constants +from yardstick.common import utils as yardstick_utils -# Hack to be able to run apexlake unit tests -# without having to install apexlake. -sys.path.append(os.path.dirname(apexlake.__file__)) - -LOG_FILE = '/tmp/yardstick.log' -LOG_FORMATTER = ('%(asctime)s ' - '%(name)s %(filename)s:%(lineno)d ' - '%(levelname)s %(message)s') +yardstick_utils.makedirs(constants.LOG_DIR) +LOG_FILE = os.path.join(constants.LOG_DIR, 'yardstick.log') +LOG_FORMATTER = '%(asctime)s [%(levelname)s] %(name)s %(filename)s:%(lineno)d %(message)s' _LOG_FORMATTER = logging.Formatter(LOG_FORMATTER) _LOG_STREAM_HDLR = logging.StreamHandler() @@ -31,17 +27,18 @@ LOG = logging.getLogger(__name__) def _init_logging(): - _LOG_STREAM_HDLR.setFormatter(_LOG_FORMATTER) + LOG.setLevel(logging.DEBUG) + _LOG_STREAM_HDLR.setFormatter(_LOG_FORMATTER) + if os.environ.get('CI_DEBUG', '').lower() in {'1', 'y', "yes", "true"}: + _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) del logging.root.handlers[:] logging.root.addHandler(_LOG_STREAM_HDLR) logging.root.addHandler(_LOG_FILE_HDLR) logging.debug("logging.root.handlers = %s", logging.root.handlers) - - if os.environ.get('CI_DEBUG', '').lower() in {'1', 1, 'y', "yes", "true"}: - LOG.setLevel(logging.DEBUG) - else: - LOG.setLevel(logging.INFO)