From: yufengmx <yufengx.mo@intel.com>
To: dts@dpdk.org
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V1 3/10] [next]framework/logger: add pktgen logger and remove
Date: Mon, 5 Aug 2019 13:50:37 +0800 [thread overview]
Message-ID: <1564984244-151448-4-git-send-email-yufengx.mo@intel.com> (raw)
In-Reply-To: <1564984244-151448-1-git-send-email-yufengx.mo@intel.com>
duplicate code
*. remove duplicate ixia logger setting.
*. add pktgen logger setting.
*. fix typo.
Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
framework/logger.py | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/framework/logger.py b/framework/logger.py
index 603d3aa..32dd954 100644
--- a/framework/logger.py
+++ b/framework/logger.py
@@ -64,6 +64,9 @@ logging.DTS_IXIA_OUTPUT = logging.DEBUG + 5
logging.DTS_VIRTDUT_CMD = logging.INFO + 6
logging.DTS_VIRTDUT_OUTPUT = logging.DEBUG + 6
+logging.DTS_PKTGEN_CMD = logging.INFO + 7
+logging.DTS_PKTGEN_OUTPUT = logging.DEBUG + 7
+
logging.addLevelName(logging.DTS_DUT_CMD, 'DTS_DUT_CMD')
logging.addLevelName(logging.DTS_DUT_OUTPUT, 'DTS_DUT_OUTPUT')
logging.addLevelName(logging.DTS_DUT_RESULT, 'DTS_DUT_RESULT')
@@ -84,8 +87,8 @@ logging.addLevelName(logging.SUITE_DUT_OUTPUT, 'SUITE_DUT_OUTPUT')
logging.addLevelName(logging.SUITE_TESTER_CMD, 'SUITE_TESTER_CMD')
logging.addLevelName(logging.SUITE_TESTER_OUTPUT, 'SUITE_TESTER_OUTPUT')
-logging.addLevelName(logging.DTS_IXIA_CMD, 'DTS_IXIA_CMD')
-logging.addLevelName(logging.DTS_IXIA_OUTPUT, 'DTS_IXIA_OUTPUT')
+logging.addLevelName(logging.DTS_PKTGEN_CMD, 'DTS_PKTGEN_CMD')
+logging.addLevelName(logging.DTS_PKTGEN_OUTPUT, 'DTS_PKTGEN_OUTPUT')
date_fmt = '%d/%m/%Y %H:%M:%S'
RESET_COLOR = '\033[0m'
@@ -149,6 +152,12 @@ class BaseLoggerAdapter(logging.LoggerAdapter):
def dts_virtdut_output(self, msg, *args, **kwargs):
self.log(logging.DTS_VIRTDUT_OUTPUT, msg, *args, **kwargs)
+ def dts_pktgen_cmd(self, msg, *args, **kwargs):
+ self.log(logging.DTS_PKTGEN_CMD, msg, *args, **kwargs)
+
+ def dts_pktgen_output(self, msg, *args, **kwargs):
+ self.log(logging.DTS_PKTGEN_OUTPUT, msg, *args, **kwargs)
+
class ColorHandler(logging.StreamHandler):
"""
@@ -167,6 +176,8 @@ class ColorHandler(logging.StreamHandler):
logging.SUITE_TESTER_CMD: '', # SYSTEM
logging.DTS_IXIA_CMD: '', # SYSTEM
logging.DTS_IXIA_OUTPUT: '', # SYSTEM
+ logging.DTS_PKTGEN_CMD: '', # SYSTEM
+ logging.DTS_PKTGEN_OUTPUT: '', # SYSTEM
logging.DTS_VIRTDUT_CMD: '', # SYSTEM
logging.DTS_VIRTDUT_OUTPUT: '', # SYSTEM
logging.WARN: '\033[01;33m', # BOLD YELLOW
@@ -228,7 +239,7 @@ class DTSLOG(BaseLoggerAdapter):
fh.setFormatter(logging.Formatter(message_fmt, date_fmt))
ch.setFormatter(logging.Formatter(stream_fmt, date_fmt))
- fh.setLevel(logging.DEBUG) # file hander default level
+ fh.setLevel(logging.DEBUG) # file handler default level
global verbose
if verbose is True:
ch.setLevel(logging.DEBUG)
@@ -310,6 +321,9 @@ class DTSLOG(BaseLoggerAdapter):
elif crb.startswith('ixia'):
self.info_lvl = logging.DTS_IXIA_CMD
self.debug_lvl = logging.DTS_IXIA_OUTPUT
+ elif crb.startswith('pktgen'):
+ self.info_lvl = logging.DTS_PKTGEN_CMD
+ self.debug_lvl = logging.DTS_PKTGEN_OUTPUT
elif crb.startswith('virtdut'):
self.info_lvl = logging.DTS_VIRTDUT_CMD
self.debug_lvl = logging.DTS_VIRTDUT_OUTPUT
@@ -342,6 +356,9 @@ class DTSLOG(BaseLoggerAdapter):
elif crb == 'ixia':
self.info_lvl = logging.DTS_IXIA_CMD
self.debug_lvl = logging.DTS_IXIA_OUTPUT
+ elif crb == 'pktgen':
+ self.info_lvl = logging.DTS_PKTGEN_CMD
+ self.debug_lvl = logging.DTS_PKTGEN_OUTPUT
elif crb == 'virtdut':
self.info_lvl = logging.DTS_VIRTDUT_CMD
self.debug_lvl = logging.DTS_VIRTDUT_OUTPUT
@@ -428,7 +445,7 @@ class LogParser(object):
# only handle case log
m = self.case_pattern.match(line.values()[0])
if m:
- # not determine case will start from begining
+ # not determine case will start from beginning
if case_name is None:
begin = self.loglist.index(line)
# start from the determined case
--
1.9.3
next prev parent reply other threads:[~2019-08-05 5:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-05 5:50 [dts] [PATCH V1 0/10] [next]dts/pktgen: add new feature and fix some internal bugs yufengmx
2019-08-05 5:50 ` [dts] [PATCH V1 1/10] [next]conf/pktgen: update option description yufengmx
2019-08-05 5:50 ` [dts] [PATCH V1 2/10] [next]doc/dts_gsg/pktgen_prog_guide: update description yufengmx
2019-08-05 5:50 ` yufengmx [this message]
2019-08-05 5:50 ` [dts] [PATCH V1 4/10] [next]framework/dut: fix logger quit issue yufengmx
2019-08-05 5:50 ` [dts] [PATCH V1 5/10] [next]framework/tester: " yufengmx
2019-08-05 5:50 ` [dts] [PATCH V1 6/10] [next]framework/pktgen_base: add new feature and fix yufengmx
2019-08-05 5:50 ` [dts] [PATCH V1 7/10] [next]framework/pktgen_ixia: " yufengmx
2019-08-05 5:50 ` [dts] [PATCH V1 8/10] [next]framework/pktgen_trex: " yufengmx
2019-08-05 5:50 ` [dts] [PATCH V1 9/10] [next]framework/pktgen: add new feature and fix internal yufengmx
2019-08-05 5:50 ` [dts] [PATCH V1 0/10] [next]tests/nic_single_core_perf: update pktgen input yufengmx
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1564984244-151448-4-git-send-email-yufengx.mo@intel.com \
--to=yufengx.mo@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).