From b659020337e3e72f7480098dbee93b45d4dec1f2 Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Tue, 16 Jul 2019 14:32:55 +0200 Subject: papi: use the injected logger wherever possible As the injected logger is already expected to be used everywhere, this is a fix. The few lines in vpp_serializer.py are not fixed, but they are not encountered in CSIT testing. Functions call_logger and return_logger have single call site each (and confusing names, as they do not log), so saved few lines by inlining them. Type: fix Change-Id: I7dd1e610ef6b885943708bf78bddedfbcf4daa1a Signed-off-by: Vratko Polak --- src/vpp-api/python/vpp_papi/vpp_papi.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'src/vpp-api/python') diff --git a/src/vpp-api/python/vpp_papi/vpp_papi.py b/src/vpp-api/python/vpp_papi/vpp_papi.py index 5207bbf0bb4..a4523b46329 100644 --- a/src/vpp-api/python/vpp_papi/vpp_papi.py +++ b/src/vpp-api/python/vpp_papi/vpp_papi.py @@ -30,8 +30,6 @@ import atexit from . vpp_serializer import VPPType, VPPEnumType, VPPUnionType from . vpp_serializer import VPPMessage, vpp_get_type, VPPTypeAlias -logger = logging.getLogger(__name__) - if sys.version[0] == '2': import Queue as queue else: @@ -78,19 +76,6 @@ else: return d.items() -def call_logger(msgdef, kwargs): - s = 'Calling {}('.format(msgdef.name) - for k, v in kwargs.items(): - s += '{}:{} '.format(k, v) - s += ')' - return s - - -def return_logger(r): - s = 'Return from {}'.format(r) - return s - - class VppApiDynamicMethodHolder(object): pass @@ -220,7 +205,8 @@ class VPPApiClient(object): to report at (from the loglevels in the logging module). """ if logger is None: - logger = logging.getLogger(__name__) + logger = logging.getLogger( + "{}.{}".format(__name__, self.__class__.__name__)) if loglevel is not None: logger.setLevel(loglevel) self.logger = logger @@ -631,7 +617,9 @@ class VPPApiClient(object): pass self.validate_args(msgdef, kwargs) - logging.debug(call_logger(msgdef, kwargs)) + s = 'Calling {}({})'.format(msgdef.name, + ','.join(['{!r}:{!r}'.format(k, v) for k, v in kwargs.items()])) + self.logger.debug(s) b = msgdef.pack(kwargs) self.transport.suspend() @@ -666,7 +654,7 @@ class VPPApiClient(object): self.transport.resume() - logger.debug(return_logger(rl)) + self.logger.debug('Return from {!r}'.format(r)) return rl def _call_vpp_async(self, i, msg, **kwargs): -- cgit 1.2.3-korg