diff options
author | Yu Yang (Gabriel) <Gabriel.yuyang@huawei.com> | 2017-01-17 02:45:28 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-01-17 02:45:28 +0000 |
commit | 14f84a307691cc17d02ec10dd07cf5f3e2c03705 (patch) | |
tree | d738e24ec847d4d260e85dbf344a0cb123cd086d /utils/logger.py | |
parent | 7442c4d4516cd34dd50918a7b82462a356c94944 (diff) | |
parent | 9512f7cabad8cb1d7aaee22efe018c6539148dc2 (diff) |
Merge "Bottlenecks stack environment prepare"
Diffstat (limited to 'utils/logger.py')
-rw-r--r-- | utils/logger.py | 19 |
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 |