From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org
Cc: gerald.rogers@intel.com, sy.jong.choi@intel.com,
Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Subject: [spp] [PATCH 3/3] spp: change logger to optional
Date: Tue, 3 Oct 2017 19:42:14 +0900 [thread overview]
Message-ID: <20171003104214.81003-3-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20171003104214.81003-1-ogawa.yasufumi@lab.ntt.co.jp>
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Logger in spp.py is used only for debugging and useless for users.
Use of logger is selectable by comment/uncomment logger's setting
defined after importing libraries.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/spp.py | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/src/spp.py b/src/spp.py
index 4bbbb44..ce8aff0 100755
--- a/src/spp.py
+++ b/src/spp.py
@@ -18,14 +18,17 @@ import readline
import threading
import json
-from logging import getLogger,StreamHandler,Formatter,DEBUG
-logger = getLogger(__name__)
-handler = StreamHandler()
-handler.setLevel(DEBUG)
-formatter = Formatter('%(asctime)s - [%(name)s] - [%(levelname)s] - %(message)s')
-handler.setFormatter(formatter)
-logger.setLevel(DEBUG)
-logger.addHandler(handler)
+logger = None
+
+# Comment out to activate debug logging
+#from logging import getLogger,StreamHandler,Formatter,DEBUG
+#logger = getLogger(__name__)
+#handler = StreamHandler()
+#handler.setLevel(DEBUG)
+#formatter = Formatter('%(asctime)s - [%(name)s] - [%(levelname)s] - %(message)s')
+#handler.setFormatter(formatter)
+#logger.setLevel(DEBUG)
+#logger.addHandler(handler)
CMD_OK = "OK"
@@ -53,13 +56,16 @@ class CmdRequestHandler(SocketServer.BaseRequestHandler):
CmdRequestHandler.CMD.onecmd(self.data)
ret = RCMD_RESULT_QUEUE.get()
if (ret is not None):
- logger.debug("ret:%s" % ret)
+ if logger != None:
+ logger.debug("ret:%s" % ret)
self.request.send(ret)
else:
- logger.debug("ret is none")
+ if logger != None:
+ logger.debug("ret is none")
self.request.send("")
else:
- logger.debug("CMD is None")
+ if logger != None:
+ logger.debug("CMD is None")
self.request.send("")
@@ -340,6 +346,7 @@ def clean_sec_cmd(cmdstr):
return res
+
class Shell(cmd.Cmd):
"""SPP command prompt"""
@@ -433,7 +440,8 @@ class Shell(cmd.Cmd):
param = result + '\n' + message
RCMD_RESULT_QUEUE.put(param)
else:
- logger.debug("unknown remote command = %s" % rcmd)
+ if logger != None:
+ logger.debug("unknown remote command = %s" % rcmd)
def do_status(self, _):
"""Display Soft Patch Panel Status"""
@@ -488,7 +496,7 @@ class Shell(cmd.Cmd):
def do_playback(self, fname):
"""Playback commands from a file: PLAYBACK filename.cmd"""
-
+
if fname == '':
print("Record file is required!")
else:
--
2.13.1
next prev parent reply other threads:[~2017-10-03 10:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-03 10:42 [spp] [PATCH 1/3] spp: fix bug of precmd ogawa.yasufumi
2017-10-03 10:42 ` [spp] [PATCH 2/3] spp: add record file check ogawa.yasufumi
2017-10-03 10:42 ` ogawa.yasufumi [this message]
2017-11-29 1:35 ` [spp] [PATCH 1/3] spp: fix bug of precmd Ferruh Yigit
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=20171003104214.81003-3-ogawa.yasufumi@lab.ntt.co.jp \
--to=ogawa.yasufumi@lab.ntt.co.jp \
--cc=gerald.rogers@intel.com \
--cc=spp@dpdk.org \
--cc=sy.jong.choi@intel.com \
/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).