From 4820353bed7a650c7a1c6ee0709484682232eddb Mon Sep 17 00:00:00 2001 From: Daniel Teichmann Date: Thu, 1 Jul 2021 20:31:22 +0200 Subject: Alter logging statements --- rwa/support/sessionservice/service.py | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py index ecc465c..cdf2a1d 100755 --- a/rwa/support/sessionservice/service.py +++ b/rwa/support/sessionservice/service.py @@ -161,22 +161,22 @@ class RWASupportSessionService(dbus.service.Object): r = requests.post(url) except requests.exceptions.ConnectionError: - logging.warning(" resulted in a connection error.") + logging.warning("Handshake resulted in a connection error.") return {"status": "error", "type": "connection"} if not r.ok: - logging.warning(" resulted in a connection error.") + logging.warning("Handshake resulted in a connection error.") return {"status": "error", "type": "connection"} if not r.json()["allowed"]: - logging.warning(" was not permitted.") + logging.warning("Handshake was not permitted.") return {"status": "error", "type": "permission_denied"} if r.json().get("api_version") not in SUPPORTED_API_VERSIONS: - logging.warning(" resulted in a incompatible API version.") + logging.warning("Handshake resulted in a incompatible API version.") return {"status": "error", "type": "unsupported_server"} - logging.info(" was successful.") + logging.info("Handshake was successful.") return {"status": "success", "type": "valid_host"} @@ -216,17 +216,26 @@ class RWASupportSessionService(dbus.service.Object): if not self._is_url(host): logging.warning("Given URL is not valid!") logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host) - return json.dumps({"status": "error", "type": "invalid_url"}) + + response = json.dumps({"status": "error", "type": "invalid_url"}) + logging.debug('The response to D-Bus caller: "%s"', response) + return response if host in self.settings.web_app_hosts: logging.warning("Given URL is already present!") logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host) - return json.dumps({"status": "error", "type": "duplicate"}) + + response = json.dumps({"status": "error", "type": "duplicate"}) + logging.debug('The response to D-Bus caller: "%s"', response) + return response res = self._do_api_handshake(host) if res["status"] == "error": logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host) - return json.dumps(res) + + response = json.dumps(res) + logging.debug('The response to D-Bus caller: "%s"', response) + return response host_id = str(uuid4()) host_object = {"url": host} @@ -234,7 +243,7 @@ class RWASupportSessionService(dbus.service.Object): self.settings.web_app_hosts[host_id] = host_object self.settings.save_settings() - logging.debug('Added "%s" to "web_app_hosts" in user_settings', host) + logging.info('Added "%s" to "web_app_hosts" in user_settings', host) response = json.dumps(self._build_host_dict(host_id, host_object)) logging.debug('The response to D-Bus caller: "%s"', response) @@ -261,11 +270,12 @@ class RWASupportSessionService(dbus.service.Object): host_object = self.settings.web_app_hosts[host_id] del self.settings.web_app_hosts[host_id] self.settings.save_settings() - logging.debug('Removed web_app_hosts[%s]="%s" in user settings', host_id, host_object) + logging.info('Removed web_app_hosts[%s]="%s" in user settings', host_id, host_object) else: logging.warning("Given host index is not valid!") logging.debug( - "Did not remove web_app_hosts[%s] (not existent!) in " "user settings", host_id + "Did not remove web_app_hosts[%s]" + "(not existent!) in " "user settings", host_id ) return json.dumps({"status": "error", "type": "host_not_found"}) -- cgit v1.2.3