aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-02-22 18:33:35 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2017-02-22 18:35:43 +0800
commit955042bf727d85f9a2e215a259c5fc14669e9a9d (patch)
tree4af31782b450bb1164d209e42c54f6a83bd7c1d9
parenta95ed75274a7f98e8988bfbf521c29c9da021fa2 (diff)
refactor logger to make unittest possible
Change-Id: Ibb630ea34701e454aabf78821f4c40781d2607ed Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
-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)