X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvpp-api%2Fpython%2Fvpp_papi.py;h=ece0e4ee52dcc2ef491452b84c18695199f97a67;hb=refs%2Fchanges%2F04%2F13104%2F1;hp=35edd4910855962e33f83048c73dc4c9bcb01727;hpb=afddd83ca17484c0f26efbebb6ff7ebe47fd567f;p=vpp.git diff --git a/src/vpp-api/python/vpp_papi.py b/src/vpp-api/python/vpp_papi.py index 35edd491085..ece0e4ee52d 100644 --- a/src/vpp-api/python/vpp_papi.py +++ b/src/vpp-api/python/vpp_papi.py @@ -116,7 +116,7 @@ class VPP(): these messages in a background thread. """ def __init__(self, apifiles=None, testmode=False, async_thread=True, - logger=logging.getLogger('vpp_papi'), loglevel='debug', + logger=None, loglevel=None, read_timeout=0): """Create a VPP API object. @@ -125,11 +125,20 @@ class VPP(): dynamically created reflecting these APIs. If not provided this will load the API files from VPP's default install location. + + logger, if supplied, is the logging logger object to log to. + loglevel, if supplied, is the log level this logger is set + to report at (from the loglevels in the logging module). """ global vpp_object vpp_object = self + + if logger is None: + logger = logging.getLogger(__name__) + if loglevel is not None: + logger.setLevel(loglevel) + self.logger = logger - logging.basicConfig(level=getattr(logging, loglevel.upper())) self.messages = {} self.id_names = [] @@ -221,7 +230,7 @@ class VPP(): localdir = os.path.dirname(os.path.realpath(main.__file__)) else: # use cwd if there is no calling script - localdir = os.cwd() + localdir = os.getcwd() localdir_s = localdir.split(os.path.sep) def dmatch(dir): @@ -639,7 +648,7 @@ class VPP(): """Send a binary-packed message to VPP.""" if not self.connected: raise IOError(1, 'Not connected') - return vpp_api.vac_write(str(buf), len(buf)) + return vpp_api.vac_write(bytes(buf), len(buf)) def _read(self): if not self.connected: