Browse files

Added logging the queries to CouchDb as debug level.

  • Loading branch information...
1 parent d6108a4 commit cf7e617bcc12f210f1875ea77516544d5c1aa498 @pgelinas pgelinas committed Dec 3, 2012
View
5 org.ektorp/src/main/java/org/ektorp/ViewQuery.java
@@ -860,6 +860,11 @@ public void setIgnoreNotFound(boolean ignoreNotFound) {
public boolean isIgnoreNotFound() {
return ignoreNotFound;
}
+
+ @Override
+ public String toString() {
+ return buildQuery();
+ }
public static class Keys {
View
15 org.ektorp/src/main/java/org/ektorp/impl/StdCouchDbConnector.java
@@ -425,14 +425,17 @@ public String getDatabaseName() {
private <T> T executeQuery(final ViewQuery query,
ResponseCallback<T> rh) {
+ LOG.debug("Querying CouchDb view at {}.", query);
+ T result;
if (!query.isCacheOk()) {
- return query.hasMultipleKeys() ? restTemplate.postUncached(query.buildQuery(),
- query.getKeysAsJson(), rh) : restTemplate.getUncached(
- query.buildQuery(), rh);
+ result = query.hasMultipleKeys() ? restTemplate.postUncached(query.buildQuery(), query.getKeysAsJson(), rh)
+ : restTemplate.getUncached(query.buildQuery(), rh);
+ } else {
+ result = query.hasMultipleKeys() ? restTemplate.post(query.buildQuery(), query.getKeysAsJson(), rh)
+ : restTemplate.get(query.buildQuery(), rh);
}
- return query.hasMultipleKeys() ? restTemplate.post(query.buildQuery(),
- query.getKeysAsJson(), rh) : restTemplate.get(
- query.buildQuery(), rh);
+ LOG.debug("Answer from view query: {}.", result);
+ return result;
}
@Override

0 comments on commit cf7e617

Please sign in to comment.