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

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).