Implement support to report error,warning logs after every test case run.
Change-Id: Id5710e9ee3497b4bc1030d7fa69c182d2e1348c6
diff --git a/src/test/utils/CordLogger.py b/src/test/utils/CordLogger.py
new file mode 100644
index 0000000..2d9242c
--- /dev/null
+++ b/src/test/utils/CordLogger.py
@@ -0,0 +1,26 @@
+from OnosLog import OnosLog
+from scapy.all import log
+import unittest
+
+class CordLogger(unittest.TestCase):
+
+ def setUp(self):
+ '''Read the log buffer'''
+ try:
+ onosLog = OnosLog()
+ st, output = onosLog.get_log()
+ onosLog.close()
+ except: pass
+
+ def tearDown(self):
+ '''Dump the log buffer for ERRORS/warnings'''
+ try:
+ onosLog = OnosLog()
+ st, output = onosLog.get_log( ('ERROR','WARN') )
+ onosLog.close()
+ if st and output:
+ log.info('\nTest %s has errors and warnings\n' %self._testMethodName)
+ log.info('%s' %output)
+ else:
+ log.info('\nTest %s has no errors and warnings in the logs' %self._testMethodName)
+ except: pass