log request in QueryServiceServlet
Change-Id: Iceb265553bd20f4ab964a769892169f2c62e44a4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1232
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
index c7adc25..427e177 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
@@ -226,6 +226,23 @@
String format;
boolean pretty;
String clientContextID;
+
+ @Override
+ public String toString() {
+ return append(new StringBuilder()).toString();
+ }
+
+ public StringBuilder append(final StringBuilder sb) {
+ sb.append("{ ");
+ sb.append("\"statement\": \"");
+ JSONUtil.escape(sb, statement);
+ sb.append("\", ");
+ sb.append("\"format\": \"").append(format).append("\", ");
+ sb.append("\"pretty\": ").append(pretty).append(", ");
+ sb.append("\"clientContextID\": \"").append(clientContextID).append("\" ");
+ sb.append('}');
+ return sb;
+ }
}
private static String getParameterValue(String content, String attribute) {
@@ -426,6 +443,7 @@
}
private void handleRequest(RequestParameters param, HttpServletResponse response) throws IOException {
+ LOGGER.info(param.toString());
long elapsedStart = System.nanoTime();
final StringWriter stringWriter = new StringWriter();
final PrintWriter resultWriter = new PrintWriter(stringWriter);
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/JSONUtil.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/JSONUtil.java
index 0b973e1..fd89c5e 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/JSONUtil.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/JSONUtil.java
@@ -112,7 +112,7 @@
return escape(new StringBuilder(), str).toString();
}
- private static StringBuilder escape(StringBuilder sb, String str) {
+ public static StringBuilder escape(StringBuilder sb, String str) {
for (int i = 0; i < str.length(); ++i) {
appendEsc(sb, str.charAt(i));
}