test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH v1 1/2] framework/logger: getLogger will return existing logger
@ 2018-01-25  7:10 Marvin Liu
  2018-01-25  7:10 ` [dts] [PATCH v1 2/2] framework/packet: log scapy command for later debug Marvin Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Marvin Liu @ 2018-01-25  7:10 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

Add list for saving all created loggers. Will return existing logger
when crb name and suite name are the same.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/logger.py b/framework/logger.py
index 78e90d6..8d0e5e8 100644
--- a/framework/logger.py
+++ b/framework/logger.py
@@ -92,6 +92,10 @@ RESET_COLOR = '\033[0m'
 stream_fmt = '%(color)s%(name)30s: %(message)s' + RESET_COLOR
 log_dir = None
 
+# List for saving all using loggers
+global Loggers
+Loggers = []
+
 
 def set_verbose():
     global verbose
@@ -356,7 +360,15 @@ def getLogger(name, crb="suite"):
     """
     Get logger handler and if there's no handler for specified CRB will create one.
     """
+    global Loggers
+    # return saved logger
+    for logger in Loggers:
+        if logger['name'] == name and logger['crb'] == crb:
+            return logger['logger']
+
+    # return new logger
     logger = DTSLOG(logging.getLogger(name), crb)
+    Loggers.append({'logger': logger, 'name': name, 'crb': crb})
     return logger
 
 
-- 
1.9.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [dts] [PATCH v1 2/2] framework/packet: log scapy command for later debug
  2018-01-25  7:10 [dts] [PATCH v1 1/2] framework/logger: getLogger will return existing logger Marvin Liu
@ 2018-01-25  7:10 ` Marvin Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Marvin Liu @ 2018-01-25  7:10 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/packet.py b/framework/packet.py
index 2aa2188..208c9a2 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -73,6 +73,10 @@ from nvgre import NVGRE, IPPROTO_NVGRE
 from lldp import LLDP, LLDPManagementAddress
 from Dot1BR import Dot1BR
 
+# get tester logger
+from logger import getLogger
+logger = getLogger('tester')
+
 # packet generator type should be configured later
 PACKETGEN = "scapy"
 
@@ -351,7 +355,7 @@ class scapy(object):
         crb.send_expect("scapy -c scapy_%s.cmd &" % intf, "# ")
 
     def print_summary(self):
-        print "Send out pkt %s" % self.pkt.summary()
+        logger.info("%s" % self.pkt.command())
 
     def send_pkt(self, intf='', count=1):
         self.print_summary()
-- 
1.9.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-25 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-25  7:10 [dts] [PATCH v1 1/2] framework/logger: getLogger will return existing logger Marvin Liu
2018-01-25  7:10 ` [dts] [PATCH v1 2/2] framework/packet: log scapy command for later debug Marvin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).