mirror of https://github.com/OpenKMIP/PyKMIP.git
Merge pull request #446 from tipabu/improved-errors-and-logging
Improve errors and logging
This commit is contained in:
commit
a931850c51
|
@ -93,7 +93,7 @@ class ProxyKmipClient(object):
|
|||
Optional, defaults to None.
|
||||
|
||||
"""
|
||||
self.logger = logging.getLogger()
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
self.attribute_factory = attributes.AttributeFactory()
|
||||
self.object_factory = factory.ObjectFactory()
|
||||
|
@ -131,7 +131,7 @@ class ProxyKmipClient(object):
|
|||
self.proxy.open()
|
||||
self._is_open = True
|
||||
except Exception as e:
|
||||
self.logger.exception("could not open client connection", e)
|
||||
self.logger.error("could not open client connection: %s", e)
|
||||
raise
|
||||
|
||||
def close(self):
|
||||
|
@ -148,7 +148,7 @@ class ProxyKmipClient(object):
|
|||
self.proxy.close()
|
||||
self._is_open = False
|
||||
except Exception as e:
|
||||
self.logger.exception("could not close client connection", e)
|
||||
self.logger.error("could not close client connection: %s", e)
|
||||
raise
|
||||
|
||||
@is_connected
|
||||
|
|
|
@ -62,6 +62,7 @@ import os
|
|||
import six
|
||||
import socket
|
||||
import ssl
|
||||
import sys
|
||||
|
||||
FILE_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
CONFIG_FILE = os.path.normpath(os.path.join(FILE_PATH, '../kmipconfig.ini'))
|
||||
|
@ -224,15 +225,15 @@ class KMIPProxy:
|
|||
self.socket.connect((self.host, self.port))
|
||||
except Exception as e:
|
||||
self.logger.error("An error occurred while connecting to "
|
||||
"appliance " + self.host)
|
||||
"appliance %s: %s", self.host, e)
|
||||
self.socket.close()
|
||||
last_error = e
|
||||
last_error = sys.exc_info()
|
||||
else:
|
||||
return
|
||||
|
||||
self.socket = None
|
||||
if last_error:
|
||||
raise last_error
|
||||
six.reraise(*last_error)
|
||||
|
||||
def _create_socket(self, sock):
|
||||
self.socket = ssl.wrap_socket(
|
||||
|
|
Loading…
Reference in New Issue