1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
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 | |
|
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 | |
} |