From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mogw1222.ocn.ad.jp (mogw1222.ocn.ad.jp [153.149.235.23]) by dpdk.org (Postfix) with ESMTP id 481111B320 for ; Tue, 3 Oct 2017 12:42:38 +0200 (CEST) Received: from mf-smf-ucb018.ocn.ad.jp (mf-smf-ucb018.ocn.ad.jp [153.149.227.67]) by mogw1222.ocn.ad.jp (Postfix) with ESMTP id 5F018100002A; Tue, 3 Oct 2017 19:42:36 +0900 (JST) Received: from mf-smf-ucb018.ocn.ad.jp (mf-smf-ucb018 [153.149.227.67]) by mf-smf-ucb018.ocn.ad.jp (Postfix) with ESMTP id 4497320626; Tue, 3 Oct 2017 19:42:36 +0900 (JST) Received: from ntt.pod01.mv-mta-ucb027 (mv-mta-ucb027.ocn.ad.jp [153.149.142.101]) by mf-smf-ucb018.ocn.ad.jp (Switch-3.3.4/Switch-3.3.4) with ESMTP id v93AgFK1016850; Tue, 3 Oct 2017 19:42:36 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.166]) by ntt.pod01.mv-mta-ucb027 with id Gyib1w0013c2f7501yibmc; Tue, 03 Oct 2017 10:42:35 +0000 Received: from localhost.localdomain (sp1-75-231-175.msb.spmode.ne.jp [1.75.231.175]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Tue, 3 Oct 2017 19:42:35 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org Cc: gerald.rogers@intel.com, sy.jong.choi@intel.com, Yasufumi Ogawa Date: Tue, 3 Oct 2017 19:42:14 +0900 Message-Id: <20171003104214.81003-3-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20171003104214.81003-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20171003104214.81003-1-ogawa.yasufumi@lab.ntt.co.jp> Subject: [spp] [PATCH 3/3] spp: change logger to optional X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Oct 2017 10:42:38 -0000 From: Yasufumi Ogawa 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 --- 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