aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhihui wu <wu.zhihui1@zte.com.cn>2017-02-23 05:55:02 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-02-23 05:55:02 +0000
commit896f3a6ed4ca5ccb35cc92f4923cdfe08b9ce581 (patch)
treef4b9f5bd5b51104626e56ae8722fda314c5b4e7f
parentea4a9fa4567b78e638646cf76217f6f6a2254347 (diff)
parent955042bf727d85f9a2e215a259c5fc14669e9a9d (diff)
Merge "refactor logger to make unittest possible"
-rw-r--r--qtip/util/logger.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/qtip/util/logger.py b/qtip/util/logger.py
index d5e76a64..a7847dfc 100644
--- a/qtip/util/logger.py
+++ b/qtip/util/logger.py
@@ -27,11 +27,11 @@ import os
class Logger(object):
- file_path = '/var/log'
formatter = logging.Formatter('%(asctime)s - %(name)s - '
'%(levelname)s - %(message)s')
- def __init__(self, logger_name):
+ def __init__(self, logger_name, file_path=None):
+ self.file_path = '/var/log' if not file_path else file_path
IF_DEBUG = os.getenv('IF_DEBUG')
@@ -59,10 +59,9 @@ class Logger(object):
class QtipLogger(Logger):
- file_path = '{}/qtip/logs'.format(os.environ['HOME'])
-
def __init__(self, logger_name):
+ self.file_path = '{}/qtip/logs'.format(os.environ['HOME'])
if not os.path.exists(self.file_path):
os.makedirs(self.file_path)
- super(QtipLogger, self).__init__(logger_name)
+ super(QtipLogger, self).__init__(logger_name, self.file_path)