camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r655021 - in /activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail: MailConfiguration.java MailConsumer.java MailMessage.java MailUtils.java
Date Sat, 10 May 2008 08:07:56 GMT
Author: davsclaus
Date: Sat May 10 01:07:56 2008
New Revision: 655021

URL: http://svn.apache.org/viewvc?rev=655021&view=rev
Log:
CAMEL-335
- Improved details of logging

Modified:
    activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
    activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
    activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
    activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailUtils.java

Modified: activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java?rev=655021&r1=655020&r2=655021&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
(original)
+++ activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
Sat May 10 01:07:56 2008
@@ -153,7 +153,7 @@
     }
 
     public String getMailStoreLogInformation() {
-        return "MailStore [" + protocol + "//" + host + ":" + port + "] folder=[" + folderName
+ "]";
+        return protocol + "//" + host + ":" + port + (isSecureProtocol() ? " (SSL enabled)"
: "") + ", folder=" + folderName;
     }
 
     // Properties

Modified: activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java?rev=655021&r1=655020&r2=655021&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
(original)
+++ activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
Sat May 10 01:07:56 2008
@@ -77,8 +77,7 @@
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Polling mailfolder " + folder.getFullName() + " at host "
-                + endpoint.getConfiguration().getHost() + ":" + endpoint.getConfiguration().getPort());
+            LOG.debug("Polling mailfolder: " + endpoint.getConfiguration().getMailStoreLogInformation());
         }
 
         if (endpoint.getConfiguration().getFetchSize() == 0) {
@@ -122,7 +121,7 @@
         if (store == null || !store.isConnected()) {
             store = sender.getSession().getStore(config.getProtocol());
             if (LOG.isDebugEnabled()) {
-                LOG.debug("Connecting to MailStore at host " + config.getHost() + " on port
" + config.getPort());
+                LOG.debug("Connecting to MailStore " + endpoint.getConfiguration().getMailStoreLogInformation());
             }
             store.connect(config.getHost(), config.getPort(), config.getUsername(), config.getPassword());
         }

Modified: activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java?rev=655021&r1=655020&r2=655021&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
(original)
+++ activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
Sat May 10 01:07:56 2008
@@ -49,7 +49,7 @@
     @Override
     public String toString() {
         if (mailMessage != null) {
-            return "MailMessage: " + mailMessage;
+            return "MailMessage: " + MailUtils.dumpMessage(mailMessage);
         } else {
             return "MailMessage: " + getBody();
         }

Modified: activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailUtils.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailUtils.java?rev=655021&r1=655020&r2=655021&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailUtils.java
(original)
+++ activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailUtils.java
Sat May 10 01:07:56 2008
@@ -90,44 +90,49 @@
      *
      * @param message the Mail message
      * @return a log string with important fields dumped
-     * @throws MessagingException can be thrown by the Mail API
      */
-    public static String dumpMessage(Message message) throws MessagingException {
-        StringBuilder sb = new StringBuilder();
-
-        int number = message.getMessageNumber();
-        sb.append("messageNumber=[").append(number).append("]");
+    public static String dumpMessage(Message message) {
+        try {
+            StringBuilder sb = new StringBuilder();
+
+            int number = message.getMessageNumber();
+            sb.append("messageNumber=[").append(number).append("]");
+
+            Address[] from = message.getFrom();
+            if (from != null) {
+                for (Address adr : from) {
+                    sb.append(", from=[").append(adr).append("]");
+                }
+            }
 
-        Address[] from = message.getFrom();
-        if (from != null) {
-            for (Address adr : from) {
-                sb.append(", from=[").append(adr).append("]");
+            Address[] to = message.getRecipients(Message.RecipientType.TO);
+            if (to != null) {
+                for (Address adr : to) {
+                    sb.append(", to=[").append(adr).append("]");
+                }
             }
-        }
 
-        Address[] to = message.getRecipients(Message.RecipientType.TO);
-        if (to != null) {
-            for (Address adr : to) {
-                sb.append(", to=[").append(adr).append("]");
+            String subject = message.getSubject();
+            if (subject != null) {
+                sb.append(", subject=[").append(subject).append("]");
             }
-        }
 
-        String subject = message.getSubject();
-        if (subject != null) {
-            sb.append(", subject=[").append(subject).append("]");
-        }
+            Date sentDate = message.getSentDate();
+            if (sentDate != null) {
+                sb.append(", sentDate=[").append(DateFormat.getDateTimeInstance().format(sentDate)).append("]");
+            }
 
-        Date sentDate = message.getSentDate();
-        if (sentDate != null) {
-            sb.append(", sentDate=[").append(DateFormat.getDateTimeInstance().format(sentDate)).append("]");
-        }
+            Date receivedDate = message.getReceivedDate();
+            if (receivedDate != null) {
+                sb.append(", receivedDate=[").append(DateFormat.getDateTimeInstance().format(receivedDate)).append("]");
+            }
 
-        Date receivedDate = message.getReceivedDate();
-        if (receivedDate != null) {
-            sb.append(", receivedDate=[").append(DateFormat.getDateTimeInstance().format(receivedDate)).append("]");
+            return sb.toString();
+        } catch (MessagingException e) {
+            // ignore the error and just return tostring 
+            return message.toString();
         }
 
-        return sb.toString();
     }
 
 }



Mime
View raw message