diff --git a/pubnub/endpoints/endpoint.py b/pubnub/endpoints/endpoint.py index aee7e370..cc4e3592 100644 --- a/pubnub/endpoints/endpoint.py +++ b/pubnub/endpoints/endpoint.py @@ -134,6 +134,7 @@ def options(self): create_status=self.create_status, create_exception=self.create_exception, operation_type=self.operation_type(), + operation_name=self.name(), data=data, files=self.build_file_upload_request(), sort_arguments=self._sort_params, diff --git a/pubnub/request_handlers/async_aiohttp.py b/pubnub/request_handlers/async_aiohttp.py index 3b057b66..e2323d28 100644 --- a/pubnub/request_handlers/async_aiohttp.py +++ b/pubnub/request_handlers/async_aiohttp.py @@ -173,7 +173,7 @@ async def async_request(self, options_func, cancellation_event): else: data = "N/A" - logger.debug("[%s %s] %s" % (options.operation_type, response_info.http_version, data)) + logger.debug("[%s %s] %s", options.operation_name, response_info.http_version, data) if response.status not in (200, 307, 204): diff --git a/pubnub/request_handlers/async_httpx.py b/pubnub/request_handlers/async_httpx.py index 512e4a56..26507a4c 100644 --- a/pubnub/request_handlers/async_httpx.py +++ b/pubnub/request_handlers/async_httpx.py @@ -226,7 +226,7 @@ async def async_request(self, options_func, cancellation_event): else: data = "N/A" - logger.debug("[%s %s] %s" % (options.operation_type, response_info.http_version, data)) + logger.debug("[%s %s] %s", options.operation_name, response_info.http_version, data) if response.status_code not in (200, 307, 204): diff --git a/pubnub/request_handlers/httpx.py b/pubnub/request_handlers/httpx.py index b0ad5c37..aa893cb1 100644 --- a/pubnub/request_handlers/httpx.py +++ b/pubnub/request_handlers/httpx.py @@ -436,13 +436,13 @@ def _invoke_request(self, p_options, e_options, base_origin): res = session.request(**args) try: - logger.debug("[%s %s] %s" % (e_options.operation_type, res.http_version, res.text)) + logger.debug("[%s %s] %s", e_options.operation_name, res.http_version, res.text) except httpx.ResponseNotRead: content = res.content.decode('utf-8', errors='ignore') - logger.debug("[%s %s] %s" % (e_options.operation_type, res.http_version, content)) + logger.debug("[%s %s] %s", e_options.operation_name, res.http_version, content) except Exception as e: msg = "(content access failed: %s)" % str(e) - logger.debug("[%s %s] %s" % (e_options.operation_type, res.http_version, msg)) + logger.debug("[%s %s] %s", e_options.operation_name, res.http_version, msg) except httpx.ConnectError as e: if use_watchdog and self._watchdog.triggered: diff --git a/pubnub/request_handlers/requests.py b/pubnub/request_handlers/requests.py index 781d65ec..d2c2f497 100644 --- a/pubnub/request_handlers/requests.py +++ b/pubnub/request_handlers/requests.py @@ -276,7 +276,7 @@ def _invoke_request(self, p_options, e_options, base_origin): f"HTTP/{res.raw.version // 10}.{res.raw.version % 10}" if res.raw and res.raw.version else "unknown" ) - logger.debug("[%s %s] %s" % (e_options.operation_type, http_ver, res.text)) + logger.debug("[%s %s] %s", e_options.operation_name, http_ver, res.text) except requests.exceptions.ConnectionError as e: raise PubNubException( diff --git a/pubnub/structures.py b/pubnub/structures.py index af7575c3..7d6e577e 100644 --- a/pubnub/structures.py +++ b/pubnub/structures.py @@ -8,7 +8,8 @@ def __init__( create_response, create_status, create_exception, operation_type, data=None, sort_arguments=False, allow_redirects=True, use_base_path=None, files=None, - request_headers=None, non_json_response=False + request_headers=None, non_json_response=False, + operation_name=None ): assert len(path) > 0 assert callable(params_callback) @@ -35,6 +36,7 @@ def __init__( self.create_status = create_status self.create_exception = create_exception self.operation_type = operation_type + self.operation_name = operation_name self.allow_redirects = allow_redirects self.use_base_path = use_base_path self.request_headers = request_headers