Skip to content

Commit

Permalink
added pretty-print on extracted IntraReq when in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
zznate committed Mar 10, 2013
1 parent e885c5d commit dd46110
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/org/usergrid/vx/experimental/IntraHandlerJson.java
Expand Up @@ -17,6 +17,7 @@


import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.commons.lang.exception.ExceptionUtils;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.usergrid.vx.handler.RequestJsonHandler; import org.usergrid.vx.handler.RequestJsonHandler;
Expand All @@ -40,11 +41,19 @@
* of {@link IHResponse}</li> * of {@link IHResponse}</li>
* <li>IHResponse with send the response via the end method of HttpServerRequest</li> * <li>IHResponse with send the response via the end method of HttpServerRequest</li>
* </ol> * </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>{ public class IntraHandlerJson implements Handler<HttpServerRequest>{
private static Logger logger = LoggerFactory.getLogger(IntraHandlerJson.class); private static Logger logger = LoggerFactory.getLogger(IntraHandlerJson.class);


private static ObjectMapper mapper = new ObjectMapper(); 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; private final Vertx vertx;


Expand All @@ -65,6 +74,10 @@ private void handleRequestAsync(final HttpServerRequest request, Buffer buffer)
IntraReq req = null; IntraReq req = null;
try { try {
req = mapper.readValue(buffer.getBytes(), IntraReq.class); 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, vertx.eventBus().send(RequestJsonHandler.IHJSON_HANDLER_TOPIC,
req.toJson(), req.toJson(),
new IHResponse(request)); new IHResponse(request));
Expand Down

0 comments on commit dd46110

Please sign in to comment.