aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tinderbox/logger.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/tinderbox/logger.py b/src/tinderbox/logger.py
index d73b7f3..a90f578 100644
--- a/src/tinderbox/logger.py
+++ b/src/tinderbox/logger.py
@@ -3,14 +3,23 @@ from errno import *
import logging as log
import config
+fhandler = None
+
def init_logging(dir):
"""Initialize logging file and settings
"""
+ global fhandler
try:
os.mkdir(dir)
except OSError, e:
if e.errno != EEXIST:
raise e
- log.basicConfig(level=config.LOG_LEVEL, format='%(asctime)s %(levelname)s %(message)s',
- filename=dir+'/tinderbox.log', filemode='a')
+ if fhandler is not None:
+ fhandler.close()
+ log.getLogger('').removeHandler(fhandler)
+ fhandler = log.FileHandler(dir+"/tinderbox.log")
+ formatter = log.Formatter('%(asctime)s %(levelname)s %(message)s')
+ fhandler.setFormatter(formatter)
+ log.getLogger('').addHandler(fhandler)
+ fhandler.setLevel(config.LOG_LEVEL)