提交 9e15e64e 编写于 作者: L Lukáš Doktor

avocado.core.job: Start logging earlier and add root_logger by default

Avocado defines own logging streams, all non-matching streams should
go to the job log.

This patch enables logging right after we setup the result direcotry to
allow the job to log early messages for example from test-discovery
directly into the job log.

Additionally this patch increases the module column in logging as lots
of module names are longer than 8 chars.

As the last change this removes the "avocado.linux" stream as it not
used anywhere.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 3573b193
......@@ -609,15 +609,17 @@ class View(object):
self.file_handler = logging.FileHandler(filename=logfile)
self.file_handler.setLevel(loglevel)
fmt = ('%(asctime)s %(module)-10.10s L%(lineno)-.4d %('
fmt = ('%(asctime)s %(module)-16.16s L%(lineno)-.4d %('
'levelname)-5.5s| %(message)s')
formatter = logging.Formatter(fmt=fmt, datefmt='%H:%M:%S')
self.file_handler.setFormatter(formatter)
test_logger = logging.getLogger('avocado.test')
linux_logger = logging.getLogger('avocado.linux')
test_logger.addHandler(self.file_handler)
linux_logger.addHandler(self.file_handler)
test_logger.setLevel(loglevel)
root_logger = logging.getLogger()
root_logger.addHandler(self.file_handler)
root_logger.setLevel(loglevel)
def stop_file_logging(self):
"""
......@@ -625,6 +627,8 @@ class View(object):
"""
test_logger = logging.getLogger('avocado.test')
linux_logger = logging.getLogger('avocado.linux')
root_logger = logging.getLogger()
test_logger.removeHandler(self.file_handler)
linux_logger.removeHandler(self.file_handler)
root_logger.removeHandler(self.file_handler)
self.file_handler.close()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册