Skip to content

Commit 56124b4

Browse files
author
Morten Brix Pedersen
committed
Log requests
1 parent c74fe85 commit 56124b4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

library/src/main/java/com/queue_it/androidsdk/QueueService.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@
33
import android.content.Context;
44
import android.os.Handler;
55
import android.text.TextUtils;
6+
import android.util.Log;
67

78

89
import org.json.JSONException;
910
import org.json.JSONObject;
1011

1112
import java.io.IOException;
13+
import java.text.DateFormat;
14+
import java.text.SimpleDateFormat;
15+
import java.util.Calendar;
16+
import java.util.Date;
17+
import java.util.Locale;
18+
import java.util.TimeZone;
1219

1320
import okhttp3.Call;
1421
import okhttp3.Callback;
@@ -62,7 +69,11 @@ public void init(final Context context)
6269

6370
OkHttpClient client = new OkHttpClient();
6471

65-
RequestBody body = RequestBody.create(JSON, getJsonObject().toString());
72+
String putBody = getJsonObject().toString();
73+
RequestBody body = RequestBody.create(JSON, putBody);
74+
75+
Log.v("QueueITEngine", "API call " + getISO8601StringForDate(Calendar.getInstance().getTime()) + ": " + url + ": " + putBody);
76+
6677
Request request = new Request.Builder()
6778
.url(url)
6879
.put(body)
@@ -120,6 +131,12 @@ public void run() {
120131
});
121132
}
122133

134+
private static String getISO8601StringForDate(Date date) {
135+
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
136+
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
137+
return dateFormat.format(date);
138+
}
139+
123140
private String optString(JSONObject json, String key)
124141
{
125142
if (json.isNull(key))

0 commit comments

Comments
 (0)