summaryrefslogtreecommitdiffstats
path: root/utils/logger.py
diff options
context:
space:
mode:
authorYu Yang (Gabriel) <Gabriel.yuyang@huawei.com>2017-01-17 02:45:28 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-01-17 02:45:28 +0000
commit14f84a307691cc17d02ec10dd07cf5f3e2c03705 (patch)
treed738e24ec847d4d260e85dbf344a0cb123cd086d /utils/logger.py
parent7442c4d4516cd34dd50918a7b82462a356c94944 (diff)
parent9512f7cabad8cb1d7aaee22efe018c6539148dc2 (diff)
Merge "Bottlenecks stack environment prepare"
Diffstat (limited to 'utils/logger.py')
-rw-r--r--utils/logger.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/utils/logger.py b/utils/logger.py
index 0f93bca7..23d749b6 100644
--- a/utils/logger.py
+++ b/utils/logger.py
@@ -19,15 +19,16 @@
import logging
import os
-# from bottlenecks_cfg import Bottlenecks_cfg as bn_cfg
+from utils.parser import Parser as conf
class Logger:
def __init__(self, logger_name):
- #if user set --debug as a cli parameter
- #we will set this variable “Debug” to output debug info.
+ # if user set --debug as a cli parameter
+ # we will set this variable "Debug" to output debug info.
DEBUG = os.getenv('DEBUG')
+ conf = Parser()
self.logger = logging.getLogger(logger_name)
self.logger.propagate = 0
@@ -47,13 +48,15 @@ class Logger:
ch.setLevel(logging.INFO)
self.logger.addHandler(ch)
-# result_path = bn_cfg.['log_dir']
-# if not os.path.exists(result_path):
-# os.makedirs(result_path)
- hdlr = logging.FileHandler('/tmp/bottlenecks.log')
+ result_path = conf.bottlenecks_config["log_dir"]
+ if not os.path.exists(result_path):
+ os.makedirs(result_path)
+ result_file = os.path.join(result_path, 'bottlenecks.log')
+ hdlr = logging.FileHandler(result_file)
+
hdlr.setFormatter(formatter)
hdlr.setLevel(logging.DEBUG)
self.logger.addHandler(hdlr)
def getLogger(self):
- return self.logger \ No newline at end of file
+ return self.logger