From 01337c3399914849b45857a8d2b132efd0fc508f Mon Sep 17 00:00:00 2001 From: Christos KK Loverdos Date: Wed, 13 Mar 2013 15:56:55 +0200 Subject: [PATCH] Enhance logging --- src/gr/grnet/pithos/web/client/Pithos.java | 23 ++++++++++++++++++++ .../pithos/web/client/catalog/GetUserCatalogs.java | 14 +++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/gr/grnet/pithos/web/client/Pithos.java b/src/gr/grnet/pithos/web/client/Pithos.java index 5e29ee0..f21477c 100644 --- a/src/gr/grnet/pithos/web/client/Pithos.java +++ b/src/gr/grnet/pithos/web/client/Pithos.java @@ -341,7 +341,30 @@ public class Pithos implements EntryPoint, ResizeHandler { final StringBuilder sb = new StringBuilder(); for(Object arg : args) { sb.append(arg); + if(arg instanceof Throwable) { + sb.append("\nCauses (including original):\n"); + final Throwable error = (Throwable) arg; + Throwable cause = error; + while(cause != null) { + sb.append(" "); + sb.append(cause.toString()); + sb.append("\n"); + cause = cause.getCause(); + } + + sb.append("Stack trace of original: "); + sb.append(error.toString()); + sb.append("\n"); + StackTraceElement[] stackTrace = error.getStackTrace(); + for(StackTraceElement errorElem : stackTrace) { + sb.append(" "); + sb.append(errorElem.toString()); + sb.append("\n"); + } + } } + + if(sb.length() > 0) { __ConsoleLog(sb.toString()); } diff --git a/src/gr/grnet/pithos/web/client/catalog/GetUserCatalogs.java b/src/gr/grnet/pithos/web/client/catalog/GetUserCatalogs.java index f006764..916702b 100644 --- a/src/gr/grnet/pithos/web/client/catalog/GetUserCatalogs.java +++ b/src/gr/grnet/pithos/web/client/catalog/GetUserCatalogs.java @@ -42,6 +42,7 @@ import com.google.gwt.json.client.JSONArray; import com.google.gwt.json.client.JSONObject; import com.google.gwt.json.client.JSONParser; import com.google.gwt.json.client.JSONValue; +import gr.grnet.pithos.web.client.Const; import gr.grnet.pithos.web.client.Helpers; import gr.grnet.pithos.web.client.Pithos; @@ -51,6 +52,7 @@ import java.util.List; * The request via which we obtain user catalog info. */ public class GetUserCatalogs implements Scheduler.ScheduledCommand { + private final Pithos app; private final String url; private final String userToken; private final List ids; @@ -78,6 +80,8 @@ public class GetUserCatalogs implements Scheduler.ScheduledCommand { public GetUserCatalogs(Pithos app, List ids, List names) { assert app != null; + this.app = app; + // FIXME: Probably use Window.Location.getHost() // https://server.com/v1/ --> https://server.com String path = app.getApiPath(); @@ -133,14 +137,16 @@ public class GetUserCatalogs implements Scheduler.ScheduledCommand { } public void onError(Request request, Throwable t) { - GWT.log("GetUserCatalogs", t); + app.LOG("GetUserCatalogs ", t); } @Override public void execute() { final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, getURL()); - rb.setHeader("X-Auth-Token", userToken); + rb.setHeader(Const.X_AUTH_TOKEN, userToken); final String requestData = makeRequestData().toString(); + app.LOG("GetUserCatalog => ", requestData); + app.LOG(new Exception()); try { rb.sendRequest(requestData, new RequestCallback() { @@ -149,12 +155,14 @@ public class GetUserCatalogs implements Scheduler.ScheduledCommand { final int statusCode = response.getStatusCode(); if(statusCode != SuccessCode) { + app.LOG("GetUserCatalog <= [", statusCode, " ", response.getStatusText(), "]"); GetUserCatalogs.this.onBadStatusCode(request, response); return; } final String responseText = response.getText(); final JSONValue jsonValue = JSONParser.parseStrict(responseText); + app.LOG("GetUserCatalog <= ", jsonValue.toString()); final JSONObject result = jsonValue.isObject(); if(result == null) { @@ -174,7 +182,7 @@ public class GetUserCatalogs implements Scheduler.ScheduledCommand { }); } catch(Exception e) { - GWT.log("GetUserCatalogs", e); + app.LOG("GetUserCatalogs. ", e); } } -- 1.7.10.4