Permalink
Browse files

added pretty-print on extracted IntraReq when in debug mode

  • Loading branch information...
1 parent e885c5d commit dd46110685dd61aa45bde17df251c733ae6e80eb @zznate committed Mar 10, 2013
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/main/java/org/usergrid/vx/experimental/IntraHandlerJson.java
View
13 src/main/java/org/usergrid/vx/experimental/IntraHandlerJson.java
@@ -17,6 +17,7 @@
import org.apache.commons.lang.exception.ExceptionUtils;
import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.usergrid.vx.handler.RequestJsonHandler;
@@ -40,11 +41,19 @@
* of {@link IHResponse}</li>
* <li>IHResponse with send the response via the end method of HttpServerRequest</li>
* </ol>
+ *
+ * In debug mode, this class will dump the payload received in the form of what was
+ * paesed into {@link IntraReq}
*/
public class IntraHandlerJson implements Handler<HttpServerRequest>{
private static Logger logger = LoggerFactory.getLogger(IntraHandlerJson.class);
private static ObjectMapper mapper = new ObjectMapper();
+ private static ObjectMapper indentObjectMapper = new ObjectMapper();
+
+ static {
+ indentObjectMapper.getSerializationConfig().set(SerializationConfig.Feature.INDENT_OUTPUT, true);
+ }
private final Vertx vertx;
@@ -65,6 +74,10 @@ private void handleRequestAsync(final HttpServerRequest request, Buffer buffer)
IntraReq req = null;
try {
req = mapper.readValue(buffer.getBytes(), IntraReq.class);
+ if ( logger.isDebugEnabled()) {
+ logger.debug("IntraJsonHandler received payload: \n{}",
+ indentObjectMapper.writeValueAsString(req));
+ }
vertx.eventBus().send(RequestJsonHandler.IHJSON_HANDLER_TOPIC,
req.toJson(),
new IHResponse(request));

0 comments on commit dd46110

Please sign in to comment.