summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2016-12-23 09:16:39 +0100
committerKlement Sekera <ksekera@cisco.com>2016-12-23 09:16:39 +0100
commit6c7440ca95fe3508c083ac4d2ecf7eca459b7f8e (patch)
tree0aa258dbede6c69fb40f1d959625cde8e6dda100 /test
parent207a322dea0a477565257005a174c4765da89d31 (diff)
make test: add log.txt
Always create a log.txt under test's temporary directory containing V=2 output for debugging purposes. Change-Id: If149c8126f42f80724ee17b63c411ddec6645f85 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/framework.py4
-rw-r--r--test/log.py17
2 files changed, 13 insertions, 8 deletions
diff --git a/test/framework.py b/test/framework.py
index 1c3e56cc827..1b745ff3e3c 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -13,6 +13,7 @@ from vpp_pg_interface import VppPGInterface
from vpp_lo_interface import VppLoInterface
from vpp_papi_provider import VppPapiProvider
from scapy.packet import Raw
+from logging import FileHandler, DEBUG
from log import *
"""
@@ -175,6 +176,9 @@ class VppTestCase(unittest.TestCase):
cls.logger = getLogger(cls.__name__)
cls.tempdir = tempfile.mkdtemp(
prefix='vpp-unittest-' + cls.__name__ + '-')
+ file_handler = FileHandler("%s/log.txt" % cls.tempdir)
+ file_handler.setLevel(DEBUG)
+ cls.logger.addHandler(file_handler)
cls.shm_prefix = cls.tempdir.split("/")[-1]
os.chdir(cls.tempdir)
cls.logger.info("Temporary dir is %s, shm prefix is %s",
diff --git a/test/log.py b/test/log.py
index 5a6219ce973..cca542b4527 100644
--- a/test/log.py
+++ b/test/log.py
@@ -24,13 +24,6 @@ class ColorFormatter(logging.Formatter):
if hasattr(record, 'color'):
message = colorize(message, record.color)
return message
-
-handler = logging.StreamHandler(sys.stdout)
-handler.setFormatter(ColorFormatter(fmt='%(asctime)s,%(msecs)03d %(message)s',
- datefmt="%H:%M:%S"))
-
-global_logger = logging.getLogger()
-global_logger.addHandler(handler)
try:
verbose = int(os.getenv("V", 0))
except:
@@ -44,13 +37,21 @@ elif verbose == 1:
else:
log_level = 40
+handler = logging.StreamHandler(sys.stdout)
+handler.setFormatter(ColorFormatter(fmt='%(asctime)s,%(msecs)03d %(message)s',
+ datefmt="%H:%M:%S"))
+handler.setLevel(log_level)
+
+global_logger = logging.getLogger()
+global_logger.addHandler(handler)
+
scapy_logger = logging.getLogger("scapy.runtime")
scapy_logger.setLevel(logging.ERROR)
def getLogger(name):
logger = logging.getLogger(name)
- logger.setLevel(log_level)
+ logger.setLevel(logging.DEBUG)
return logger
# Static variables to store color formatting strings.