Code Review
/
yardstick.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Adding Grafana dashboard for visualizing the vEPC default bearer metrics."
[yardstick.git]
/
yardstick
/
__init__.py
diff --git
a/yardstick/__init__.py
b/yardstick/__init__.py
index
2f5ae9f
..
9eb5db9
100644
(file)
--- a/
yardstick/__init__.py
+++ b/
yardstick/__init__.py
@@
-10,21
+10,25
@@
from __future__ import absolute_import
import logging
import os
from __future__ import absolute_import
import logging
import os
-import
sys
+import
errno
-import yardstick.vTC.apexlake as apexlake
+# this module must only import other modules that do
+# not require loggers to be created, so this cannot
from yardstick.common import constants
from yardstick.common import constants
-from yardstick.common import
utils as yardstick_util
s
+from yardstick.common import
exception
s
-# Hack to be able to run apexlake unit tests
-# without having to install apexlake.
-sys.path.append(os.path.dirname(apexlake.__file__))
-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_FILE = os.path.join(constants.LOG_DIR, 'yardstick.log')
-LOG_FORMATTER = ('%(asctime)s '
- '%(name)s %(filename)s:%(lineno)d '
- '%(levelname)s %(message)s')
+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()
_LOG_FORMATTER = logging.Formatter(LOG_FORMATTER)
_LOG_STREAM_HDLR = logging.StreamHandler()
@@
-42,6
+46,7
@@
def _init_logging():
_LOG_STREAM_HDLR.setLevel(logging.DEBUG)
else:
_LOG_STREAM_HDLR.setLevel(logging.INFO)
_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)
# don't append to log file, clobber
_LOG_FILE_HDLR.setFormatter(_LOG_FORMATTER)
_LOG_FILE_HDLR.setLevel(logging.DEBUG)