Coverage Report - org.mule.endpoint.inbound.InboundLoggingMessageProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
InboundLoggingMessageProcessor
0%
0/14
0%
0/4
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.endpoint.inbound;
 8  
 
 9  
 import org.mule.api.MuleEvent;
 10  
 import org.mule.api.MuleException;
 11  
 import org.mule.api.MuleMessage;
 12  
 import org.mule.api.endpoint.InboundEndpoint;
 13  
 import org.mule.api.processor.MessageProcessor;
 14  
 import org.mule.util.ObjectUtils;
 15  
 import org.mule.util.StringMessageUtils;
 16  
 
 17  
 import org.apache.commons.logging.Log;
 18  
 import org.apache.commons.logging.LogFactory;
 19  
 
 20  
 public class InboundLoggingMessageProcessor implements MessageProcessor
 21  
 {
 22  0
     protected final transient Log logger = LogFactory.getLog(getClass());
 23  
     protected InboundEndpoint endpoint;
 24  
 
 25  
     public InboundLoggingMessageProcessor(InboundEndpoint endpoint)
 26  0
     {
 27  0
         this.endpoint = endpoint;
 28  0
     }
 29  
 
 30  
     public MuleEvent process(MuleEvent event) throws MuleException
 31  
     {
 32  0
         MuleMessage message = event.getMessage();
 33  0
         if (logger.isDebugEnabled())
 34  
         {
 35  0
             logger.debug("Message Received on: " + endpoint.getEndpointURI());
 36  
         }
 37  0
         if (logger.isTraceEnabled())
 38  
         {
 39  
             try
 40  
             {
 41  0
                 logger.trace("Message Payload: \n"
 42  
                              + StringMessageUtils.truncate(StringMessageUtils.toString(message.getPayload()),
 43  
                                  200, false));
 44  0
                 logger.trace("Message detail: \n" + StringMessageUtils.headersToString(message));
 45  
             }
 46  0
             catch (Exception e)
 47  
             {
 48  
                 // ignore
 49  0
             }
 50  
         }
 51  
 
 52  0
         return event;
 53  
     }
 54  
 
 55  
     @Override
 56  
     public String toString()
 57  
     {
 58  0
         return ObjectUtils.toString(this);
 59  
     }
 60  
 }