From 96665938926b5083cf917517e2ecb7c7267d72c1 Mon Sep 17 00:00:00 2001 From: dongwenjuan Date: Wed, 23 Aug 2017 16:33:17 +0800 Subject: Specify the filename for 'w' filemode FileHandler use 'a' mode in default for writing the file. Change-Id: Ie19d80e5ff286da2722634787dcffe36234c0119 Signed-off-by: dongwenjuan --- tests/logger.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/logger.py b/tests/logger.py index 021389d9..80d19bb9 100644 --- a/tests/logger.py +++ b/tests/logger.py @@ -21,7 +21,8 @@ class Logger(object): CI_DEBUG = os.getenv('CI_DEBUG') - logging.basicConfig(filemode='w') + filename = '%s.log' % logger_name + logging.basicConfig(filemode='w', filename=filename) self.logger = logging.getLogger(logger_name) self.logger.propagate = 0 self.logger.setLevel(logging.DEBUG) @@ -37,7 +38,7 @@ class Logger(object): ch.setLevel(logging.INFO) self.logger.addHandler(ch) - file_handler = logging.FileHandler('%s.log' % logger_name) + file_handler = logging.FileHandler(filename) file_handler.setFormatter(formatter) file_handler.setLevel(logging.DEBUG) self.logger.addHandler(file_handler) -- cgit 1.2.3-korg