You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@excalibur.apache.org by le...@apache.org on 2006/04/06 05:26:03 UTC
svn commit: r391887 - in /excalibur/trunk/containerkit: logger/project.xml
logger/src/java/org/apache/avalon/excalibur/logger/factory/SMTPTargetFactory.java
logkit/project.xml
logkit/src/java/org/apache/log/output/net/SMTPOutputLogTarget.java
Author: leif
Date: Wed Apr 5 20:26:01 2006
New Revision: 391887
URL: http://svn.apache.org/viewcvs?rev=391887&view=rev
Log:
Make it possible to debug the sending of SMTP messages.
Modified:
excalibur/trunk/containerkit/logger/project.xml
excalibur/trunk/containerkit/logger/src/java/org/apache/avalon/excalibur/logger/factory/SMTPTargetFactory.java
excalibur/trunk/containerkit/logkit/project.xml
excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/net/SMTPOutputLogTarget.java
Modified: excalibur/trunk/containerkit/logger/project.xml
URL: http://svn.apache.org/viewcvs/excalibur/trunk/containerkit/logger/project.xml?rev=391887&r1=391886&r2=391887&view=diff
==============================================================================
--- excalibur/trunk/containerkit/logger/project.xml (original)
+++ excalibur/trunk/containerkit/logger/project.xml Wed Apr 5 20:26:01 2006
@@ -17,6 +17,7 @@
-->
<project>
<extend>${basedir}/../project-common.xml</extend>
+ <currentVersion>2.2-dev</currentVersion>
<name>Excalibur Logger</name>
<id>excalibur-logger</id>
@@ -47,7 +48,7 @@
<dependency>
<groupId>avalon-logkit</groupId>
<artifactId>avalon-logkit</artifactId>
- <version>2.1</version>
+ <version>2.2-dev</version>
</dependency>
<dependency>
Modified: excalibur/trunk/containerkit/logger/src/java/org/apache/avalon/excalibur/logger/factory/SMTPTargetFactory.java
URL: http://svn.apache.org/viewcvs/excalibur/trunk/containerkit/logger/src/java/org/apache/avalon/excalibur/logger/factory/SMTPTargetFactory.java?rev=391887&r1=391886&r2=391887&view=diff
==============================================================================
--- excalibur/trunk/containerkit/logger/src/java/org/apache/avalon/excalibur/logger/factory/SMTPTargetFactory.java (original)
+++ excalibur/trunk/containerkit/logger/src/java/org/apache/avalon/excalibur/logger/factory/SMTPTargetFactory.java Wed Apr 5 20:26:01 2006
@@ -48,6 +48,7 @@
* <subject>subject line</subject>
* <maximum-size>number</maximum-size>
* <maximum-delay-time>seconds</maximum-delay-time>
+ * <debug>false</debug>
* </smtp>
* </pre>
*
@@ -98,7 +99,7 @@
{
try
{
- return new SMTPOutputLogTarget(
+ SMTPOutputLogTarget logTarget = new SMTPOutputLogTarget(
getSession( config ),
getToAddresses( config ),
getFromAddress( config ),
@@ -107,6 +108,16 @@
getMaxDelayTime( config ),
getFormatter( config )
);
+
+ // Only set the debug flag when true. The flag is global in javamail
+ // and this makes things work more cleanly with old logkit versions.
+ boolean debug = getDebug( config );
+ if ( debug )
+ {
+ logTarget.setDebug( debug );
+ }
+
+ return logTarget;
}
catch( final ContextException ce )
{
@@ -255,6 +266,19 @@
throws ConfigurationException, AddressException
{
return createAddress( config.getChild( "from" ).getValue() );
+ }
+
+ /**
+ * Helper method to obtain the debug glag to use from the given
+ * configuration object.
+ *
+ * @param config a <code>Configuration</code> instance
+ * @return subject line
+ */
+ private boolean getDebug( Configuration config )
+ throws ConfigurationException
+ {
+ return config.getChild( "debug" ).getValueAsBoolean();
}
/**
Modified: excalibur/trunk/containerkit/logkit/project.xml
URL: http://svn.apache.org/viewcvs/excalibur/trunk/containerkit/logkit/project.xml?rev=391887&r1=391886&r2=391887&view=diff
==============================================================================
--- excalibur/trunk/containerkit/logkit/project.xml (original)
+++ excalibur/trunk/containerkit/logkit/project.xml Wed Apr 5 20:26:01 2006
@@ -17,6 +17,7 @@
-->
<project>
<extend>${basedir}/../project-common.xml</extend>
+ <currentVersion>2.2-dev</currentVersion>
<name>Avalon Logkit</name>
<id>avalon-logkit</id>
Modified: excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/net/SMTPOutputLogTarget.java
URL: http://svn.apache.org/viewcvs/excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/net/SMTPOutputLogTarget.java?rev=391887&r1=391886&r2=391887&view=diff
==============================================================================
--- excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/net/SMTPOutputLogTarget.java (original)
+++ excalibur/trunk/containerkit/logkit/src/java/org/apache/log/output/net/SMTPOutputLogTarget.java Wed Apr 5 20:26:01 2006
@@ -72,6 +72,9 @@
/** Flag which will be set in the close method when it is time to shutdown. */
private boolean m_shutdown;
+
+ /** Flag which controls whether debug is enabled for each message. */
+ private boolean m_debug;
/** SMTPOutputLogTarget constructor.
*
@@ -225,6 +228,8 @@
{
try
{
+ m_session.setDebug( m_debug ); // This is global, so always set it.
+
m_message = new MimeMessage( m_session );
m_message.setFrom( m_fromAddress );
m_message.setRecipients( Message.RecipientType.TO, m_toAddresses );
@@ -310,11 +315,11 @@
/**
* Method to enable/disable debugging on the mail session.
*
- * @param flag true to enable debugging, false to disable it
+ * @param debug true to enable debugging, false to disable it
*/
- public void setDebug( boolean flag )
+ public void setDebug( boolean debug )
{
- m_session.setDebug( flag );
+ m_debug = debug;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
For additional commands, e-mail: scm-help@excalibur.apache.org