summaryrefslogtreecommitdiffstats
path: root/utils/logger.py
diff options
context:
space:
mode:
authorliyin <liyin11@huawei.com>2017-01-11 19:10:57 +0800
committerAce Lee <liyin11@huawei.com>2017-01-12 08:36:38 +0000
commit9512f7cabad8cb1d7aaee22efe018c6539148dc2 (patch)
treee5fa5532cb7d8c00428999c3d09d64d466080004 /utils/logger.py
parente1a54d34819563946d1ff1ec673d1d261b826ad8 (diff)
Bottlenecks stack environment prepare
JIRA: BOTTLENECK-124 This code is for Bottlenecks to have a common way to prepare stack environment. those action are divided into three part: fetch os file, source file and adding ext-net to source file. those function also need change other file like fetch_os_creds.sh. And add some config to config file. remove parser file logging function. This code is relying on the patch: Modify utils/ code into PEP8 style Change-Id: I54405776b6dc3f5fb939e511c96963a9c1624938 Signed-off-by: liyin <liyin11@huawei.com>
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