mirror of
https://github.com/gogcom/galaxy-integrations-python-api.git
synced 2026-02-01 02:21:18 -05:00
PLINT-711 Enhancement for logging plugin responses
This commit is contained in:
@@ -299,14 +299,11 @@ class Connection():
|
||||
except TypeError:
|
||||
raise InvalidRequest()
|
||||
|
||||
def _send(self, data, sensitive=True):
|
||||
def _send(self, data, log_level=logging.DEBUG):
|
||||
try:
|
||||
line = self._encoder.encode(data)
|
||||
logger.log(log_level, "Sending data: %s", line)
|
||||
data = (line + "\n").encode("utf-8")
|
||||
if sensitive:
|
||||
logger.debug("Sending %d bytes of data", len(data))
|
||||
else:
|
||||
logger.debug("Sending data: %s", line)
|
||||
self._writer.write(data)
|
||||
except TypeError as error:
|
||||
logger.error(str(error))
|
||||
@@ -317,7 +314,7 @@ class Connection():
|
||||
"id": request_id,
|
||||
"result": result
|
||||
}
|
||||
self._send(response, sensitive=False)
|
||||
self._send(response, logging.INFO)
|
||||
|
||||
def _send_error(self, request_id, error):
|
||||
response = {
|
||||
@@ -325,8 +322,7 @@ class Connection():
|
||||
"id": request_id,
|
||||
"error": error.json()
|
||||
}
|
||||
|
||||
self._send(response, sensitive=False)
|
||||
self._send(response, logging.ERROR)
|
||||
|
||||
def _send_request(self, request_id, method, params):
|
||||
request = {
|
||||
@@ -335,7 +331,7 @@ class Connection():
|
||||
"id": request_id,
|
||||
"params": params
|
||||
}
|
||||
self._send(request, sensitive=True)
|
||||
self._send(request, logging.NOTSET)
|
||||
|
||||
def _send_notification(self, method, params):
|
||||
notification = {
|
||||
@@ -343,7 +339,7 @@ class Connection():
|
||||
"method": method,
|
||||
"params": params
|
||||
}
|
||||
self._send(notification, sensitive=True)
|
||||
self._send(notification, logging.NOTSET)
|
||||
|
||||
@staticmethod
|
||||
def _log_request(request, sensitive_params):
|
||||
|
||||
Reference in New Issue
Block a user