diff options
author | Brendan Long <self@brendanlong.com> | 2019-02-09 19:29:01 +0300 |
---|---|---|
committer | Brendan Long <self@brendanlong.com> | 2019-02-09 22:04:18 +0300 |
commit | 0c64f2686b3be32108e8b7e3d0c69df8ffaa5ddf (patch) | |
tree | c75b657a7c1c4c6f82f42722d774f41181a7e9f3 /plugins | |
parent | 5d6566b22041fe199489489da5d98bf1b27e19a3 (diff) |
Simplify TT-RSS error logging
There was debug logging littered across the code, printing every request
and response 2-3 times.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/backend/ttrss/ttrssAPI.vala | 16 | ||||
-rw-r--r-- | plugins/backend/ttrss/ttrssMessage.vala | 27 |
2 files changed, 10 insertions, 33 deletions
diff --git a/plugins/backend/ttrss/ttrssAPI.vala b/plugins/backend/ttrss/ttrssAPI.vala index 41a8b588..ae2cd267 100644 --- a/plugins/backend/ttrss/ttrssAPI.vala +++ b/plugins/backend/ttrss/ttrssAPI.vala @@ -66,8 +66,6 @@ public LoginResponse login() message.add_string("user", username); message.add_string("password", passwd); int status = message.send(); - if(status != ConnectionError.NO_RESPONSE) - message.printResponse(); if(status == ConnectionError.SUCCESS) { @@ -84,11 +82,6 @@ public LoginResponse login() return LoginResponse.PLUGIN_NEEDED; } - else - { - message.printMessage(); - message.printResponse(); - } if(status == ConnectionError.API_ERROR) { @@ -121,7 +114,6 @@ public bool logout() message.add_string("op", "logout"); int status = message.send(); Logger.warning("TTRSS: logout"); - message.printResponse(); if(status == ConnectionError.SUCCESS) { @@ -141,7 +133,6 @@ public bool isloggedin() message.add_string("op", "isLoggedIn"); int status = message.send(); Logger.debug("TTRSS: isloggedin?"); - message.printResponse(); if(status == ConnectionError.SUCCESS) { @@ -456,7 +447,6 @@ public void getHeadlines(Gee.List<Article> articles, int skip, int limit, Articl } int status = message.send(); - message.printMessage(); if(status == ConnectionError.SUCCESS) { @@ -540,7 +530,6 @@ public Gee.List<string>? NewsPlus(ArticleStatus type, int limit) else return null; int status = message.send(); - message.printMessage(); if(status == ConnectionError.SUCCESS) { @@ -783,9 +772,6 @@ public bool subscribeToFeed(string feedURL, string? catID, string? username, str } int msg_status = message.send(); - message.printMessage(); - message.printResponse(); - Logger.debug(message.getStatusCode().to_string()); if(msg_status == ConnectionError.SUCCESS) { @@ -850,8 +836,6 @@ public string? createCategory(string title, int? parentID = null) if(parentID != null) message.add_int("parent_id", parentID); int status = message.send(); - message.printMessage(); - if(status == ConnectionError.SUCCESS) { diff --git a/plugins/backend/ttrss/ttrssMessage.vala b/plugins/backend/ttrss/ttrssMessage.vala index 9b7de310..53f7ca00 100644 --- a/plugins/backend/ttrss/ttrssMessage.vala +++ b/plugins/backend/ttrss/ttrssMessage.vala @@ -71,8 +71,7 @@ public ConnectionError send(bool ping = false) var error = send_impl(ping); if(error != ConnectionError.SUCCESS) { - printMessage(); - printResponse(); + logError("Error response from TT-RSS API"); } return error; @@ -148,7 +147,7 @@ public ConnectionError send_impl(bool ping) parseError(content); } - return ApiError(); + return apiError(); } else if(m_response_object.get_int_member("status") == 0) { @@ -202,16 +201,12 @@ public uint getStatusCode() return m_message_soup.status_code; } -public void printMessage() +private void logError(string prefix) { - var msg = request_object_to_string(); - if (!msg.contains("password")) - Logger.debug(msg); -} - -public void printResponse() -{ - Logger.debug((string)m_message_soup.response_body.flatten().data); + var url = m_message_soup.get_uri().to_string(false); + var request = request_object_to_string(); + var response = (string)m_message_soup.response_body.flatten().data; + Logger.error(@"$prefix\nURL: $url\nRequest object: $request\nResponse: $response"); } private ConnectionError parseError(Json.Object err) @@ -228,14 +223,12 @@ private ConnectionError parseError(Json.Object err) return ConnectionError.API_DISABLED; } - return ApiError(); + return apiError(); } -private ConnectionError ApiError() +private ConnectionError apiError() { - Logger.error("ttrss api error"); - printMessage(); - printResponse(); + logError("TT-RSS API error"); return ConnectionError.API_ERROR; } } |