[geany/geany-plugins] 5d4dc3: geniuspaste: Log both request and response separately for debugging
Colomban Wendling
git-noreply at xxxxx
Sun Feb 21 08:49:48 UTC 2016
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sat, 16 Jan 2016 23:33:13 UTC
Commit: 5d4dc34ccb08a065117c7ab9fe4eed8f54fce340
https://github.com/geany/geany-plugins/commit/5d4dc34ccb08a065117c7ab9fe4eed8f54fce340
Log Message:
-----------
geniuspaste: Log both request and response separately for debugging
The request and response might be sensibly different, and their
respective URI especially matters, so log them both separately.
Modified Paths:
--------------
geniuspaste/src/geniuspaste.c
Modified: geniuspaste/src/geniuspaste.c
43 lines changed, 26 insertions(+), 17 deletions(-)
===================================================================
@@ -606,6 +606,29 @@ static void show_msgbox(GtkMessageType type, GtkButtonsType buttons,
gtk_widget_destroy(dlg);
}
+static void debug_log_message_body(SoupMessage *msg,
+ SoupMessageBody *body,
+ const gchar *label)
+{
+ if (geany->app->debug_mode)
+ {
+ gchar *real_uri = soup_uri_to_string(soup_message_get_uri(msg), FALSE);
+
+ soup_message_body_flatten(body);
+ msgwin_msg_add(COLOR_BLUE, -1, NULL,
+ "[geniuspaste] %s:\n"
+ "URI: %s\n"
+ "Body: %s\n"
+ "Code: %d (%s)",
+ label,
+ real_uri,
+ body->data,
+ msg->status_code,
+ msg->reason_phrase);
+ g_free(real_uri);
+ }
+}
+
static void paste(GeanyDocument * doc, const gchar * website)
{
const Pastebin *pastebin;
@@ -645,26 +668,12 @@ static void paste(GeanyDocument * doc, const gchar * website)
session = soup_session_async_new_with_options(SOUP_SESSION_USER_AGENT, user_agent, NULL);
g_free(user_agent);
+ debug_log_message_body(msg, msg->request_body, "Request");
+
status = soup_session_send_message(session, msg);
g_object_unref(session);
- if (geany->app->debug_mode)
- {
- gchar *real_uri = soup_uri_to_string(soup_message_get_uri(msg), FALSE);
-
- soup_message_body_flatten(msg->request_body);
- msgwin_msg_add(COLOR_BLUE, -1, NULL,
- "[geniuspaste] %s\n"
- "Request: %s\n"
- "Response: %s\n"
- "Code: %d (%s)",
- real_uri,
- msg->request_body->data,
- msg->response_body->data,
- msg->status_code,
- msg->reason_phrase);
- g_free(real_uri);
- }
+ debug_log_message_body(msg, msg->response_body, "Response");
if (! SOUP_STATUS_IS_SUCCESSFUL(status))
{
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list