diff options
author | Vratko Polak <vrpolak@cisco.com> | 2019-07-16 14:32:55 +0200 |
---|---|---|
committer | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2019-07-16 16:33:06 +0000 |
commit | b659020337e3e72f7480098dbee93b45d4dec1f2 (patch) | |
tree | b09da6b4d72d643d4b7768f100feb1ceb45ff1c4 /src/vpp-api/python/vpp_papi | |
parent | 31b315707f148a087a206214159d8957cc9f9cfb (diff) |
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 <vrpolak@cisco.com>
Diffstat (limited to 'src/vpp-api/python/vpp_papi')
-rw-r--r-- | src/vpp-api/python/vpp_papi/vpp_papi.py | 24 |
1 files changed, 6 insertions, 18 deletions
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): |