add debug and trace logs to couchdb river

This commit is contained in:
kimchy 2010-11-02 01:07:06 +02:00
parent 4ff1b429f1
commit dd9553e7cc
1 changed files with 13 additions and 0 deletions

View File

@ -212,9 +212,15 @@ public class CouchdbRiver extends AbstractRiverComponent implements River {
if (ctx.containsKey("ignore") && ctx.get("ignore").equals(Boolean.TRUE)) { if (ctx.containsKey("ignore") && ctx.get("ignore").equals(Boolean.TRUE)) {
// ignore dock // ignore dock
} else if (ctx.containsKey("deleted") && ctx.get("deleted").equals(Boolean.TRUE)) { } else if (ctx.containsKey("deleted") && ctx.get("deleted").equals(Boolean.TRUE)) {
if (logger.isTraceEnabled()) {
logger.trace("processing [delete]: [{}]/[{}]/[{}]", indexName, typeName, id);
}
bulk.add(deleteRequest(indexName).type(typeName).id(id)); bulk.add(deleteRequest(indexName).type(typeName).id(id));
} else if (ctx.containsKey("doc")) { } else if (ctx.containsKey("doc")) {
Map<String, Object> doc = (Map<String, Object>) ctx.get("doc"); Map<String, Object> doc = (Map<String, Object>) ctx.get("doc");
if (logger.isTraceEnabled()) {
logger.trace("processing [index ]: [{}]/[{}]/[{}], source {}", indexName, typeName, id, doc);
}
bulk.add(indexRequest(indexName).type(typeName).id(id).source(doc)); bulk.add(indexRequest(indexName).type(typeName).id(id).source(doc));
} else { } else {
logger.warn("ignoring unknown change {}", s); logger.warn("ignoring unknown change {}", s);
@ -264,6 +270,9 @@ public class CouchdbRiver extends AbstractRiverComponent implements River {
if (lastSeq != null) { if (lastSeq != null) {
try { try {
if (logger.isTraceEnabled()) {
logger.trace("processing [_seq ]: [{}]/[{}]/[{}], last_seq [{}]", riverIndexName, riverName.name(), "_seq", lastSeq);
}
bulk.add(indexRequest(riverIndexName).type(riverName.name()).id("_seq") bulk.add(indexRequest(riverIndexName).type(riverName.name()).id("_seq")
.source(jsonBuilder().startObject().startObject("couchdb").field("last_seq", lastSeq).endObject().endObject())); .source(jsonBuilder().startObject().startObject("couchdb").field("last_seq", lastSeq).endObject().endObject()));
} catch (IOException e) { } catch (IOException e) {
@ -330,6 +339,10 @@ public class CouchdbRiver extends AbstractRiverComponent implements River {
file = file + "&since=" + lastSeq; file = file + "&since=" + lastSeq;
} }
if (logger.isDebugEnabled()) {
logger.debug("using host [{}], port [{}], path [{}]", couchHost, couchPort, file);
}
HttpURLConnection connection = null; HttpURLConnection connection = null;
InputStream is = null; InputStream is = null;
try { try {