You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/03/27 23:07:59 UTC
cvs commit: jakarta-avalon-logkit/src/test/org/apache/log/util/test UtilTestCase.java
donaldp 02/03/27 14:07:58
Modified: src/compat/org/apache/log ContextStack.java
FilterTarget.java Formatter.java
src/compat/org/apache/log/format AvalonFormatter.java
src/compat/org/apache/log/output DatagramOutputTarget.java
DefaultOutputLogTarget.java
FileOutputLogTarget.java
src/java/org/apache/log ContextMap.java ErrorAware.java
Hierarchy.java LogEvent.java LogTarget.java
Logger.java Priority.java
src/java/org/apache/log/filter AbstractFilterTarget.java
PriorityFilter.java
src/java/org/apache/log/format ExtendedPatternFormatter.java
PatternFormatter.java RawFormatter.java
SyslogFormatter.java XMLFormatter.java
src/java/org/apache/log/output AbstractOutputTarget.java
AbstractTarget.java AsyncLogTarget.java
MemoryTarget.java NullOutputLogTarget.java
ServletOutputLogTarget.java
src/java/org/apache/log/output/db AbstractJDBCTarget.java
ColumnInfo.java ColumnType.java
DefaultDataSource.java DefaultJDBCTarget.java
NormalizedJDBCTarget.java
src/java/org/apache/log/output/io FileTarget.java
SafeFileTarget.java StreamTarget.java
WriterTarget.java
src/java/org/apache/log/output/io/rotate FileStrategy.java
OrRotateStrategy.java RevolvingFileStrategy.java
RotateStrategyByDate.java RotateStrategyByTime.java
RotatingFileTarget.java UniqueFileStrategy.java
src/java/org/apache/log/output/jms AbstractJMSTarget.java
JMSQueueTarget.java JMSTopicTarget.java
MessageBuilder.java PropertyInfo.java
PropertyType.java TextMessageBuilder.java
src/java/org/apache/log/output/net SocketOutputTarget.java
src/java/org/apache/log/util DefaultErrorHandler.java
LoggerOutputStream.java OutputStreamLogger.java
StackIntrospector.java
src/test/org/apache/log/format/test FormatterTestCase.java
src/test/org/apache/log/output/test DBTargetTestCase.java
DatagramTest.java OutputTargetTestCase.java
TestRotatingFileOutputLogTarget.java
src/test/org/apache/log/test InheritanceTestCase.java
src/test/org/apache/log/util/test UtilTestCase.java
Log:
Ran IDEA restyle over codebase
Revision Changes Path
1.3 +5 -5 jakarta-avalon-logkit/src/compat/org/apache/log/ContextStack.java
Index: ContextStack.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/compat/org/apache/log/ContextStack.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContextStack.java 12 Aug 2001 12:25:16 -0000 1.2
+++ ContextStack.java 27 Mar 2002 22:07:56 -0000 1.3
@@ -13,21 +13,21 @@
* The ContextStack records the nested context of an application.
* The context is an application defined characteristeric. For instance
* a webserver context may be defined as the session that is currently
- * used to connect to server. A application may have context
- * defined by current thread. A applet may have it's context defined
+ * used to connect to server. A application may have context
+ * defined by current thread. A applet may have it's context defined
* by the name of the applet etc.
*
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
* @deprecated This class has been deprecated as it encouraged use of bad
* design practices. Use org.apache.log.ContextMap instead.
*/
-public class ContextStack
+public class ContextStack
{
///Thread local for holding instance of stack associated with current thread
- private static final ThreadLocal c_context = new ThreadLocal();
+ private static final ThreadLocal c_context = new ThreadLocal();
///Container to hold stack of elements
- private Stack m_stack = new Stack();
+ private Stack m_stack = new Stack();
/**
* Get the Current ContextStack.
1.2 +4 -4 jakarta-avalon-logkit/src/compat/org/apache/log/FilterTarget.java
Index: FilterTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/compat/org/apache/log/FilterTarget.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FilterTarget.java 31 Jul 2001 02:40:32 -0000 1.1
+++ FilterTarget.java 27 Mar 2002 22:07:56 -0000 1.2
@@ -8,10 +8,10 @@
package org.apache.log;
/**
- * A Log target which will do filtering and then pass it
+ * A Log target which will do filtering and then pass it
* onto targets further along in chain.
- *
- * <p>Filtering can mena that not all LogEvents get passed
+ *
+ * <p>Filtering can mena that not all LogEvents get passed
* along chain or that the LogEvents passed alongare modified
* in some manner.</p>
*
@@ -19,7 +19,7 @@
* @deprecated Interface offered no significant advantage and thus will no
* longer be used by new interfaces
*/
-public interface FilterTarget
+public interface FilterTarget
extends LogTarget
{
/**
1.2 +1 -1 jakarta-avalon-logkit/src/compat/org/apache/log/Formatter.java
Index: Formatter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/compat/org/apache/log/Formatter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Formatter.java 31 Jul 2001 02:40:32 -0000 1.1
+++ Formatter.java 27 Mar 2002 22:07:56 -0000 1.2
@@ -8,7 +8,7 @@
package org.apache.log;
/**
- * This defines the interface for components that wish to serialize
+ * This defines the interface for components that wish to serialize
* LogEvents into Strings.
*
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
1.4 +2 -5 jakarta-avalon-logkit/src/compat/org/apache/log/format/AvalonFormatter.java
Index: AvalonFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/compat/org/apache/log/format/AvalonFormatter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AvalonFormatter.java 5 Nov 2001 12:37:16 -0000 1.3
+++ AvalonFormatter.java 27 Mar 2002 22:07:56 -0000 1.4
@@ -7,11 +7,8 @@
*/
package org.apache.log.format;
-import java.util.Date;
-import org.apache.avalon.framework.ExceptionUtil;
-
/**
- * This formatter extends PatternFormatter so that
+ * This formatter extends PatternFormatter so that
* CascadingExceptions are formatted with all nested exceptions.
*
* @deprecated Use <code>org.apache.avalon.framework.logger.AvalonFormatter</code>
@@ -19,7 +16,7 @@
*
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
*/
-public class AvalonFormatter
+public class AvalonFormatter
extends org.apache.avalon.framework.logger.AvalonFormatter
{
public AvalonFormatter()
1.2 +1 -1 jakarta-avalon-logkit/src/compat/org/apache/log/output/DatagramOutputTarget.java
Index: DatagramOutputTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/compat/org/apache/log/output/DatagramOutputTarget.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DatagramOutputTarget.java 31 Jul 2001 02:40:32 -0000 1.1
+++ DatagramOutputTarget.java 27 Mar 2002 22:07:56 -0000 1.2
@@ -28,7 +28,7 @@
* @param port the address port
* @exception IOException if an error occurs
*/
- public DatagramOutputTarget( final InetAddress address,
+ public DatagramOutputTarget( final InetAddress address,
final int port,
final Formatter formatter )
throws IOException
1.2 +7 -9 jakarta-avalon-logkit/src/compat/org/apache/log/output/DefaultOutputLogTarget.java
Index: DefaultOutputLogTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/compat/org/apache/log/output/DefaultOutputLogTarget.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultOutputLogTarget.java 31 Jul 2001 02:40:32 -0000 1.1
+++ DefaultOutputLogTarget.java 27 Mar 2002 22:07:56 -0000 1.2
@@ -7,13 +7,11 @@
*/
package org.apache.log.output;
-import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
-import org.apache.log.format.PatternFormatter;
-import org.apache.log.Hierarchy;
import org.apache.log.format.Formatter;
+import org.apache.log.format.PatternFormatter;
import org.apache.log.output.io.WriterTarget;
/**
@@ -21,14 +19,14 @@
* The format is specified via a string.
*
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
- * @deprecated Use org.apache.log.output.io.WriterTarget or
- * org.apache.log.output.io.StreamTarget as appropriate
+ * @deprecated Use org.apache.log.output.io.WriterTarget or
+ * org.apache.log.output.io.StreamTarget as appropriate
* as this class encourages unsafe behaviour
*/
public class DefaultOutputLogTarget
extends WriterTarget
{
- private static final String FORMAT =
+ private static final String FORMAT =
"%7.7{priority} %5.5{time} [%8.8{category}] (%{context}): %{message}\\n%{throwable}";
/**
@@ -85,13 +83,13 @@
* Set the format string for this target.
*
* @param format the format string
- * @deprecated This method is unsafe as it assumes formatter is PatternFormatter
+ * @deprecated This method is unsafe as it assumes formatter is PatternFormatter
* and accesses a protected attribute. Instead of calling this method
- * It is recomended that a fully configured formatter is passed into
+ * It is recomended that a fully configured formatter is passed into
* constructor.
*/
public void setFormat( final String format )
{
- ((PatternFormatter)m_formatter).setFormat( format );
+ ( (PatternFormatter)m_formatter ).setFormat( format );
}
}
1.2 +9 -9 jakarta-avalon-logkit/src/compat/org/apache/log/output/FileOutputLogTarget.java
Index: FileOutputLogTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/compat/org/apache/log/output/FileOutputLogTarget.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FileOutputLogTarget.java 31 Jul 2001 02:40:32 -0000 1.1
+++ FileOutputLogTarget.java 27 Mar 2002 22:07:56 -0000 1.2
@@ -21,7 +21,7 @@
public class FileOutputLogTarget
extends DefaultOutputLogTarget
{
- private boolean m_append = false;
+ private boolean m_append = false;
public FileOutputLogTarget()
{
@@ -45,14 +45,14 @@
m_append = append;
}
- /**
- * Overwrites the m_output value in the super class through
- * assignment of an OutputStreamWriter based on a supplied
- * file path. Side-effects include the creation of a
- * directory path based relative to the supplied filename.
- *
- * @param filename path and filename for log destination
- */
+ /**
+ * Overwrites the m_output value in the super class through
+ * assignment of an OutputStreamWriter based on a supplied
+ * file path. Side-effects include the creation of a
+ * directory path based relative to the supplied filename.
+ *
+ * @param filename path and filename for log destination
+ */
public void setFilename( final String filename )
throws IOException
{
1.7 +8 -6 jakarta-avalon-logkit/src/java/org/apache/log/ContextMap.java
Index: ContextMap.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/ContextMap.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ContextMap.java 13 Dec 2001 10:09:03 -0000 1.6
+++ ContextMap.java 27 Mar 2002 22:07:56 -0000 1.7
@@ -12,7 +12,7 @@
import java.util.Hashtable;
/**
- * The ContextMap contains non-hierarchical context information
+ * The ContextMap contains non-hierarchical context information
* relevent to a particular LogEvent. It may include information
* such as;
*
@@ -33,15 +33,15 @@
implements Serializable
{
///Thread local for holding instance of map associated with current thread
- private static final ThreadLocal c_context = new InheritableThreadLocal();
+ private static final ThreadLocal c_context = new InheritableThreadLocal();
private final ContextMap m_parent;
///Container to hold map of elements
- private Hashtable m_map = new Hashtable();
+ private Hashtable m_map = new Hashtable();
///Flag indicating whether this map should be readonly
- private transient boolean m_readOnly;
+ private transient boolean m_readOnly;
/**
* Get the Current ContextMap.
@@ -150,8 +150,10 @@
{
final Object object = get( key );
- if( null != object ) return object;
- else return defaultObject;
+ if( null != object )
+ return object;
+ else
+ return defaultObject;
}
/**
1.3 +1 -1 jakarta-avalon-logkit/src/java/org/apache/log/ErrorAware.java
Index: ErrorAware.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/ErrorAware.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ErrorAware.java 19 Nov 2001 12:18:33 -0000 1.2
+++ ErrorAware.java 27 Mar 2002 22:07:56 -0000 1.3
@@ -8,7 +8,7 @@
package org.apache.log;
/**
- * Interface implemented by components that wish to
+ * Interface implemented by components that wish to
* delegate ErrorHandling to an ErrorHandler.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
1.15 +9 -10 jakarta-avalon-logkit/src/java/org/apache/log/Hierarchy.java
Index: Hierarchy.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/Hierarchy.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Hierarchy.java 26 Feb 2002 09:50:55 -0000 1.14
+++ Hierarchy.java 27 Mar 2002 22:07:56 -0000 1.15
@@ -7,7 +7,6 @@
*/
package org.apache.log;
-import java.util.Hashtable;
import org.apache.log.format.PatternFormatter;
import org.apache.log.output.io.StreamTarget;
import org.apache.log.util.DefaultErrorHandler;
@@ -21,18 +20,18 @@
public class Hierarchy
{
///Format of default formatter
- private static final String FORMAT =
+ private static final String FORMAT =
"%7.7{priority} %23.23{time:yyyy-MM-dd' 'HH:mm:ss.SSS} [%8.8{category}] (%{context}): " +
"%{message}\n%{throwable}";
///The instance of default hierarchy
- private static final Hierarchy c_hierarchy = new Hierarchy();
+ private static final Hierarchy c_hierarchy = new Hierarchy();
///Error Handler associated with hierarchy
- private ErrorHandler m_errorHandler;
+ private ErrorHandler m_errorHandler;
///The root logger which contains all Loggers in this hierarchy
- private Logger m_rootLogger;
+ private Logger m_rootLogger;
/**
* Retrieve the default hierarchy.
@@ -79,7 +78,7 @@
throw new IllegalArgumentException( "Can not set DefaultLogTarget to null" );
}
- final LogTarget[] targets = new LogTarget[] { target };
+ final LogTarget[] targets = new LogTarget[]{target};
getRootLogger().setLogTargets( targets );
}
@@ -91,11 +90,11 @@
*/
public void setDefaultLogTargets( final LogTarget[] targets )
{
- if ( null == targets || 0 == targets.length )
+ if( null == targets || 0 == targets.length )
{
throw new IllegalArgumentException( "Can not set DefaultLogTargets to null" );
}
-
+
for( int i = 0; i < targets.length; i++ )
{
if( null == targets[ i ] )
@@ -184,8 +183,8 @@
* @param throwable the exception associated with error (may be null)
* @param event the LogEvent that caused error, if any (may be null)
*/
- public void error( final String message,
- final Throwable throwable,
+ public void error( final String message,
+ final Throwable throwable,
final LogEvent event )
{
m_errorHandler.error( message, throwable, event );
1.10 +8 -9 jakarta-avalon-logkit/src/java/org/apache/log/LogEvent.java
Index: LogEvent.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/LogEvent.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- LogEvent.java 13 Dec 2001 10:09:03 -0000 1.9
+++ LogEvent.java 27 Mar 2002 22:07:56 -0000 1.10
@@ -21,31 +21,31 @@
implements Serializable
{
//A Constant used when retrieving time relative to start of applicaiton start
- private final static long START_TIME = System.currentTimeMillis();
+ private final static long START_TIME = System.currentTimeMillis();
///The category that this LogEvent concerns. (Must not be null)
- private String m_category;
+ private String m_category;
///The message to be logged. (Must not be null)
- private String m_message;
+ private String m_message;
///The exception that caused LogEvent if any. (May be null)
- private Throwable m_throwable;
+ private Throwable m_throwable;
///The time in millis that LogEvent occurred
- private long m_time;
+ private long m_time;
///The priority of LogEvent. (Must not be null)
- private Priority m_priority;
+ private Priority m_priority;
///The context map associated with LogEvent. (May be null).
- private ContextMap m_contextMap;
+ private ContextMap m_contextMap;
/**
* The context stack associated with LogEvent. (May be null)
* @deprecated ContextStack has been deprecated and thus so has this field.
*/
- private transient ContextStack m_contextStack;
+ private transient ContextStack m_contextStack;
/**
* Get Priority for LogEvent.
@@ -200,7 +200,6 @@
{
m_time = time;
}
-
/**
* Helper method that replaces deserialized priority with correct singleton.
1.4 +3 -3 jakarta-avalon-logkit/src/java/org/apache/log/LogTarget.java
Index: LogTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/LogTarget.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LogTarget.java 19 Nov 2001 12:18:33 -0000 1.3
+++ LogTarget.java 27 Mar 2002 22:07:56 -0000 1.4
@@ -11,7 +11,7 @@
* LogTarget is a class to encapsulate outputting LogEvent's.
* This provides the base for all output and filter targets.
*
- * Warning: If performance becomes a problem then this
+ * Warning: If performance becomes a problem then this
* interface will be rewritten as a abstract class.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
@@ -20,9 +20,9 @@
{
/**
* Process a log event.
- * In NO case should this method ever throw an exception/error.
+ * In NO case should this method ever throw an exception/error.
* The reason is that logging is usually added for debugging/auditing
- * purposes and it would be unnaceptable to have your debugging
+ * purposes and it would be unnaceptable to have your debugging
* code cause more errors.
*
* @param event the event
1.22 +58 -46 jakarta-avalon-logkit/src/java/org/apache/log/Logger.java
Index: Logger.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/Logger.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Logger.java 22 Dec 2001 02:54:07 -0000 1.21
+++ Logger.java 27 Mar 2002 22:07:56 -0000 1.22
@@ -15,37 +15,37 @@
public class Logger
{
///Separator character use to separate different categories
- public final static char CATEGORY_SEPARATOR = '.';
+ public final static char CATEGORY_SEPARATOR = '.';
///The ErrorHandler associated with Logger
- private final ErrorHandler m_errorHandler;
+ private final ErrorHandler m_errorHandler;
///Logger to inherit logtargets and priorities from
- private final Logger m_parent;
+ private final Logger m_parent;
///the fully qualified name of category
- private final String m_category;
+ private final String m_category;
///The list of child loggers associated with this logger
- private Logger[] m_children;
+ private Logger[] m_children;
///The log-targets this logger writes to
- private LogTarget[] m_logTargets;
+ private LogTarget[] m_logTargets;
///Indicate that logTargets were set with setLogTargets() rather than inherited
- private boolean m_logTargetsForceSet;
+ private boolean m_logTargetsForceSet;
///The priority threshold associated with logger
- private Priority m_priority;
+ private Priority m_priority;
///Indicate that priority was set with setPriority() rather than inherited
- private boolean m_priorityForceSet;
+ private boolean m_priorityForceSet;
/**
* True means LogEvents will be sent to parents LogTargets
* aswell as the ones set for this Logger.
*/
- private boolean m_additivity;
+ private boolean m_additivity;
/**
* Protected constructor for use inside the logging toolkit.
@@ -56,9 +56,9 @@
* @param logTargets the LogTargets associated with logger
* @param parent the parent logger (used for inheriting from)
*/
- Logger( final ErrorHandler errorHandler,
- final String category,
- final LogTarget[] logTargets,
+ Logger( final ErrorHandler errorHandler,
+ final String category,
+ final LogTarget[] logTargets,
final Logger parent )
{
m_errorHandler = errorHandler;
@@ -281,7 +281,7 @@
{
return getPriority().isLowerOrEqual( priority );
}
-
+
/**
* Log a event at specific priority with a certain message and throwable.
*
@@ -340,8 +340,10 @@
*/
public synchronized void unsetPriority( final boolean recursive )
{
- if( null != m_parent ) m_priority = m_parent.getPriority();
- else m_priority = Priority.DEBUG;
+ if( null != m_parent )
+ m_priority = m_parent.getPriority();
+ else
+ m_priority = Priority.DEBUG;
m_priorityForceSet = false;
resetChildPriorities( recursive );
@@ -362,7 +364,7 @@
/**
* Unset the logtargets for this logger.
- * This logger (and thus all child loggers who don't specify logtargets) will
+ * This logger (and thus all child loggers who don't specify logtargets) will
* inherit from the parents LogTargets.
*/
public synchronized void unsetLogTargets()
@@ -372,13 +374,15 @@
/**
* Unset the logtargets for this logger and all child loggers if recursive is set.
- * The loggers unset (and all child loggers who don't specify logtargets) will
+ * The loggers unset (and all child loggers who don't specify logtargets) will
* inherit from the parents LogTargets.
*/
public synchronized void unsetLogTargets( final boolean recursive )
{
- if( null != m_parent ) m_logTargets = m_parent.safeGetLogTargets();
- else m_logTargets = null;
+ if( null != m_parent )
+ m_logTargets = m_parent.safeGetLogTargets();
+ else
+ m_logTargets = null;
m_logTargetsForceSet = false;
resetChildLogTargets( recursive );
@@ -393,7 +397,7 @@
{
if( null == m_children ) return new Logger[ 0 ];
- final Logger[] children = new Logger[ m_children.length ];
+ final Logger[] children = new Logger[ m_children.length ];
for( int i = 0; i < children.length; i++ )
{
@@ -418,37 +422,41 @@
String nextCategory = null;
String remainder = null;
-
- if( -1 == end ) nextCategory = subCategory;
+
+ if( -1 == end )
+ nextCategory = subCategory;
else
{
if( end == 0 )
{
throw new IllegalArgumentException( "Logger categories MUST not have empty elements" );
}
-
+
nextCategory = subCategory.substring( 0, end );
remainder = subCategory.substring( end + 1 );
}
- //Get FQN for category
+ //Get FQN for category
String category = null;
- if( m_category.equals( "" ) ) category = nextCategory;
+ if( m_category.equals( "" ) )
+ category = nextCategory;
else
{
category = m_category + CATEGORY_SEPARATOR + nextCategory;
}
//Check existing children to see if they
- //contain next Logger for step in category
+ //contain next Logger for step in category
if( null != m_children )
{
for( int i = 0; i < m_children.length; i++ )
{
if( m_children[ i ].getCategory().equals( category ) )
{
- if( null == remainder ) return m_children[ i ];
- else return m_children[ i ].getChildLogger( remainder );
+ if( null == remainder )
+ return m_children[ i ];
+ else
+ return m_children[ i ].getChildLogger( remainder );
}
}
}
@@ -457,9 +465,9 @@
final Logger child = new Logger( m_errorHandler, category, null, this );
//Add new logger to child list
- if( null == m_children )
+ if( null == m_children )
{
- m_children = new Logger[] { child };
+ m_children = new Logger[]{child};
}
else
{
@@ -469,16 +477,18 @@
m_children = children;
}
- if( null == remainder ) return child;
- else return child.getChildLogger( remainder );
+ if( null == remainder )
+ return child;
+ else
+ return child.getChildLogger( remainder );
}
/**
* Retrieve priority associated with Logger.
*
* @return the loggers priority
- * @deprecated This method violates Inversion of Control principle.
- * It will downgraded to protected access in a future
+ * @deprecated This method violates Inversion of Control principle.
+ * It will downgraded to protected access in a future
* release. When user needs to check priority it is advised
* that they use the is[Priority]Enabled() functions.
*/
@@ -491,8 +501,8 @@
* Retrieve category associated with logger.
*
* @return the Category
- * @deprecated This method violates Inversion of Control principle.
- * If you are relying on its presence then there may be
+ * @deprecated This method violates Inversion of Control principle.
+ * If you are relying on its presence then there may be
* something wrong with the design of your system
*/
public final String getCategory()
@@ -504,8 +514,8 @@
* Get a copy of log targets for this logger.
*
* @return the child loggers
- * @deprecated This method is deprecated and will be removed in Future version.
- * Previously it allowed unsafe access to logtargets which permitted
+ * @deprecated This method is deprecated and will be removed in Future version.
+ * Previously it allowed unsafe access to logtargets which permitted
* masqurade attacks. It currently returns a zero sized array.
*/
public LogTarget[] getLogTargets()
@@ -529,7 +539,7 @@
event.setContextStack( ContextStack.getCurrentContext( false ) );
event.setContextMap( ContextMap.getCurrentContext( false ) );
- if( null != message )
+ if( null != message )
{
event.setMessage( message );
}
@@ -567,7 +577,7 @@
else
{
//If log targets were not inherited, additivity is true
- //then fire an event to local targets
+ //then fire an event to local targets
if( m_logTargetsForceSet )
{
fireEvent( event, targets );
@@ -585,8 +595,8 @@
{
for( int i = 0; i < targets.length; i++ )
{
- //No need to clone array as addition of a log-target
- //will result in changin whole array
+ //No need to clone array as addition of a log-target
+ //will result in changin whole array
targets[ i ].processEvent( event );
}
}
@@ -638,8 +648,10 @@
{
if( null == m_logTargets )
{
- if( null == m_parent ) return new LogTarget[ 0 ];
- else return m_parent.safeGetLogTargets();
+ if( null == m_parent )
+ return new LogTarget[ 0 ];
+ else
+ return m_parent.safeGetLogTargets();
}
else
{
@@ -679,7 +691,7 @@
final LogTarget target = m_logTargets[ i ];
if( target instanceof ErrorAware )
{
- ((ErrorAware)target).setErrorHandler( m_errorHandler );
+ ( (ErrorAware)target ).setErrorHandler( m_errorHandler );
}
}
}
1.11 +32 -26 jakarta-avalon-logkit/src/java/org/apache/log/Priority.java
Index: Priority.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/Priority.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Priority.java 13 Dec 2001 10:09:03 -0000 1.10
+++ Priority.java 27 Mar 2002 22:07:56 -0000 1.11
@@ -7,12 +7,12 @@
*/
package org.apache.log;
-import java.io.Serializable;
import java.io.ObjectStreamException;
+import java.io.Serializable;
/**
* Class representing and holding constants for priority.
- *
+ *
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
*/
public final class Priority
@@ -38,15 +38,15 @@
* A problem has occurred but it is not fatal. The system will still function.
*/
public final static Priority ERROR = new Priority( "ERROR", 20 );
-
+
/**
* Something caused whole system to fail. This indicates that an administrator
* should restart the system and try to fix the problem that caused the failure.
- */
+ */
public final static Priority FATAL_ERROR = new Priority( "FATAL_ERROR", 25 );
-
- private final String m_name;
- private final int m_priority;
+
+ private final String m_name;
+ private final int m_priority;
/**
* Retrieve a Priority object for the name parameter.
@@ -56,26 +56,32 @@
*/
public static Priority getPriorityForName( final String priority )
{
- if( Priority.DEBUG.getName().equals( priority ) ) return Priority.DEBUG;
- else if( Priority.INFO.getName().equals( priority ) ) return Priority.INFO;
- else if( Priority.WARN.getName().equals( priority ) ) return Priority.WARN;
- else if( Priority.ERROR.getName().equals( priority ) ) return Priority.ERROR;
- else if( Priority.FATAL_ERROR.getName().equals( priority ) ) return Priority.FATAL_ERROR;
- else return Priority.DEBUG;
- }
-
+ if( Priority.DEBUG.getName().equals( priority ) )
+ return Priority.DEBUG;
+ else if( Priority.INFO.getName().equals( priority ) )
+ return Priority.INFO;
+ else if( Priority.WARN.getName().equals( priority ) )
+ return Priority.WARN;
+ else if( Priority.ERROR.getName().equals( priority ) )
+ return Priority.ERROR;
+ else if( Priority.FATAL_ERROR.getName().equals( priority ) )
+ return Priority.FATAL_ERROR;
+ else
+ return Priority.DEBUG;
+ }
+
/**
* Private Constructor to block instantiation outside class.
*
* @param name the string name of priority
* @param priority the numerical code of priority
*/
- private Priority( final String name, final int priority )
+ private Priority( final String name, final int priority )
{
m_name = name;
m_priority = priority;
}
-
+
/**
* Overidden string to display Priority in human readable form.
*
@@ -85,47 +91,47 @@
{
return "Priority[" + getName() + "/" + getValue() + "]";
}
-
+
/**
* Get numerical value associated with priority.
*
* @return the numerical value
*/
- public int getValue()
+ public int getValue()
{
return m_priority;
}
-
+
/**
* Get name of priority.
*
* @return the priorities name
*/
- public String getName()
+ public String getName()
{
return m_name;
}
-
+
/**
* Test whether this priority is greater than other priority.
*
* @param other the other Priority
*/
- public boolean isGreater( final Priority other )
+ public boolean isGreater( final Priority other )
{
return m_priority > other.getValue();
}
-
+
/**
* Test whether this priority is lower than other priority.
*
* @param other the other Priority
*/
- public boolean isLower( final Priority other )
+ public boolean isLower( final Priority other )
{
return m_priority < other.getValue();
}
-
+
/**
* Test whether this priority is lower or equal to other priority.
*
1.6 +6 -5 jakarta-avalon-logkit/src/java/org/apache/log/filter/AbstractFilterTarget.java
Index: AbstractFilterTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/filter/AbstractFilterTarget.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractFilterTarget.java 19 Nov 2001 12:18:33 -0000 1.5
+++ AbstractFilterTarget.java 27 Mar 2002 22:07:56 -0000 1.6
@@ -17,11 +17,11 @@
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
*/
-public abstract class AbstractFilterTarget
+public abstract class AbstractFilterTarget
implements FilterTarget, LogTarget
{
//Log targets in filter chain
- private LogTarget m_targets[];
+ private LogTarget m_targets[];
/**
* Add a new target to output chain.
@@ -32,7 +32,7 @@
{
if( null == m_targets )
{
- m_targets = new LogTarget[] { target };
+ m_targets = new LogTarget[]{target};
}
else
{
@@ -56,9 +56,10 @@
*
* @param event the log event
*/
- public void processEvent( final LogEvent event )
+ public void processEvent( final LogEvent event )
{
- if( null == m_targets || filter( event ) ) return;
+ if( null == m_targets || filter( event ) )
+ return;
else
{
for( int i = 0; i < m_targets.length; i++ )
1.8 +1 -1 jakarta-avalon-logkit/src/java/org/apache/log/filter/PriorityFilter.java
Index: PriorityFilter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/filter/PriorityFilter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PriorityFilter.java 19 Nov 2001 12:18:33 -0000 1.7
+++ PriorityFilter.java 27 Mar 2002 22:07:56 -0000 1.8
@@ -19,7 +19,7 @@
extends AbstractFilterTarget
{
///Priority to filter against
- private Priority m_priority;
+ private Priority m_priority;
/**
* Constructor that sets the priority that is filtered against.
1.4 +17 -14 jakarta-avalon-logkit/src/java/org/apache/log/format/ExtendedPatternFormatter.java
Index: ExtendedPatternFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/format/ExtendedPatternFormatter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExtendedPatternFormatter.java 19 Nov 2001 12:18:33 -0000 1.3
+++ ExtendedPatternFormatter.java 27 Mar 2002 22:07:56 -0000 1.4
@@ -7,8 +7,6 @@
*/
package org.apache.log.format;
-import java.io.StringWriter;
-import java.util.Stack;
import org.apache.log.ContextMap;
import org.apache.log.LogEvent;
import org.apache.log.Logger;
@@ -26,16 +24,16 @@
* information dynamically.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version CVS $Revision: 1.3 $ $Date: 2001/11/19 12:18:33 $
+ * @version CVS $Revision: 1.4 $ $Date: 2002/03/27 22:07:56 $
*/
public class ExtendedPatternFormatter
extends PatternFormatter
{
- private final static int TYPE_METHOD = MAX_TYPE + 1;
- private final static int TYPE_THREAD = MAX_TYPE + 2;
+ private final static int TYPE_METHOD = MAX_TYPE + 1;
+ private final static int TYPE_THREAD = MAX_TYPE + 2;
- private final static String TYPE_METHOD_STR = "method";
- private final static String TYPE_THREAD_STR = "thread";
+ private final static String TYPE_METHOD_STR = "method";
+ private final static String TYPE_THREAD_STR = "thread";
public ExtendedPatternFormatter( final String format )
{
@@ -50,8 +48,10 @@
*/
protected int getTypeIdFor( final String type )
{
- if( type.equalsIgnoreCase( TYPE_METHOD_STR ) ) return TYPE_METHOD;
- else if( type.equalsIgnoreCase( TYPE_THREAD_STR ) ) return TYPE_THREAD;
+ if( type.equalsIgnoreCase( TYPE_METHOD_STR ) )
+ return TYPE_METHOD;
+ else if( type.equalsIgnoreCase( TYPE_THREAD_STR ) )
+ return TYPE_THREAD;
else
{
return super.getTypeIdFor( type );
@@ -68,16 +68,19 @@
{
switch( run.m_type )
{
- case TYPE_METHOD: return getMethod( event, run.m_format );
- case TYPE_THREAD: return getThread( event, run.m_format );
- default: return super.formatPatternRun( event, run );
+ case TYPE_METHOD:
+ return getMethod( event, run.m_format );
+ case TYPE_THREAD:
+ return getThread( event, run.m_format );
+ default:
+ return super.formatPatternRun( event, run );
}
}
/**
* Utility method to format category.
*
- * @param category the category string
+ * @param event the event
* @param format ancilliary format parameter - allowed to be null
* @return the formatted string
*/
@@ -104,7 +107,7 @@
/**
* Utility thread to format category.
*
- * @param category the category string
+ * @param event the even
* @param format ancilliary format parameter - allowed to be null
* @return the formatted string
*/
1.27 +95 -77 jakarta-avalon-logkit/src/java/org/apache/log/format/PatternFormatter.java
Index: PatternFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/format/PatternFormatter.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- PatternFormatter.java 11 Feb 2002 13:27:02 -0000 1.26
+++ PatternFormatter.java 27 Mar 2002 22:07:56 -0000 1.27
@@ -71,7 +71,7 @@
* <td>Specifies the context map parameter name.</td>
* </tr><tr>
* <td><b>time</b></td>
- * <td>Specifies the pattern to be pass to
+ * <td>Specifies the pattern to be pass to
* {@link java.text.SimpleDateFormat SimpleDateFormat} to format the time.</td>
* </tr>
* </table>
@@ -89,63 +89,63 @@
* </p><p>
* The format string specifies that the logger should first print the
* time value of the log event without size restriction, then the
- * priority of the log event with a minimum and maximum size of 5,
+ * priority of the log event with a minimum and maximum size of 5,
* then the category of the log event right justified with a minimum
* and maximum size of 10, followed by the message of the log event
* without any size restriction.
* </p>
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Revision: 1.26 $ $Date: 2002/02/11 13:27:02 $
+ * @version CVS $Revision: 1.27 $ $Date: 2002/03/27 22:07:56 $
*/
public class PatternFormatter
implements Formatter, org.apache.log.Formatter
{
- private final static int TYPE_TEXT = 1;
- private final static int TYPE_CATEGORY = 2;
- private final static int TYPE_CONTEXT = 3;
- private final static int TYPE_MESSAGE = 4;
- private final static int TYPE_TIME = 5;
- private final static int TYPE_RELATIVE_TIME = 6;
- private final static int TYPE_THROWABLE = 7;
- private final static int TYPE_PRIORITY = 8;
+ private final static int TYPE_TEXT = 1;
+ private final static int TYPE_CATEGORY = 2;
+ private final static int TYPE_CONTEXT = 3;
+ private final static int TYPE_MESSAGE = 4;
+ private final static int TYPE_TIME = 5;
+ private final static int TYPE_RELATIVE_TIME = 6;
+ private final static int TYPE_THROWABLE = 7;
+ private final static int TYPE_PRIORITY = 8;
/**
* The maximum value used for TYPEs. Subclasses can define their own TYPEs
* starting at <code>MAX_TYPE + 1</code>.
*/
- protected final static int MAX_TYPE = TYPE_PRIORITY;
+ protected final static int MAX_TYPE = TYPE_PRIORITY;
- private final static String TYPE_CATEGORY_STR = "category";
- private final static String TYPE_CONTEXT_STR = "context";
- private final static String TYPE_MESSAGE_STR = "message";
- private final static String TYPE_TIME_STR = "time";
- private final static String TYPE_RELATIVE_TIME_STR = "rtime";
- private final static String TYPE_THROWABLE_STR = "throwable";
- private final static String TYPE_PRIORITY_STR = "priority";
-
- private final static String SPACE_16 = " ";
- private final static String SPACE_8 = " ";
- private final static String SPACE_4 = " ";
- private final static String SPACE_2 = " ";
- private final static String SPACE_1 = " ";
+ private final static String TYPE_CATEGORY_STR = "category";
+ private final static String TYPE_CONTEXT_STR = "context";
+ private final static String TYPE_MESSAGE_STR = "message";
+ private final static String TYPE_TIME_STR = "time";
+ private final static String TYPE_RELATIVE_TIME_STR = "rtime";
+ private final static String TYPE_THROWABLE_STR = "throwable";
+ private final static String TYPE_PRIORITY_STR = "priority";
+
+ private final static String SPACE_16 = " ";
+ private final static String SPACE_8 = " ";
+ private final static String SPACE_4 = " ";
+ private final static String SPACE_2 = " ";
+ private final static String SPACE_1 = " ";
- private final static String EOL = System.getProperty( "line.separator", "\n" );
+ private final static String EOL = System.getProperty( "line.separator", "\n" );
protected static class PatternRun
{
- public String m_data;
- public boolean m_rightJustify;
- public int m_minSize;
- public int m_maxSize;
- public int m_type;
- public String m_format;
+ public String m_data;
+ public boolean m_rightJustify;
+ public int m_minSize;
+ public int m_maxSize;
+ public int m_type;
+ public String m_format;
}
- private PatternRun m_formatSpecification[];
+ private PatternRun m_formatSpecification[];
- private SimpleDateFormat m_simpleDateFormat;
- private final Date m_date = new Date();
+ private SimpleDateFormat m_simpleDateFormat;
+ private final Date m_date = new Date();
/**
* @deprecated Use constructor PatternFormatter(String pattern) as this does not
@@ -176,19 +176,20 @@
final int start = index++;
//first check for a +|- sign
- if( '+' == pattern[ index ] ) index++;
+ if( '+' == pattern[ index ] )
+ index++;
else if( '-' == pattern[ index ] )
{
run.m_rightJustify = true;
index++;
}
- if( Character.isDigit( pattern[ index ] ))
+ if( Character.isDigit( pattern[ index ] ) )
{
int total = 0;
while( Character.isDigit( pattern[ index ] ) )
{
- total = total * 10 + (pattern[ index ] - '0');
+ total = total * 10 + ( pattern[ index ] - '0' );
index++;
}
run.m_minSize = total;
@@ -199,12 +200,12 @@
{
index++;
- if( Character.isDigit( pattern[ index ] ))
+ if( Character.isDigit( pattern[ index ] ) )
{
int total = 0;
while( Character.isDigit( pattern[ index ] ) )
{
- total = total * 10 + (pattern[ index ] - '0');
+ total = total * 10 + ( pattern[ index ] - '0' );
index++;
}
run.m_maxSize = total;
@@ -221,7 +222,7 @@
int typeStart = index;
while( index < pattern.length &&
- pattern[ index ]!= ':' && pattern[ index ] != '}' )
+ pattern[ index ] != ':' && pattern[ index ] != '}' )
{
index++;
}
@@ -249,8 +250,8 @@
if( index >= pattern.length || '}' != pattern[ index ] )
{
throw new
- IllegalArgumentException("Unterminated type in pattern at character "
- + index );
+ IllegalArgumentException( "Unterminated type in pattern at character "
+ + index );
}
index++;
@@ -286,13 +287,18 @@
{
if( escapeMode )
{
- if( 'n' == pattern[ index ] ) sb.append( EOL );
- else if( 't' == pattern[ index ] ) sb.append( '\t' );
- else sb.append( pattern[ index ] );
+ if( 'n' == pattern[ index ] )
+ sb.append( EOL );
+ else if( 't' == pattern[ index ] )
+ sb.append( '\t' );
+ else
+ sb.append( pattern[ index ] );
escapeMode = false;
}
- else if( '\\' == pattern[ index ] ) escapeMode = true;
- else sb.append( pattern[ index ] );
+ else if( '\\' == pattern[ index ] )
+ escapeMode = true;
+ else
+ sb.append( pattern[ index ] );
index++;
}
@@ -434,28 +440,34 @@
{
switch( run.m_type )
{
- case TYPE_RELATIVE_TIME: return getRTime( event.getRelativeTime(), run.m_format );
- case TYPE_TIME: return getTime( event.getTime(), run.m_format );
- case TYPE_THROWABLE: return getStackTrace( event.getThrowable(), run.m_format );
- case TYPE_MESSAGE: return getMessage( event.getMessage(), run.m_format );
- case TYPE_CATEGORY: return getCategory( event.getCategory(), run.m_format );
- case TYPE_PRIORITY: return getPriority( event.getPriority(), run.m_format );
-
- case TYPE_CONTEXT:
- if( null == run.m_format ||
- run.m_format.startsWith( "stack" ) )
- {
- //Print a warning out to stderr here
- //to indicate you are using a deprecated feature?
- return getContext( event.getContextStack(), run.m_format );
- }
- else
- {
- return getContextMap( event.getContextMap(), run.m_format );
- }
+ case TYPE_RELATIVE_TIME:
+ return getRTime( event.getRelativeTime(), run.m_format );
+ case TYPE_TIME:
+ return getTime( event.getTime(), run.m_format );
+ case TYPE_THROWABLE:
+ return getStackTrace( event.getThrowable(), run.m_format );
+ case TYPE_MESSAGE:
+ return getMessage( event.getMessage(), run.m_format );
+ case TYPE_CATEGORY:
+ return getCategory( event.getCategory(), run.m_format );
+ case TYPE_PRIORITY:
+ return getPriority( event.getPriority(), run.m_format );
+
+ case TYPE_CONTEXT:
+ if( null == run.m_format ||
+ run.m_format.startsWith( "stack" ) )
+ {
+ //Print a warning out to stderr here
+ //to indicate you are using a deprecated feature?
+ return getContext( event.getContextStack(), run.m_format );
+ }
+ else
+ {
+ return getContextMap( event.getContextMap(), run.m_format );
+ }
- default:
- throw new IllegalStateException( "Unknown Pattern specification." + run.m_type );
+ default:
+ throw new IllegalStateException( "Unknown Pattern specification." + run.m_type );
}
}
@@ -566,7 +578,7 @@
*/
protected String getTime( final long time, final String format )
{
- if ( null == format )
+ if( null == format )
{
return Long.toString( time );
}
@@ -592,12 +604,18 @@
*/
protected int getTypeIdFor( final String type )
{
- if( type.equalsIgnoreCase( TYPE_CATEGORY_STR ) ) return TYPE_CATEGORY;
- else if( type.equalsIgnoreCase( TYPE_CONTEXT_STR ) ) return TYPE_CONTEXT;
- else if( type.equalsIgnoreCase( TYPE_MESSAGE_STR ) ) return TYPE_MESSAGE;
- else if( type.equalsIgnoreCase( TYPE_PRIORITY_STR ) ) return TYPE_PRIORITY;
- else if( type.equalsIgnoreCase( TYPE_TIME_STR ) ) return TYPE_TIME;
- else if( type.equalsIgnoreCase( TYPE_RELATIVE_TIME_STR ) ) return TYPE_RELATIVE_TIME;
+ if( type.equalsIgnoreCase( TYPE_CATEGORY_STR ) )
+ return TYPE_CATEGORY;
+ else if( type.equalsIgnoreCase( TYPE_CONTEXT_STR ) )
+ return TYPE_CONTEXT;
+ else if( type.equalsIgnoreCase( TYPE_MESSAGE_STR ) )
+ return TYPE_MESSAGE;
+ else if( type.equalsIgnoreCase( TYPE_PRIORITY_STR ) )
+ return TYPE_PRIORITY;
+ else if( type.equalsIgnoreCase( TYPE_TIME_STR ) )
+ return TYPE_TIME;
+ else if( type.equalsIgnoreCase( TYPE_RELATIVE_TIME_STR ) )
+ return TYPE_RELATIVE_TIME;
else if( type.equalsIgnoreCase( TYPE_THROWABLE_STR ) )
{
return TYPE_THROWABLE;
@@ -632,7 +650,7 @@
}
else
{
- index += addTextRun( stack, pattern, index );
+ index += addTextRun( stack, pattern, index );
}
}
1.7 +1 -1 jakarta-avalon-logkit/src/java/org/apache/log/format/RawFormatter.java
Index: RawFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/format/RawFormatter.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RawFormatter.java 19 Nov 2001 12:18:34 -0000 1.6
+++ RawFormatter.java 27 Mar 2002 22:07:56 -0000 1.7
@@ -10,7 +10,7 @@
import org.apache.log.LogEvent;
/**
- * Basic formatter that just returns raw
+ * Basic formatter that just returns raw
* message string and ignores remainder of LogEvent.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
1.8 +50 -45 jakarta-avalon-logkit/src/java/org/apache/log/format/SyslogFormatter.java
Index: SyslogFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/format/SyslogFormatter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SyslogFormatter.java 22 Dec 2001 02:54:33 -0000 1.7
+++ SyslogFormatter.java 27 Mar 2002 22:07:56 -0000 1.8
@@ -11,7 +11,7 @@
import org.apache.log.Priority;
/**
- * A formatter that serializes in the format originally
+ * A formatter that serializes in the format originally
* used by BSD syslog daemon.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
@@ -19,54 +19,54 @@
public class SyslogFormatter
implements Formatter, org.apache.log.Formatter
{
- public static final int PRIORITY_DEBUG = 7;
- public static final int PRIORITY_INFO = 6;
- public static final int PRIORITY_NOTICE = 5;
- public static final int PRIORITY_WARNING = 4;
- public static final int PRIORITY_ERR = 3;
- public static final int PRIORITY_CRIT = 2;
- public static final int PRIORITY_ALERT = 1;
- public static final int PRIORITY_EMERG = 0;
+ public static final int PRIORITY_DEBUG = 7;
+ public static final int PRIORITY_INFO = 6;
+ public static final int PRIORITY_NOTICE = 5;
+ public static final int PRIORITY_WARNING = 4;
+ public static final int PRIORITY_ERR = 3;
+ public static final int PRIORITY_CRIT = 2;
+ public static final int PRIORITY_ALERT = 1;
+ public static final int PRIORITY_EMERG = 0;
/*
* Constants for facility.
- */
- public static final int FACILITY_KERN = ( 0<<3);
- public static final int FACILITY_USER = ( 1<<3);
- public static final int FACILITY_MAIL = ( 2<<3);
- public static final int FACILITY_DAEMON = ( 3<<3);
- public static final int FACILITY_AUTH = ( 4<<3);
- public static final int FACILITY_SYSLOG = ( 5<<3);
- public static final int FACILITY_LPR = ( 6<<3);
- public static final int FACILITY_NEWS = ( 7<<3);
- public static final int FACILITY_UUCP = ( 8<<3);
- public static final int FACILITY_CRON = ( 9<<3);
- public static final int FACILITY_AUTHPRIV = (10<<3);
- public static final int FACILITY_FTP = (11<<3);
-
- public static final int FACILITY_LOCAL0 = (16<<3);
- public static final int FACILITY_LOCAL1 = (17<<3);
- public static final int FACILITY_LOCAL2 = (18<<3);
- public static final int FACILITY_LOCAL3 = (19<<3);
- public static final int FACILITY_LOCAL4 = (20<<3);
- public static final int FACILITY_LOCAL5 = (21<<3);
- public static final int FACILITY_LOCAL6 = (22<<3);
- public static final int FACILITY_LOCAL7 = (23<<3);
+ */
+ public static final int FACILITY_KERN = ( 0 << 3 );
+ public static final int FACILITY_USER = ( 1 << 3 );
+ public static final int FACILITY_MAIL = ( 2 << 3 );
+ public static final int FACILITY_DAEMON = ( 3 << 3 );
+ public static final int FACILITY_AUTH = ( 4 << 3 );
+ public static final int FACILITY_SYSLOG = ( 5 << 3 );
+ public static final int FACILITY_LPR = ( 6 << 3 );
+ public static final int FACILITY_NEWS = ( 7 << 3 );
+ public static final int FACILITY_UUCP = ( 8 << 3 );
+ public static final int FACILITY_CRON = ( 9 << 3 );
+ public static final int FACILITY_AUTHPRIV = ( 10 << 3 );
+ public static final int FACILITY_FTP = ( 11 << 3 );
+
+ public static final int FACILITY_LOCAL0 = ( 16 << 3 );
+ public static final int FACILITY_LOCAL1 = ( 17 << 3 );
+ public static final int FACILITY_LOCAL2 = ( 18 << 3 );
+ public static final int FACILITY_LOCAL3 = ( 19 << 3 );
+ public static final int FACILITY_LOCAL4 = ( 20 << 3 );
+ public static final int FACILITY_LOCAL5 = ( 21 << 3 );
+ public static final int FACILITY_LOCAL6 = ( 22 << 3 );
+ public static final int FACILITY_LOCAL7 = ( 23 << 3 );
///String descriptions of all the facilities
protected static final String[] FACILITY_DESCRIPTIONS =
- {
- "kern", "user", "mail", "daemon", "auth", "syslog",
- "lpr", "news", "uucp", "cron", "authpriv", "ftp",
- "", "", "", "", "local0", "local1", "local2", "local3",
- "local4", "local5", "local6", "local7"
- };
+ {
+ "kern", "user", "mail", "daemon", "auth", "syslog",
+ "lpr", "news", "uucp", "cron", "authpriv", "ftp",
+ "", "", "", "", "local0", "local1", "local2", "local3",
+ "local4", "local5", "local6", "local7"
+ };
///Constant for holding facility id
- private int m_facility;
+ private int m_facility;
///flag to decide whether we write out Facility banner
- private boolean m_showFacilityBanner;
+ private boolean m_showFacilityBanner;
/**
* Constructor that assumes FACILITY_USER.
@@ -122,7 +122,7 @@
message = getFacilityDescription( facility ) + ": " + message;
}
- return "<" + (facility|priority) + "> " + message;
+ return "<" + ( facility | priority ) + "> " + message;
}
/**
@@ -157,10 +157,15 @@
*/
protected int getSyslogPriority( final LogEvent event )
{
- if( event.getPriority().isLowerOrEqual( Priority.DEBUG ) ) return PRIORITY_DEBUG;
- else if( event.getPriority().isLowerOrEqual( Priority.INFO ) ) return PRIORITY_INFO;
- else if( event.getPriority().isLowerOrEqual( Priority.WARN ) ) return PRIORITY_WARNING;
- else if( event.getPriority().isLowerOrEqual( Priority.ERROR ) ) return PRIORITY_ERR;
- else return PRIORITY_CRIT;
+ if( event.getPriority().isLowerOrEqual( Priority.DEBUG ) )
+ return PRIORITY_DEBUG;
+ else if( event.getPriority().isLowerOrEqual( Priority.INFO ) )
+ return PRIORITY_INFO;
+ else if( event.getPriority().isLowerOrEqual( Priority.WARN ) )
+ return PRIORITY_WARNING;
+ else if( event.getPriority().isLowerOrEqual( Priority.ERROR ) )
+ return PRIORITY_ERR;
+ else
+ return PRIORITY_CRIT;
}
}
1.6 +13 -13 jakarta-avalon-logkit/src/java/org/apache/log/format/XMLFormatter.java
Index: XMLFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/format/XMLFormatter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLFormatter.java 19 Nov 2001 12:18:34 -0000 1.5
+++ XMLFormatter.java 27 Mar 2002 22:07:56 -0000 1.6
@@ -7,8 +7,8 @@
*/
package org.apache.log.format;
-import org.apache.log.LogEvent;
import java.util.Date;
+import org.apache.log.LogEvent;
/**
* Basic XML formatter that writes out a basic XML-ified log event.
@@ -21,19 +21,19 @@
public class XMLFormatter
implements Formatter, org.apache.log.Formatter
{
- private static final String EOL = System.getProperty( "line.separator", "\n" );
+ private static final String EOL = System.getProperty( "line.separator", "\n" );
- //Booleans indicating whether or not we
+ //Booleans indicating whether or not we
//print out a particular field
- private boolean m_printTime = true;
- private boolean m_printRelativeTime = false;
- private boolean m_printPriority = true;
- private boolean m_printCategory = true;
- private boolean m_printContext = true;
- private boolean m_printMessage = true;
- private boolean m_printException = true;
+ private boolean m_printTime = true;
+ private boolean m_printRelativeTime = false;
+ private boolean m_printPriority = true;
+ private boolean m_printCategory = true;
+ private boolean m_printContext = true;
+ private boolean m_printMessage = true;
+ private boolean m_printException = true;
- private boolean m_printNumericTime = true;
+ private boolean m_printNumericTime = true;
/**
* Print out time field to log.
@@ -117,11 +117,11 @@
sb.append( "<log-entry>" );
sb.append( EOL );
-
+
if( m_printTime )
{
sb.append( " <time>" );
-
+
if( m_printNumericTime )
{
sb.append( event.getTime() );
1.11 +1 -2 jakarta-avalon-logkit/src/java/org/apache/log/output/AbstractOutputTarget.java
Index: AbstractOutputTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/AbstractOutputTarget.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AbstractOutputTarget.java 19 Nov 2001 12:18:34 -0000 1.10
+++ AbstractOutputTarget.java 27 Mar 2002 22:07:57 -0000 1.11
@@ -8,7 +8,6 @@
package org.apache.log.output;
import org.apache.log.LogEvent;
-import org.apache.log.LogTarget;
import org.apache.log.format.Formatter;
/**
@@ -27,7 +26,7 @@
* @deprecated You should not be directly accessing this attribute
* as it will become private next release
*/
- protected Formatter m_formatter;
+ protected Formatter m_formatter;
/**
* Parameterless constructor.
1.5 +1 -1 jakarta-avalon-logkit/src/java/org/apache/log/output/AbstractTarget.java
Index: AbstractTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/AbstractTarget.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractTarget.java 21 Mar 2002 15:07:23 -0000 1.4
+++ AbstractTarget.java 27 Mar 2002 22:07:57 -0000 1.5
@@ -27,7 +27,7 @@
private ErrorHandler m_errorHandler = DEFAULT_ERROR_HANDLER;
///Flag indicating that log session is finished (aka target has been closed)
- private boolean m_isOpen;
+ private boolean m_isOpen;
/**
* Provide component with ErrorHandler.
1.9 +22 -17 jakarta-avalon-logkit/src/java/org/apache/log/output/AsyncLogTarget.java
Index: AsyncLogTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/AsyncLogTarget.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- AsyncLogTarget.java 21 Jan 2002 12:26:13 -0000 1.8
+++ AsyncLogTarget.java 27 Mar 2002 22:07:57 -0000 1.9
@@ -8,14 +8,14 @@
package org.apache.log.output;
import java.util.LinkedList;
-import org.apache.log.ErrorHandler;
import org.apache.log.ErrorAware;
+import org.apache.log.ErrorHandler;
import org.apache.log.LogEvent;
import org.apache.log.LogTarget;
/**
* An asynchronous LogTarget that sends entries on in another thread.
- * It is the responsibility of the user of this class to start
+ * It is the responsibility of the user of this class to start
* the thread etc.
*
* <pre>
@@ -30,13 +30,13 @@
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
*/
-public class AsyncLogTarget
+public class AsyncLogTarget
extends AbstractTarget
implements Runnable
{
- private final LinkedList m_list;
- private final int m_queueSize;
- private final LogTarget m_logTarget;
+ private final LinkedList m_list;
+ private final int m_queueSize;
+ private final LogTarget m_logTarget;
public AsyncLogTarget( final LogTarget logTarget )
{
@@ -62,7 +62,7 @@
if( m_logTarget instanceof ErrorAware )
{
- ((ErrorAware)m_logTarget).setErrorHandler( errorHandler );
+ ( (ErrorAware)m_logTarget ).setErrorHandler( errorHandler );
}
}
@@ -78,11 +78,14 @@
final int size = m_list.size();
while( m_queueSize <= size )
{
- try { m_list.wait(); }
+ try
+ {
+ m_list.wait();
+ }
catch( final InterruptedException ie )
{
//This really should not occur ...
- //Maybe we should log it though for
+ //Maybe we should log it though for
//now lets ignore it
}
}
@@ -91,7 +94,7 @@
if( size == 0 )
{
- //tell the "server" thread to wake up
+ //tell the "server" thread to wake up
//if it is waiting for a queue to contain some items
m_list.notify();
}
@@ -117,10 +120,10 @@
if( size > 0 )
{
event = (LogEvent)m_list.removeLast();
-
+
if( size == m_queueSize )
{
- //tell the "client" thread to wake up
+ //tell the "client" thread to wake up
//if it is waiting for a queue position to open up
m_list.notify();
}
@@ -134,10 +137,13 @@
}
else
{
- try { m_list.wait(); }
+ try
+ {
+ m_list.wait();
+ }
catch( final InterruptedException ie )
{
- //Ignore this and let it be dealt in next loop
+ //Ignore this and let it be dealt in next loop
//Need to set variable as the exception throw cleared status
interupted = true;
}
@@ -145,9 +151,8 @@
}
}
-
- try
- {
+ try
+ {
//actually process an event
m_logTarget.processEvent( event );
}
1.6 +12 -10 jakarta-avalon-logkit/src/java/org/apache/log/output/MemoryTarget.java
Index: MemoryTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/MemoryTarget.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MemoryTarget.java 19 Nov 2001 12:18:34 -0000 1.5
+++ MemoryTarget.java 27 Mar 2002 22:07:57 -0000 1.6
@@ -26,22 +26,22 @@
extends AbstractTarget
{
///Buffer for all the LogEvents
- private final LogEvent[] m_buffer;
+ private final LogEvent[] m_buffer;
///Priority at which to push LogEvents to next LogTarget
- private Priority m_threshold;
+ private Priority m_threshold;
///Target to push LogEvents to
- private LogTarget m_target;
+ private LogTarget m_target;
///Count of used events
- private int m_used;
+ private int m_used;
///Position of last element inserted
- private int m_index;
+ private int m_index;
///Flag indicating whether it is possible to overite elements in array
- private boolean m_overwrite;
+ private boolean m_overwrite;
public MemoryTarget( final LogTarget target,
final int size,
@@ -73,7 +73,8 @@
//Check if it is full
if( isFull() )
{
- if( m_overwrite ) m_used--;
+ if( m_overwrite )
+ m_used--;
else
{
getErrorHandler().error( "Memory buffer is full", null, event );
@@ -81,10 +82,11 @@
}
}
- if( 0 == m_used ) m_index = 0;
+ if( 0 == m_used )
+ m_index = 0;
else
{
- m_index = (m_index + 1) % m_buffer.length;
+ m_index = ( m_index + 1 ) % m_buffer.length;
}
m_buffer[ m_index ] = event;
m_used++;
@@ -137,7 +139,7 @@
for( int i = 0; i < size; i++ )
{
- final int index = (base + i) % m_buffer.length;
+ final int index = ( base + i ) % m_buffer.length;
//process event in buffer
m_target.processEvent( m_buffer[ index ] );
1.6 +1 -1 jakarta-avalon-logkit/src/java/org/apache/log/output/NullOutputLogTarget.java
Index: NullOutputLogTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/NullOutputLogTarget.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NullOutputLogTarget.java 19 Nov 2001 12:18:34 -0000 1.5
+++ NullOutputLogTarget.java 27 Mar 2002 22:07:57 -0000 1.6
@@ -12,7 +12,7 @@
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
*/
-public class NullOutputLogTarget
+public class NullOutputLogTarget
extends AbstractOutputTarget
{
public NullOutputLogTarget()
1.9 +0 -1 jakarta-avalon-logkit/src/java/org/apache/log/output/ServletOutputLogTarget.java
Index: ServletOutputLogTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/ServletOutputLogTarget.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ServletOutputLogTarget.java 16 Aug 2001 10:13:56 -0000 1.8
+++ ServletOutputLogTarget.java 27 Mar 2002 22:07:57 -0000 1.9
@@ -1,7 +1,6 @@
package org.apache.log.output;
import javax.servlet.ServletContext;
-import org.apache.log.LogEvent;
/**
* Generic logging interface. Implementations are based on the strategy
1.5 +2 -2 jakarta-avalon-logkit/src/java/org/apache/log/output/db/AbstractJDBCTarget.java
Index: AbstractJDBCTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/db/AbstractJDBCTarget.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractJDBCTarget.java 19 Nov 2001 12:18:34 -0000 1.4
+++ AbstractJDBCTarget.java 27 Mar 2002 22:07:57 -0000 1.5
@@ -22,10 +22,10 @@
extends AbstractTarget
{
///Datasource to extract connections from
- private DataSource m_dataSource;
+ private DataSource m_dataSource;
///Database connection
- private Connection m_connection;
+ private Connection m_connection;
protected AbstractJDBCTarget( final DataSource dataSource )
{
1.3 +3 -3 jakarta-avalon-logkit/src/java/org/apache/log/output/db/ColumnInfo.java
Index: ColumnInfo.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/db/ColumnInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ColumnInfo.java 19 Nov 2001 12:18:34 -0000 1.2
+++ ColumnInfo.java 27 Mar 2002 22:07:57 -0000 1.3
@@ -15,13 +15,13 @@
public class ColumnInfo
{
///Name of column
- private final String m_name;
+ private final String m_name;
///Type/Source of column
- private final int m_type;
+ private final int m_type;
///Auxilliary parameters (ie constant or sub-format)
- private final String m_aux; //may be null
+ private final String m_aux; //may be null
public ColumnInfo( final String name, final int type, final String aux )
{
1.3 +36 -28 jakarta-avalon-logkit/src/java/org/apache/log/output/db/ColumnType.java
Index: ColumnType.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/db/ColumnType.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ColumnType.java 19 Nov 2001 12:18:34 -0000 1.2
+++ ColumnType.java 27 Mar 2002 22:07:57 -0000 1.3
@@ -15,17 +15,17 @@
public class ColumnType
{
//x-db sequencer...
- public final static int SEQUENCE = 0;
+ public final static int SEQUENCE = 0;
- public final static int STATIC = 1;
- public final static int CATEGORY = 2;
- public final static int CONTEXT = 3;
- public final static int MESSAGE = 4;
- public final static int TIME = 5;
- public final static int RELATIVE_TIME = 6;
- public final static int THROWABLE = 7;
- public final static int PRIORITY = 8;
- public final static int HOSTNAME = 9;
+ public final static int STATIC = 1;
+ public final static int CATEGORY = 2;
+ public final static int CONTEXT = 3;
+ public final static int MESSAGE = 4;
+ public final static int TIME = 5;
+ public final static int RELATIVE_TIME = 6;
+ public final static int THROWABLE = 7;
+ public final static int PRIORITY = 8;
+ public final static int HOSTNAME = 9;
//public final static int IPADDRESS = 10;
/**
@@ -34,30 +34,38 @@
*/
//public final static int MAX_TYPE = IPADDRESS;
- public final static String SEQUENCE_STR = "sequence";
- public final static String STATIC_STR = "static";
- public final static String CATEGORY_STR = "category";
- public final static String CONTEXT_STR = "context";
- public final static String MESSAGE_STR = "message";
- public final static String TIME_STR = "time";
- public final static String RELATIVE_TIME_STR = "rtime";
- public final static String THROWABLE_STR = "throwable";
- public final static String PRIORITY_STR = "priority";
- public final static String HOSTNAME_STR = "hostname";
+ public final static String SEQUENCE_STR = "sequence";
+ public final static String STATIC_STR = "static";
+ public final static String CATEGORY_STR = "category";
+ public final static String CONTEXT_STR = "context";
+ public final static String MESSAGE_STR = "message";
+ public final static String TIME_STR = "time";
+ public final static String RELATIVE_TIME_STR = "rtime";
+ public final static String THROWABLE_STR = "throwable";
+ public final static String PRIORITY_STR = "priority";
+ public final static String HOSTNAME_STR = "hostname";
//public final static String IPADDRESS_STR = "ipaddress";
public static int getTypeIdFor( final String type )
{
- if( type.equalsIgnoreCase( CATEGORY_STR ) ) return CATEGORY;
- else if( type.equalsIgnoreCase( STATIC_STR ) ) return STATIC;
- else if( type.equalsIgnoreCase( CONTEXT_STR ) ) return CONTEXT;
- else if( type.equalsIgnoreCase( MESSAGE_STR ) ) return MESSAGE;
- else if( type.equalsIgnoreCase( PRIORITY_STR ) ) return PRIORITY;
- else if( type.equalsIgnoreCase( TIME_STR ) ) return TIME;
- else if( type.equalsIgnoreCase( RELATIVE_TIME_STR ) ) return RELATIVE_TIME;
+ if( type.equalsIgnoreCase( CATEGORY_STR ) )
+ return CATEGORY;
+ else if( type.equalsIgnoreCase( STATIC_STR ) )
+ return STATIC;
+ else if( type.equalsIgnoreCase( CONTEXT_STR ) )
+ return CONTEXT;
+ else if( type.equalsIgnoreCase( MESSAGE_STR ) )
+ return MESSAGE;
+ else if( type.equalsIgnoreCase( PRIORITY_STR ) )
+ return PRIORITY;
+ else if( type.equalsIgnoreCase( TIME_STR ) )
+ return TIME;
+ else if( type.equalsIgnoreCase( RELATIVE_TIME_STR ) )
+ return RELATIVE_TIME;
//else if( type.equalsIgnoreCase( IPADDRESS_STR ) ) return IPADDRESS;
- else if( type.equalsIgnoreCase( HOSTNAME_STR ) ) return HOSTNAME;
+ else if( type.equalsIgnoreCase( HOSTNAME_STR ) )
+ return HOSTNAME;
else if( type.equalsIgnoreCase( THROWABLE_STR ) )
{
return THROWABLE;
1.3 +21 -21 jakarta-avalon-logkit/src/java/org/apache/log/output/db/DefaultDataSource.java
Index: DefaultDataSource.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/db/DefaultDataSource.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultDataSource.java 19 Nov 2001 12:18:34 -0000 1.2
+++ DefaultDataSource.java 27 Mar 2002 22:07:57 -0000 1.3
@@ -7,14 +7,14 @@
*/
package org.apache.log.output.db;
-import java.sql.DriverManager;
import java.io.PrintWriter;
-import java.sql.SQLException;
import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
import javax.sql.DataSource;
/**
- * A basic datasource that doesn't do any pooling but just wraps
+ * A basic datasource that doesn't do any pooling but just wraps
* around default mechanisms.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
@@ -22,15 +22,15 @@
public class DefaultDataSource
implements DataSource
{
- private final String m_username;
- private final String m_password;
- private final String m_url;
+ private final String m_username;
+ private final String m_password;
+ private final String m_url;
- private PrintWriter m_logWriter;
- private int m_loginTimeout;
+ private PrintWriter m_logWriter;
+ private int m_loginTimeout;
- public DefaultDataSource( final String url,
- final String username,
+ public DefaultDataSource( final String url,
+ final String username,
final String password )
{
m_url = url;
@@ -63,16 +63,16 @@
}
/**
- * Gets the maximum time in seconds that this data source can wait while
- * attempting to connect to a database.
- *
- * @return the login time
- */
- public int getLoginTimeout()
+ * Gets the maximum time in seconds that this data source can wait while
+ * attempting to connect to a database.
+ *
+ * @return the login time
+ */
+ public int getLoginTimeout()
throws SQLException
- {
- return m_loginTimeout;
- }
+ {
+ return m_loginTimeout;
+ }
/**
* Get the log writer for this data source.
@@ -84,9 +84,9 @@
{
return m_logWriter;
}
-
+
/**
- * Sets the maximum time in seconds that this data source will wait
+ * Sets the maximum time in seconds that this data source will wait
* while attempting to connect to a database.
*
* @param loginTimeout the loging timeout in seconds
1.4 +65 -63 jakarta-avalon-logkit/src/java/org/apache/log/output/db/DefaultJDBCTarget.java
Index: DefaultJDBCTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/db/DefaultJDBCTarget.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultJDBCTarget.java 19 Nov 2001 12:18:34 -0000 1.3
+++ DefaultJDBCTarget.java 27 Mar 2002 22:07:57 -0000 1.4
@@ -14,7 +14,6 @@
import java.sql.Timestamp;
import javax.sql.DataSource;
import org.apache.log.ContextMap;
-import org.apache.log.Hierarchy;
import org.apache.log.LogEvent;
/**
@@ -25,10 +24,10 @@
public class DefaultJDBCTarget
extends AbstractJDBCTarget
{
- private final String m_table;
- private final ColumnInfo[] m_columns;
-
- private PreparedStatement m_statement;
+ private final String m_table;
+ private final ColumnInfo[] m_columns;
+
+ private PreparedStatement m_statement;
public DefaultJDBCTarget( final DataSource dataSource,
final String table,
@@ -147,7 +146,10 @@
if( null != m_statement )
{
- try { m_statement.close(); }
+ try
+ {
+ m_statement.close();
+ }
catch( final SQLException se )
{
getErrorHandler().error( "Error closing statement", se, null );
@@ -169,41 +171,41 @@
switch( info.getType() )
{
- case ColumnType.RELATIVE_TIME:
- statement.setLong( index + 1, event.getRelativeTime() );
- break;
-
- case ColumnType.TIME:
- statement.setTimestamp( index + 1, new Timestamp( event.getTime() ) );
- break;
-
- case ColumnType.MESSAGE:
- statement.setString( index + 1, event.getMessage() );
- break;
-
- case ColumnType.CATEGORY:
- statement.setString( index + 1, event.getCategory() );
- break;
-
- case ColumnType.PRIORITY:
- statement.setString( index + 1, event.getPriority().getName() );
- break;
-
- case ColumnType.CONTEXT:
- statement.setString( index + 1, getContextMap( event.getContextMap(),
- info.getAux() ) );
- break;
-
- case ColumnType.STATIC:
- statement.setString( index + 1, info.getAux() );
- break;
-
- case ColumnType.THROWABLE:
- statement.setString( index + 1, getStackTrace( event.getThrowable() ) );
- break;
+ case ColumnType.RELATIVE_TIME:
+ statement.setLong( index + 1, event.getRelativeTime() );
+ break;
+
+ case ColumnType.TIME:
+ statement.setTimestamp( index + 1, new Timestamp( event.getTime() ) );
+ break;
+
+ case ColumnType.MESSAGE:
+ statement.setString( index + 1, event.getMessage() );
+ break;
+
+ case ColumnType.CATEGORY:
+ statement.setString( index + 1, event.getCategory() );
+ break;
+
+ case ColumnType.PRIORITY:
+ statement.setString( index + 1, event.getPriority().getName() );
+ break;
+
+ case ColumnType.CONTEXT:
+ statement.setString( index + 1, getContextMap( event.getContextMap(),
+ info.getAux() ) );
+ break;
+
+ case ColumnType.STATIC:
+ statement.setString( index + 1, info.getAux() );
+ break;
+
+ case ColumnType.THROWABLE:
+ statement.setString( index + 1, getStackTrace( event.getThrowable() ) );
+ break;
- default:
- throw new IllegalStateException( "Unknown ColumnType: " + info.getType() );
+ default:
+ throw new IllegalStateException( "Unknown ColumnType: " + info.getType() );
}
}
@@ -230,27 +232,27 @@
if( null == map ) return "";
return map.get( aux, "" ).toString();
}
-/*
- protected String getHostName( final LogEvent event, final String aux )
- {
- String result = null;
-
- final ContextMap map = event.getContextMap();
- if( null != map )
- {
- final Object object = map.get( "hostname" );
- if( null != object )
- {
- result = object.toString();
- }
- }
-
- if( null == result )
- {
- result = "Unknown hostname";
- }
-
- return result;
- }
-*/
+ /*
+ protected String getHostName( final LogEvent event, final String aux )
+ {
+ String result = null;
+
+ final ContextMap map = event.getContextMap();
+ if( null != map )
+ {
+ final Object object = map.get( "hostname" );
+ if( null != object )
+ {
+ result = object.toString();
+ }
+ }
+
+ if( null == result )
+ {
+ result = "Unknown hostname";
+ }
+
+ return result;
+ }
+ */
}
1.4 +37 -27 jakarta-avalon-logkit/src/java/org/apache/log/output/db/NormalizedJDBCTarget.java
Index: NormalizedJDBCTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/db/NormalizedJDBCTarget.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NormalizedJDBCTarget.java 19 Nov 2001 12:18:34 -0000 1.3
+++ NormalizedJDBCTarget.java 27 Mar 2002 22:07:57 -0000 1.4
@@ -7,11 +7,11 @@
*/
package org.apache.log.output.db;
-import java.util.HashMap;
-import java.sql.Statement;
-import java.sql.ResultSet;
import java.sql.PreparedStatement;
+import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
import javax.sql.DataSource;
import org.apache.log.LogEvent;
@@ -19,7 +19,7 @@
* JDBC target that writes to normalized tables.
* This reduces overhead and cost of querying/storing logs.
*
- * <p>Parts based on JDBC logger from prottomatter by
+ * <p>Parts based on JDBC logger from prottomatter by
* <a href="mailto:nate@protomatter.com">Nate Sammons</a></p>
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
@@ -27,8 +27,8 @@
public class NormalizedJDBCTarget
extends DefaultJDBCTarget
{
- private HashMap m_categoryIDs = new HashMap();
- private HashMap m_priorityIDs = new HashMap();
+ private HashMap m_categoryIDs = new HashMap();
+ private HashMap m_priorityIDs = new HashMap();
public NormalizedJDBCTarget( final DataSource dataSource,
final String table,
@@ -51,20 +51,20 @@
switch( info.getType() )
{
- case ColumnType.CATEGORY:
- tableName = getTable() + "_" + ColumnType.CATEGORY_STR + "_SET";
- id = getID( tableName, m_categoryIDs, event.getCategory() );
- statement.setInt( index + 1, id );
- break;
-
- case ColumnType.PRIORITY:
- tableName = getTable() + "_" + ColumnType.PRIORITY_STR + "_SET";
- id = getID( tableName, m_priorityIDs, event.getPriority().getName() );
- statement.setInt( index + 1, id );
- break;
+ case ColumnType.CATEGORY:
+ tableName = getTable() + "_" + ColumnType.CATEGORY_STR + "_SET";
+ id = getID( tableName, m_categoryIDs, event.getCategory() );
+ statement.setInt( index + 1, id );
+ break;
+
+ case ColumnType.PRIORITY:
+ tableName = getTable() + "_" + ColumnType.PRIORITY_STR + "_SET";
+ id = getID( tableName, m_priorityIDs, event.getPriority().getName() );
+ statement.setInt( index + 1, id );
+ break;
- default:
- super.specifyColumn( statement, index, event );
+ default:
+ super.specifyColumn( statement, index, event );
}
}
@@ -77,7 +77,7 @@
// see if it's been put in before.
Statement statement = null;
ResultSet resultSet = null;
-
+
try
{
statement = getConnection().createStatement();
@@ -91,13 +91,13 @@
idMap.put( instance, newID );
return newID.intValue();
}
-
+
resultSet.close();
//Note that the next part should be a transaction but
//it is not mega vital so ...
- //Find the max id in table and set
+ //Find the max id in table and set
//max to it's value if any items are present in table
final String maxQuerySql = "SELECT MAX(ID) FROM " + tableName;
resultSet = statement.executeQuery( maxQuerySql );
@@ -106,7 +106,7 @@
resultSet.close();
final int newID = max + 1;
- final String insertSQL = "INSERT INTO " + tableName +
+ final String insertSQL = "INSERT INTO " + tableName +
" (ID, NAME) VALUES ( " + newID + ", '" + instance + "')";
statement.executeUpdate( insertSQL );
@@ -118,13 +118,23 @@
// close up shop
if( null != resultSet )
{
- try { resultSet.close(); }
- catch( final Exception e ) {}
+ try
+ {
+ resultSet.close();
+ }
+ catch( final Exception e )
+ {
+ }
}
if( null != statement )
{
- try { statement.close(); }
- catch( final Exception e ) {}
+ try
+ {
+ statement.close();
+ }
+ catch( final Exception e )
+ {
+ }
}
}
}
1.11 +2 -2 jakarta-avalon-logkit/src/java/org/apache/log/output/io/FileTarget.java
Index: FileTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/FileTarget.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- FileTarget.java 21 Feb 2002 15:07:03 -0000 1.10
+++ FileTarget.java 27 Mar 2002 22:07:57 -0000 1.11
@@ -21,10 +21,10 @@
extends StreamTarget
{
///File we are writing to
- private File m_file;
+ private File m_file;
///Flag indicating whether or not file should be appended to
- private boolean m_append;
+ private boolean m_append;
/**
* Construct file target to write to a file with a formatter.
1.5 +1 -1 jakarta-avalon-logkit/src/java/org/apache/log/output/io/SafeFileTarget.java
Index: SafeFileTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/SafeFileTarget.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SafeFileTarget.java 19 Nov 2001 12:18:34 -0000 1.4
+++ SafeFileTarget.java 27 Mar 2002 22:07:57 -0000 1.5
@@ -10,8 +10,8 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import org.apache.log.format.Formatter;
import org.apache.log.LogEvent;
+import org.apache.log.format.Formatter;
/**
* A target that will open and close a file for each logevent.
1.6 +1 -1 jakarta-avalon-logkit/src/java/org/apache/log/output/io/StreamTarget.java
Index: StreamTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/StreamTarget.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StreamTarget.java 19 Nov 2001 12:18:34 -0000 1.5
+++ StreamTarget.java 27 Mar 2002 22:07:57 -0000 1.6
@@ -21,7 +21,7 @@
extends AbstractOutputTarget
{
///OutputStream we are writing to
- private OutputStream m_outputStream;
+ private OutputStream m_outputStream;
/**
* Constructor that writes to a stream and uses a particular formatter.
1.5 +1 -1 jakarta-avalon-logkit/src/java/org/apache/log/output/io/WriterTarget.java
Index: WriterTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/WriterTarget.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WriterTarget.java 19 Nov 2001 12:18:34 -0000 1.4
+++ WriterTarget.java 27 Mar 2002 22:07:57 -0000 1.5
@@ -24,7 +24,7 @@
* @deprecated Accessing this variable in subclasses is no longer supported
* and will become private in the future.
*/
- protected Writer m_output;
+ protected Writer m_output;
/**
* Construct target with a specific writer and formatter.
1.3 +1 -1 jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/FileStrategy.java
Index: FileStrategy.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/FileStrategy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileStrategy.java 19 Nov 2001 12:18:35 -0000 1.2
+++ FileStrategy.java 27 Mar 2002 22:07:57 -0000 1.3
@@ -17,7 +17,7 @@
* @author <a href="mailto:bh22351@i-one.at">Bernhard Huber</a>
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
*/
-public interface FileStrategy
+public interface FileStrategy
{
/**
* Get the next log file to rotate to.
1.4 +1 -1 jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/OrRotateStrategy.java
Index: OrRotateStrategy.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/OrRotateStrategy.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OrRotateStrategy.java 9 Feb 2002 21:40:24 -0000 1.3
+++ OrRotateStrategy.java 27 Mar 2002 22:07:57 -0000 1.4
@@ -73,7 +73,7 @@
}
}
}
-
+
return false;
}
}
1.4 +9 -9 jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RevolvingFileStrategy.java
Index: RevolvingFileStrategy.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RevolvingFileStrategy.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RevolvingFileStrategy.java 9 Feb 2002 21:40:24 -0000 1.3
+++ RevolvingFileStrategy.java 27 Mar 2002 22:07:57 -0000 1.4
@@ -21,22 +21,22 @@
implements FileStrategy
{
///revolving suffix formatting pattern. ie. "'.'000000"
- private final static String PATTERN = "'.'000000";
+ private final static String PATTERN = "'.'000000";
///a revolving suffix formatter
- private DecimalFormat m_decimalFormat;
+ private DecimalFormat m_decimalFormat;
///current revolving suffix
- private int m_rotation;
+ private int m_rotation;
- ///max revolving value.
- private int m_maxRotations;
+ ///max revolving value.
+ private int m_maxRotations;
///the base file name.
- private File m_baseFile;
+ private File m_baseFile;
- public RevolvingFileStrategy( final File baseFile,
- final int initialRotation,
+ public RevolvingFileStrategy( final File baseFile,
+ final int initialRotation,
final int maxRotations )
{
m_decimalFormat = new DecimalFormat( PATTERN );
@@ -69,7 +69,7 @@
*
* @return File the calculated file name
*/
- public File nextFile()
+ public File nextFile()
{
final StringBuffer sb = new StringBuffer();
final FieldPosition fp = new FieldPosition( NumberFormat.INTEGER_FIELD );
1.4 +3 -3 jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RotateStrategyByDate.java
Index: RotateStrategyByDate.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RotateStrategyByDate.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RotateStrategyByDate.java 21 Feb 2002 13:43:35 -0000 1.3
+++ RotateStrategyByDate.java 27 Mar 2002 22:07:57 -0000 1.4
@@ -8,14 +8,14 @@
package org.apache.log.output.io.rotate;
import java.io.File;
-import java.util.Date;
import java.text.SimpleDateFormat;
+import java.util.Date;
/**
* Rotation stragety based on SimpleDateFormat.
*
* @author <a href="mailto:colus@apache.org">Eung-ju Park</a>
- * @version $Revision: 1.3 $ $Date: 2002/02/21 13:43:35 $
+ * @version $Revision: 1.4 $ $Date: 2002/03/27 22:07:57 $
*/
public class RotateStrategyByDate
implements RotateStrategy
@@ -44,7 +44,7 @@
public boolean isRotationNeeded( final String data, final File file )
{
m_date.setTime( System.currentTimeMillis() );
- if ( m_current.equals( m_format.format( m_date ) ) )
+ if( m_current.equals( m_format.format( m_date ) ) )
{
return false;
}
1.7 +4 -4 jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RotateStrategyByTime.java
Index: RotateStrategyByTime.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RotateStrategyByTime.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RotateStrategyByTime.java 21 Feb 2002 15:11:00 -0000 1.6
+++ RotateStrategyByTime.java 27 Mar 2002 22:07:57 -0000 1.7
@@ -18,13 +18,13 @@
implements RotateStrategy
{
///time interval when rotation is triggered.
- private long m_timeInterval;
+ private long m_timeInterval;
///time when logging started.
- private long m_startingTime;
+ private long m_startingTime;
///rotation count.
- private long m_currentRotation;
+ private long m_currentRotation;
/**
* Rotate logs by time.
@@ -68,7 +68,7 @@
public boolean isRotationNeeded( final String data, final File file )
{
final long newRotation =
- (System.currentTimeMillis() - m_startingTime) / m_timeInterval;
+ ( System.currentTimeMillis() - m_startingTime ) / m_timeInterval;
if( newRotation > m_currentRotation )
{
1.11 +7 -5 jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RotatingFileTarget.java
Index: RotatingFileTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RotatingFileTarget.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- RotatingFileTarget.java 21 Feb 2002 15:07:03 -0000 1.10
+++ RotatingFileTarget.java 27 Mar 2002 22:07:57 -0000 1.11
@@ -8,7 +8,6 @@
package org.apache.log.output.io.rotate;
import java.io.File;
-import java.io.FileWriter;
import java.io.IOException;
import org.apache.log.format.Formatter;
import org.apache.log.output.io.FileTarget;
@@ -24,13 +23,13 @@
extends FileTarget
{
///Flag indicating whether or not file should be appended to
- private boolean m_append;
+ private boolean m_append;
///The rotation strategy to be used.
- private RotateStrategy m_rotateStrategy;
+ private RotateStrategy m_rotateStrategy;
///The file strategy to be used.
- private FileStrategy m_fileStrategy;
+ private FileStrategy m_fileStrategy;
/**
* Construct RotatingFileTarget object.
@@ -88,7 +87,10 @@
// if rotation is needed, close old File, create new File
if( m_rotateStrategy.isRotationNeeded( data, getFile() ) )
{
- try { rotate(); }
+ try
+ {
+ rotate();
+ }
catch( final IOException ioe )
{
getErrorHandler().error( "Error rotating file", ioe, null );
1.4 +5 -5 jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/UniqueFileStrategy.java
Index: UniqueFileStrategy.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/UniqueFileStrategy.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- UniqueFileStrategy.java 21 Feb 2002 11:21:58 -0000 1.3
+++ UniqueFileStrategy.java 27 Mar 2002 22:07:57 -0000 1.4
@@ -8,7 +8,6 @@
package org.apache.log.output.io.rotate;
import java.io.File;
-import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -30,7 +29,7 @@
public class UniqueFileStrategy
implements FileStrategy
{
- private File m_baseFile;
+ private File m_baseFile;
private SimpleDateFormat m_formatter;
@@ -68,11 +67,12 @@
}
else
{
- final String dateString = m_formatter.format(new Date());
- sb.append(dateString);
+ final String dateString = m_formatter.format( new Date() );
+ sb.append( dateString );
}
- if( m_suffix != null ) {
+ if( m_suffix != null )
+ {
sb.append( m_suffix );
}
1.5 +5 -4 jakarta-avalon-logkit/src/java/org/apache/log/output/jms/AbstractJMSTarget.java
Index: AbstractJMSTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/jms/AbstractJMSTarget.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractJMSTarget.java 19 Nov 2001 12:18:35 -0000 1.4
+++ AbstractJMSTarget.java 27 Mar 2002 22:07:58 -0000 1.5
@@ -7,13 +7,12 @@
*/
package org.apache.log.output.jms;
+import javax.jms.Message;
+import javax.jms.Session;
import javax.jms.TopicConnection;
import javax.jms.TopicPublisher;
import javax.jms.TopicSession;
-import javax.jms.Session;
-import javax.jms.Message;
import org.apache.log.LogEvent;
-import org.apache.log.LogTarget;
import org.apache.log.output.AbstractTarget;
/**
@@ -25,7 +24,7 @@
extends AbstractTarget
{
///Appropriate MessageBuilder
- private MessageBuilder m_builder;
+ private MessageBuilder m_builder;
public AbstractJMSTarget( final MessageBuilder builder )
{
@@ -33,6 +32,7 @@
}
protected abstract void send( Message message );
+
protected abstract Session getSession();
/**
@@ -76,5 +76,6 @@
}
protected abstract void openConnection();
+
protected abstract void closeConnection();
}
1.3 +9 -9 jakarta-avalon-logkit/src/java/org/apache/log/output/jms/JMSQueueTarget.java
Index: JMSQueueTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/jms/JMSQueueTarget.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JMSQueueTarget.java 11 Sep 2001 01:07:39 -0000 1.2
+++ JMSQueueTarget.java 27 Mar 2002 22:07:58 -0000 1.3
@@ -27,16 +27,16 @@
private QueueConnectionFactory m_factory;
///Queue we will send messages to
- private Queue m_queue;
+ private Queue m_queue;
///Session associated with queue
- private QueueSession m_session;
+ private QueueSession m_session;
///Sender for queue
- private QueueSender m_sender;
+ private QueueSender m_sender;
///JMS queue Connection
- private QueueConnection m_connection;
+ private QueueConnection m_connection;
public JMSQueueTarget( final MessageBuilder builder,
final QueueConnectionFactory factory,
@@ -50,7 +50,7 @@
protected void send( final Message message )
{
- try
+ try
{
m_sender.send( message );
}
@@ -71,10 +71,10 @@
{
m_connection = m_factory.createQueueConnection();
m_connection.start();
-
- m_session =
- m_connection.createQueueSession( false, Session.AUTO_ACKNOWLEDGE);
-
+
+ m_session =
+ m_connection.createQueueSession( false, Session.AUTO_ACKNOWLEDGE );
+
m_sender = m_session.createSender( m_queue );
}
catch( final Exception e )
1.5 +11 -11 jakarta-avalon-logkit/src/java/org/apache/log/output/jms/JMSTopicTarget.java
Index: JMSTopicTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/jms/JMSTopicTarget.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JMSTopicTarget.java 19 Nov 2001 12:18:35 -0000 1.4
+++ JMSTopicTarget.java 27 Mar 2002 22:07:58 -0000 1.5
@@ -7,13 +7,13 @@
*/
package org.apache.log.output.jms;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;
import javax.jms.TopicPublisher;
import javax.jms.TopicSession;
-import javax.jms.Topic;
-import javax.jms.Session;
-import javax.jms.Message;
/**
* A target that writes to a JMS Topic.
@@ -27,16 +27,16 @@
private TopicConnectionFactory m_factory;
///Topic we will send messages to
- private Topic m_topic;
+ private Topic m_topic;
///Session associated with topic
- private TopicSession m_session;
+ private TopicSession m_session;
///Publisher for topic
- private TopicPublisher m_publisher;
+ private TopicPublisher m_publisher;
///JMS topic Connection
- private TopicConnection m_connection;
+ private TopicConnection m_connection;
public JMSTopicTarget( final MessageBuilder builder,
final TopicConnectionFactory factory,
@@ -50,7 +50,7 @@
protected void send( final Message message )
{
- try
+ try
{
m_publisher.publish( message );
}
@@ -71,10 +71,10 @@
{
m_connection = m_factory.createTopicConnection();
m_connection.start();
-
- m_session =
+
+ m_session =
m_connection.createTopicSession( false, Session.AUTO_ACKNOWLEDGE );
-
+
m_publisher = m_session.createPublisher( m_topic );
//if( m_persistent ) publisher.setDeliveryMode( DeliveryMode.PERSISTENT );
//else publisher.setDeliveryMode( DeliveryMode.NON_PERSISTENT );
1.3 +2 -2 jakarta-avalon-logkit/src/java/org/apache/log/output/jms/MessageBuilder.java
Index: MessageBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/jms/MessageBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MessageBuilder.java 19 Nov 2001 12:18:35 -0000 1.2
+++ MessageBuilder.java 27 Mar 2002 22:07:58 -0000 1.3
@@ -7,9 +7,9 @@
*/
package org.apache.log.output.jms;
+import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
-import javax.jms.JMSException;
import org.apache.log.LogEvent;
/**
@@ -19,6 +19,6 @@
*/
public interface MessageBuilder
{
- Message buildMessage( Session session, LogEvent event )
+ Message buildMessage( Session session, LogEvent event )
throws JMSException;
}
1.3 +4 -4 jakarta-avalon-logkit/src/java/org/apache/log/output/jms/PropertyInfo.java
Index: PropertyInfo.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/jms/PropertyInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PropertyInfo.java 2 Sep 2001 06:42:18 -0000 1.2
+++ PropertyInfo.java 27 Mar 2002 22:07:58 -0000 1.3
@@ -12,16 +12,16 @@
*
* @author <a href="mailto:mirceatoma@home.com">Mircea Toma</a>
*/
-public class PropertyInfo
+public class PropertyInfo
{
///Name of property
- private final String m_name;
+ private final String m_name;
///Type/Source of property
- private final int m_type;
+ private final int m_type;
///Auxilliary parameters (ie constant or sub-format)
- private final String m_aux; //may be null
+ private final String m_aux; //may be null
public PropertyInfo( final String name, final int type, final String aux )
{
1.2 +30 -23 jakarta-avalon-logkit/src/java/org/apache/log/output/jms/PropertyType.java
Index: PropertyType.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/jms/PropertyType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PropertyType.java 1 Sep 2001 12:10:23 -0000 1.1
+++ PropertyType.java 27 Mar 2002 22:07:58 -0000 1.2
@@ -14,38 +14,45 @@
*/
public class PropertyType
{
- public final static int STATIC = 1;
- public final static int CATEGORY = 2;
- public final static int CONTEXT = 3;
- public final static int MESSAGE = 4;
- public final static int TIME = 5;
- public final static int RELATIVE_TIME = 6;
- public final static int THROWABLE = 7;
- public final static int PRIORITY = 8;
+ public final static int STATIC = 1;
+ public final static int CATEGORY = 2;
+ public final static int CONTEXT = 3;
+ public final static int MESSAGE = 4;
+ public final static int TIME = 5;
+ public final static int RELATIVE_TIME = 6;
+ public final static int THROWABLE = 7;
+ public final static int PRIORITY = 8;
/**
* The maximum value used for TYPEs. Subclasses can define their own TYPEs
* starting at <code>MAX_TYPE + 1</code>.
*/
- public final static String STATIC_STR = "static";
- public final static String CATEGORY_STR = "category";
- public final static String CONTEXT_STR = "context";
- public final static String MESSAGE_STR = "message";
- public final static String TIME_STR = "time";
- public final static String RELATIVE_TIME_STR = "rtime";
- public final static String THROWABLE_STR = "throwable";
- public final static String PRIORITY_STR = "priority";
+ public final static String STATIC_STR = "static";
+ public final static String CATEGORY_STR = "category";
+ public final static String CONTEXT_STR = "context";
+ public final static String MESSAGE_STR = "message";
+ public final static String TIME_STR = "time";
+ public final static String RELATIVE_TIME_STR = "rtime";
+ public final static String THROWABLE_STR = "throwable";
+ public final static String PRIORITY_STR = "priority";
public static int getTypeIdFor( final String type )
{
- if( type.equalsIgnoreCase( CATEGORY_STR ) ) return CATEGORY;
- else if( type.equalsIgnoreCase( STATIC_STR ) ) return STATIC;
- else if( type.equalsIgnoreCase( CONTEXT_STR ) ) return CONTEXT;
- else if( type.equalsIgnoreCase( MESSAGE_STR ) ) return MESSAGE;
- else if( type.equalsIgnoreCase( PRIORITY_STR ) ) return PRIORITY;
- else if( type.equalsIgnoreCase( TIME_STR ) ) return TIME;
- else if( type.equalsIgnoreCase( RELATIVE_TIME_STR ) ) return RELATIVE_TIME;
+ if( type.equalsIgnoreCase( CATEGORY_STR ) )
+ return CATEGORY;
+ else if( type.equalsIgnoreCase( STATIC_STR ) )
+ return STATIC;
+ else if( type.equalsIgnoreCase( CONTEXT_STR ) )
+ return CONTEXT;
+ else if( type.equalsIgnoreCase( MESSAGE_STR ) )
+ return MESSAGE;
+ else if( type.equalsIgnoreCase( PRIORITY_STR ) )
+ return PRIORITY;
+ else if( type.equalsIgnoreCase( TIME_STR ) )
+ return TIME;
+ else if( type.equalsIgnoreCase( RELATIVE_TIME_STR ) )
+ return RELATIVE_TIME;
else if( type.equalsIgnoreCase( THROWABLE_STR ) )
{
return THROWABLE;
1.7 +42 -43 jakarta-avalon-logkit/src/java/org/apache/log/output/jms/TextMessageBuilder.java
Index: TextMessageBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/jms/TextMessageBuilder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TextMessageBuilder.java 19 Nov 2001 12:18:35 -0000 1.6
+++ TextMessageBuilder.java 27 Mar 2002 22:07:58 -0000 1.7
@@ -14,7 +14,6 @@
import javax.jms.Session;
import javax.jms.TextMessage;
import org.apache.log.ContextMap;
-import org.apache.log.Hierarchy;
import org.apache.log.LogEvent;
import org.apache.log.format.Formatter;
@@ -26,22 +25,22 @@
public class TextMessageBuilder
implements MessageBuilder
{
- private final PropertyInfo[] m_properties;
+ private final PropertyInfo[] m_properties;
private final Formatter m_formatter;
-
+
public TextMessageBuilder( final Formatter formatter )
{
- m_properties = new PropertyInfo[0];
+ m_properties = new PropertyInfo[ 0 ];
m_formatter = formatter;
}
- public TextMessageBuilder( final PropertyInfo[] properties,
+ public TextMessageBuilder( final PropertyInfo[] properties,
final Formatter formatter )
{
m_properties = properties;
m_formatter = formatter;
}
-
+
public Message buildMessage( final Session session, final LogEvent event )
throws JMSException
{
@@ -69,52 +68,52 @@
switch( info.getType() )
{
- case PropertyType.MESSAGE:
- message.setStringProperty( name, event.getMessage() );
- break;
-
- case PropertyType.RELATIVE_TIME:
- message.setLongProperty( name, event.getRelativeTime() );
- break;
-
- case PropertyType.TIME:
- message.setLongProperty( name, event.getTime() );
- break;
-
- case PropertyType.CATEGORY:
- message.setStringProperty( name, event.getCategory() );
- break;
-
- case PropertyType.PRIORITY:
- message.setStringProperty( name, event.getPriority().getName() );
- break;
-
- case PropertyType.CONTEXT:
- message.setStringProperty( name, getContextMap( event.getContextMap(),
- info.getAux() ) );
- break;
-
- case PropertyType.STATIC:
- message.setStringProperty( name, info.getAux() );
- break;
-
- case PropertyType.THROWABLE:
- message.setStringProperty( name, getStackTrace( event.getThrowable() ) );
- break;
+ case PropertyType.MESSAGE:
+ message.setStringProperty( name, event.getMessage() );
+ break;
+
+ case PropertyType.RELATIVE_TIME:
+ message.setLongProperty( name, event.getRelativeTime() );
+ break;
+
+ case PropertyType.TIME:
+ message.setLongProperty( name, event.getTime() );
+ break;
+
+ case PropertyType.CATEGORY:
+ message.setStringProperty( name, event.getCategory() );
+ break;
+
+ case PropertyType.PRIORITY:
+ message.setStringProperty( name, event.getPriority().getName() );
+ break;
+
+ case PropertyType.CONTEXT:
+ message.setStringProperty( name, getContextMap( event.getContextMap(),
+ info.getAux() ) );
+ break;
+
+ case PropertyType.STATIC:
+ message.setStringProperty( name, info.getAux() );
+ break;
+
+ case PropertyType.THROWABLE:
+ message.setStringProperty( name, getStackTrace( event.getThrowable() ) );
+ break;
- default:
- throw new IllegalStateException( "Unknown PropertyType: " + info.getType() );
+ default:
+ throw new IllegalStateException( "Unknown PropertyType: " + info.getType() );
}
}
private String getText( final LogEvent event )
{
- if ( null == m_formatter )
+ if( null == m_formatter )
{
return event.getMessage();
}
- else
+ else
{
return m_formatter.format( event );
}
@@ -122,7 +121,7 @@
private String getStackTrace( final Throwable throwable )
{
- if ( null == throwable ) return "";
+ if( null == throwable ) return "";
final StringWriter stringWriter = new StringWriter();
final PrintWriter printWriter = new PrintWriter( stringWriter );
1.3 +3 -8 jakarta-avalon-logkit/src/java/org/apache/log/output/net/SocketOutputTarget.java
Index: SocketOutputTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/net/SocketOutputTarget.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SocketOutputTarget.java 9 Feb 2002 21:40:24 -0000 1.2
+++ SocketOutputTarget.java 27 Mar 2002 22:07:58 -0000 1.3
@@ -1,14 +1,9 @@
package org.apache.log.output.net;
import java.io.IOException;
-import java.io.OutputStream;
import java.io.ObjectOutputStream;
-
-import java.net.Socket;
-import java.net.SocketException;
import java.net.InetAddress;
-import java.net.UnknownHostException;
-
+import java.net.Socket;
import org.apache.log.LogEvent;
import org.apache.log.output.AbstractOutputTarget;
@@ -37,7 +32,7 @@
*/
public SocketOutputTarget( final InetAddress address,
final int port )
- throws IOException
+ throws IOException
{
m_socket = new Socket( address, port );
m_outputStream = new ObjectOutputStream( m_socket.getOutputStream() );
@@ -53,7 +48,7 @@
*/
public SocketOutputTarget( final String host,
final int port )
- throws IOException
+ throws IOException
{
m_socket = new Socket( host, port );
m_outputStream = new ObjectOutputStream( m_socket.getOutputStream() );
1.3 +3 -3 jakarta-avalon-logkit/src/java/org/apache/log/util/DefaultErrorHandler.java
Index: DefaultErrorHandler.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/util/DefaultErrorHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultErrorHandler.java 19 Nov 2001 12:18:35 -0000 1.2
+++ DefaultErrorHandler.java 27 Mar 2002 22:07:58 -0000 1.3
@@ -11,7 +11,7 @@
import org.apache.log.LogEvent;
/**
- * Handle unrecoverable errors that occur during logging by
+ * Handle unrecoverable errors that occur during logging by
* writing to standard error.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
@@ -26,8 +26,8 @@
* @param throwable the exception associated with error (may be null)
* @param event the LogEvent that caused error, if any (may be null)
*/
- public void error( final String message,
- final Throwable throwable,
+ public void error( final String message,
+ final Throwable throwable,
final LogEvent event )
{
System.err.println( "Logging Error: " + message );
1.3 +13 -13 jakarta-avalon-logkit/src/java/org/apache/log/util/LoggerOutputStream.java
Index: LoggerOutputStream.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/util/LoggerOutputStream.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LoggerOutputStream.java 19 Nov 2001 12:18:35 -0000 1.2
+++ LoggerOutputStream.java 27 Mar 2002 22:07:58 -0000 1.3
@@ -7,19 +7,19 @@
*/
package org.apache.log.util;
+import java.io.EOFException;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.EOFException;
-import org.apache.log.Priority;
import org.apache.log.Logger;
+import org.apache.log.Priority;
/**
* Redirect an output stream to a logger.
- * This class is useful to redirect standard output or
+ * This class is useful to redirect standard output or
* standard error to a Logger. An example use is
*
* <pre>
- * final LoggerOutputStream outputStream =
+ * final LoggerOutputStream outputStream =
* new LoggerOutputStream( logger, Priority.DEBUG );
* final PrintStream output = new PrintStream( outputStream, true );
*
@@ -30,18 +30,18 @@
*/
public class LoggerOutputStream
extends OutputStream
-{
+{
///Logger that we log to
- private final Logger m_logger;
+ private final Logger m_logger;
///Log level we log to
- private final Priority m_priority;
+ private final Priority m_priority;
///The buffered output so far
- private final StringBuffer m_output = new StringBuffer();
+ private final StringBuffer m_output = new StringBuffer();
///Flag set to true once stream closed
- private boolean m_closed;
+ private boolean m_closed;
/**
* Construct OutputStreamLogger to write to a particular logger at a particular priority.
@@ -49,7 +49,7 @@
* @param logger the logger to write to
* @param priority the priority at which to log
*/
- public LoggerOutputStream( final Logger logger,
+ public LoggerOutputStream( final Logger logger,
final Priority priority )
{
m_logger = logger;
@@ -74,11 +74,11 @@
* @param data the byte of data
* @exception IOException if an error occurs
*/
- public void write( final int data )
+ public void write( final int data )
throws IOException
{
checkValid();
-
+
//Should we properly convert char using locales etc??
m_output.append( (char)data );
@@ -110,7 +110,7 @@
private void checkValid()
throws IOException
{
- if( true == m_closed )
+ if( true == m_closed )
{
throw new EOFException( "OutputStreamLogger closed" );
}
1.7 +5 -5 jakarta-avalon-logkit/src/java/org/apache/log/util/OutputStreamLogger.java
Index: OutputStreamLogger.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/util/OutputStreamLogger.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- OutputStreamLogger.java 19 Nov 2001 12:18:35 -0000 1.6
+++ OutputStreamLogger.java 27 Mar 2002 22:07:58 -0000 1.7
@@ -7,16 +7,16 @@
*/
package org.apache.log.util;
-import org.apache.log.Priority;
import org.apache.log.Logger;
+import org.apache.log.Priority;
/**
* Redirect an output stream to a logger.
- * This class is useful to redirect standard output or
+ * This class is useful to redirect standard output or
* standard error to a Logger. An example use is
*
* <pre>
- * final OutputStreamLogger outputStream =
+ * final OutputStreamLogger outputStream =
* new OutputStreamLogger( logger, Priority.DEBUG );
* final PrintStream output = new PrintStream( outputStream, true );
*
@@ -28,7 +28,7 @@
*/
public class OutputStreamLogger
extends LoggerOutputStream
-{
+{
/**
* Construct OutputStreamLogger to write to a particular logger at a particular priority.
*
@@ -36,7 +36,7 @@
* @param priority the priority at which to log
* @deprecated Use LoggerOutputStream as this class was misnamed.
*/
- public OutputStreamLogger( final Logger logger,
+ public OutputStreamLogger( final Logger logger,
final Priority priority )
{
super( logger, priority );
1.5 +94 -92 jakarta-avalon-logkit/src/java/org/apache/log/util/StackIntrospector.java
Index: StackIntrospector.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/util/StackIntrospector.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StackIntrospector.java 11 Nov 2001 02:18:32 -0000 1.4
+++ StackIntrospector.java 27 Mar 2002 22:07:58 -0000 1.5
@@ -15,7 +15,7 @@
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
* @author <a href="mailto:stuart.roebuck@adolos.com">Stuart Roebuck</a>
- * @version CVS $Revision: 1.4 $ $Date: 2001/11/11 02:18:32 $
+ * @version CVS $Revision: 1.5 $ $Date: 2002/03/27 22:07:58 $
*/
public final class StackIntrospector
{
@@ -41,7 +41,7 @@
}
///Method to cache CallStack hack as needed
- private static CallStack c_callStack;
+ private static CallStack c_callStack;
/**
* Private constructor to block instantiation.
@@ -55,7 +55,7 @@
* Create Hack SecurityManager to get CallStack.
*
* @return the CallStack object
- * @exception SecurityException if an existing SecurityManager disallows construction
+ * @exception SecurityException if an existing SecurityManager disallows construction
* of another SecurityManager
*/
private synchronized static CallStack getCallStack()
@@ -76,7 +76,7 @@
*
* @param clazz the Class to search for on stack to find caller of
* @return the Class of object that called parrameter class
- * @exception SecurityException if an existing SecurityManager disallows construction
+ * @exception SecurityException if an existing SecurityManager disallows construction
* of another SecurityManager and thus blocks method results
*/
public final static Class getCallerClass( final Class clazz )
@@ -105,7 +105,7 @@
*
* @return The method path name in the form "the.package.path.Method"
*/
- public final static String getCallerMethod( final Class clazz )
+ public final static String getCallerMethod( final Class clazz )
{
final String className = clazz.getName();
@@ -115,7 +115,7 @@
throwable.printStackTrace( new PrintWriter( sw, true ) );
final StringBuffer buffer = sw.getBuffer();
- //Cache vars used in loop
+ //Cache vars used in loop
final StringBuffer line = new StringBuffer();
final int length = buffer.length();
@@ -128,50 +128,51 @@
{
final char ch = buffer.charAt( i );
- switch( state )
+ switch( state )
{
- case 0:
- //Strip the first line from input
- if( '\n' == ch ) state = 1;
- break;
-
- case 1:
- //strip 't' from 'at'
- if( 't' == ch ) state = 2;
- break;
-
- case 2:
- //Strip space after 'at'
- line.setLength( 0 );
- state = 3;
- break;
-
- case 3:
- //accumulate all characters to end of line
- if( '\n' != ch ) line.append( ch );
- else
- {
- //At this stage you have the line that looks like
- //com.biz.SomeClass.someMethod(SomeClass.java:22)
- final String method = line.toString();
-
- ///Determine if line is a match for class
- final boolean match = method.startsWith( className );
- if( !found && match )
- {
- //If this is the first time we cound class then
- //set found to true and look for caller into class
- found = true;
- }
- else if( found && !match )
+ case 0:
+ //Strip the first line from input
+ if( '\n' == ch ) state = 1;
+ break;
+
+ case 1:
+ //strip 't' from 'at'
+ if( 't' == ch ) state = 2;
+ break;
+
+ case 2:
+ //Strip space after 'at'
+ line.setLength( 0 );
+ state = 3;
+ break;
+
+ case 3:
+ //accumulate all characters to end of line
+ if( '\n' != ch )
+ line.append( ch );
+ else
{
- //We have now located caller of Clazz
- return method;
+ //At this stage you have the line that looks like
+ //com.biz.SomeClass.someMethod(SomeClass.java:22)
+ final String method = line.toString();
+
+ ///Determine if line is a match for class
+ final boolean match = method.startsWith( className );
+ if( !found && match )
+ {
+ //If this is the first time we cound class then
+ //set found to true and look for caller into class
+ found = true;
+ }
+ else if( found && !match )
+ {
+ //We have now located caller of Clazz
+ return method;
+ }
+
+ //start parsing from start of line again
+ state = 1;
}
-
- //start parsing from start of line again
- state = 1;
- }
}
}
@@ -191,7 +192,7 @@
*
* @return The method path name in the form "the.package.path.Method"
*/
- public final static String getRecentStack( final Class clazz, int entries )
+ public final static String getRecentStack( final Class clazz, int entries )
{
final String className = clazz.getName();
@@ -201,7 +202,7 @@
throwable.printStackTrace( new PrintWriter( sw, true ) );
final StringBuffer buffer = sw.getBuffer();
- //Cache vars used in loop
+ //Cache vars used in loop
final StringBuffer line = new StringBuffer();
final StringBuffer stack = new StringBuffer();
final int length = buffer.length();
@@ -217,51 +218,52 @@
switch( state )
{
- case 0:
- //Strip the first line from input
- if( '\n' == ch ) state = 1;
- break;
-
- case 1:
- //strip 't' from 'at'
- if( 't' == ch ) state = 2;
- break;
-
- case 2:
- //Strip space after 'at'
- line.setLength( 0 );
- state = 3;
- break;
-
- case 3:
- //accumulate all characters to end of line
- if( '\n' != ch ) line.append( ch );
- else
- {
- //At this stage you have the line that looks like
- //com.biz.SomeClass.someMethod(SomeClass.java:22)
- final String method = line.toString();
-
- ///Determine if line is a match for class
- final boolean match = method.startsWith( className );
- if( !found && match )
+ case 0:
+ //Strip the first line from input
+ if( '\n' == ch ) state = 1;
+ break;
+
+ case 1:
+ //strip 't' from 'at'
+ if( 't' == ch ) state = 2;
+ break;
+
+ case 2:
+ //Strip space after 'at'
+ line.setLength( 0 );
+ state = 3;
+ break;
+
+ case 3:
+ //accumulate all characters to end of line
+ if( '\n' != ch )
+ line.append( ch );
+ else
{
- //If this is the first time we cound class then
- //set found to true and look for caller into class
- found = true;
- }
- else if( found && !match )
- {
- //We are looking at the callers of Clazz
- stack.append(method);
- entries--;
- if (entries == 0) return stack.toString();
- stack.append("\n");
- }
+ //At this stage you have the line that looks like
+ //com.biz.SomeClass.someMethod(SomeClass.java:22)
+ final String method = line.toString();
+
+ ///Determine if line is a match for class
+ final boolean match = method.startsWith( className );
+ if( !found && match )
+ {
+ //If this is the first time we cound class then
+ //set found to true and look for caller into class
+ found = true;
+ }
+ else if( found && !match )
+ {
+ //We are looking at the callers of Clazz
+ stack.append( method );
+ entries--;
+ if( entries == 0 ) return stack.toString();
+ stack.append( "\n" );
+ }
- //start parsing from start of line again
- state = 1;
- }
+ //start parsing from start of line again
+ state = 1;
+ }
}
}
1.5 +60 -60 jakarta-avalon-logkit/src/test/org/apache/log/format/test/FormatterTestCase.java
Index: FormatterTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/test/org/apache/log/format/test/FormatterTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FormatterTestCase.java 19 Nov 2001 12:18:35 -0000 1.4
+++ FormatterTestCase.java 27 Mar 2002 22:07:58 -0000 1.5
@@ -7,16 +7,16 @@
*/
package org.apache.log.format.test;
-import org.apache.log.ContextStack;
+import junit.framework.TestCase;
import org.apache.log.ContextMap;
-import org.apache.log.format.Formatter;
+import org.apache.log.ContextStack;
import org.apache.log.LogEvent;
import org.apache.log.Priority;
+import org.apache.log.format.Formatter;
+import org.apache.log.format.PatternFormatter;
import org.apache.log.format.RawFormatter;
-import org.apache.log.format.XMLFormatter;
import org.apache.log.format.SyslogFormatter;
-import org.apache.log.format.PatternFormatter;
-import junit.framework.TestCase;
+import org.apache.log.format.XMLFormatter;
/**
* Test suite for the formatters.
@@ -27,7 +27,7 @@
public final class FormatterTestCase
extends TestCase
{
- private static String EOL = System.getProperty( "line.separator", "\n" );
+ private static String EOL = System.getProperty( "line.separator", "\n" );
private static String M1 = "Message1";
private static String M2 = "Message2Message2";
@@ -53,44 +53,44 @@
private static LogEvent E2 = createEvent( C2, M2, null, T2, P2, null, CM2 );
private static LogEvent E3 = createEvent( C3, M3, null, T3, P3, null, null );
- private static String E1_XML = "<log-entry>" + EOL +
- " <time>" + T1 + "</time>" + EOL +
- " <priority>" + P1.getName() + "</priority>" + EOL +
+ private static String E1_XML = "<log-entry>" + EOL +
+ " <time>" + T1 + "</time>" + EOL +
+ " <priority>" + P1.getName() + "</priority>" + EOL +
" <category>" + C1 + "</category>" + EOL +
- " <message><![CDATA[" + M1 + "]]></message>" + EOL +
+ " <message><![CDATA[" + M1 + "]]></message>" + EOL +
"</log-entry>" + EOL;
- private static String E2_XML = "<log-entry>" + EOL +
- " <time>" + T2 + "</time>" + EOL +
- " <priority>" + P2.getName() + "</priority>" + EOL +
+ private static String E2_XML = "<log-entry>" + EOL +
+ " <time>" + T2 + "</time>" + EOL +
+ " <priority>" + P2.getName() + "</priority>" + EOL +
" <category>" + C2 + "</category>" + EOL +
- " <message><![CDATA[" + M2 + "]]></message>" + EOL +
+ " <message><![CDATA[" + M2 + "]]></message>" + EOL +
"</log-entry>" + EOL;
- private static String E3_XML = "<log-entry>" + EOL +
- " <time>" + T3 + "</time>" + EOL +
- " <priority>" + P3.getName() + "</priority>" + EOL +
+ private static String E3_XML = "<log-entry>" + EOL +
+ " <time>" + T3 + "</time>" + EOL +
+ " <priority>" + P3.getName() + "</priority>" + EOL +
" <category>" + C3 + "</category>" + EOL +
- " <message><![CDATA[" + M3 + "]]></message>" + EOL +
+ " <message><![CDATA[" + M3 + "]]></message>" + EOL +
"</log-entry>" + EOL;
- private static int FACILITY_ID = 9<<3; //cron
+ private static int FACILITY_ID = 9 << 3; //cron
private static String FACILITY_NAME = "cron"; //cron
- private static String E1_SYSLOG = "<" + (2|FACILITY_ID) + "> " + M1;
- private static String E2_SYSLOG = "<" + (3|FACILITY_ID) + "> " + M2;
- private static String E3_SYSLOG = "<" + (4|FACILITY_ID) + "> " + M3;
-
- private static String E1_SYSLOG_WB = "<" + (2|FACILITY_ID) + "> " + FACILITY_NAME + ": " + M1;
- private static String E2_SYSLOG_WB = "<" + (3|FACILITY_ID) + "> " + FACILITY_NAME + ": " + M2;
- private static String E3_SYSLOG_WB = "<" + (4|FACILITY_ID) + "> " + FACILITY_NAME + ": " + M3;
+ private static String E1_SYSLOG = "<" + ( 2 | FACILITY_ID ) + "> " + M1;
+ private static String E2_SYSLOG = "<" + ( 3 | FACILITY_ID ) + "> " + M2;
+ private static String E3_SYSLOG = "<" + ( 4 | FACILITY_ID ) + "> " + M3;
+
+ private static String E1_SYSLOG_WB = "<" + ( 2 | FACILITY_ID ) + "> " + FACILITY_NAME + ": " + M1;
+ private static String E2_SYSLOG_WB = "<" + ( 3 | FACILITY_ID ) + "> " + FACILITY_NAME + ": " + M2;
+ private static String E3_SYSLOG_WB = "<" + ( 4 | FACILITY_ID ) + "> " + FACILITY_NAME + ": " + M3;
private static String PATTERN1 = "[%8.8{category}]: %{message}" + EOL;
private static String E1_PATTERN1 = "[Category]: " + M1 + EOL;
private static String E2_PATTERN1 = "[Category]: " + M2 + EOL;
private static String E3_PATTERN1 = "[Category]: " + M3 + EOL;
- private static String PATTERN2 = "[%10.{category}]: %{message}"+ EOL;
+ private static String PATTERN2 = "[%10.{category}]: %{message}" + EOL;
private static String E1_PATTERN2 = "[" + C1 + " ]: " + M1 + EOL;
private static String E2_PATTERN2 = "[" + C2 + "]: " + M2 + EOL;
private static String E3_PATTERN2 = "[" + C3 + "]: " + M3 + EOL;
@@ -129,9 +129,9 @@
private static String PATTERN9 = "[%{method}]: %{message}" + EOL;
private static String E1_PATTERN9 = "[com.biz.MyObject.myMethod(MyObject:53)]: " + M1 + EOL;
- private static String E2_PATTERN9_START = "[" + CLASS_PREFIX +"testPattern9Formatter(";
+ private static String E2_PATTERN9_START = "[" + CLASS_PREFIX + "testPattern9Formatter(";
private static String E2_PATTERN9_END = ")]: " + M2 + EOL;
- private static String E3_PATTERN9_START = "[" + CLASS_PREFIX +"testPattern9Formatter(";
+ private static String E3_PATTERN9_START = "[" + CLASS_PREFIX + "testPattern9Formatter(";
private static String E3_PATTERN9_END = ")]: " + M3 + EOL;
private static String PATTERN10 = "[%{context:method}]: %{message}" + EOL;
@@ -243,11 +243,11 @@
public void testPattern1Formatter()
{
final Formatter formatter = new PatternFormatter( PATTERN1 );
-
+
final String result1 = formatter.format( E1 );
final String result2 = formatter.format( E2 );
final String result3 = formatter.format( E3 );
-
+
assertEquals( "Pattern1 formatting of E1", E1_PATTERN1, result1 );
assertEquals( "Pattern1 formatting of E2", E2_PATTERN1, result2 );
assertEquals( "Pattern1 formatting of E3", E3_PATTERN1, result3 );
@@ -256,7 +256,7 @@
public void testPattern2Formatter()
{
final Formatter formatter = new PatternFormatter( PATTERN2 );
-
+
final String result1 = formatter.format( E1 );
final String result2 = formatter.format( E2 );
final String result3 = formatter.format( E3 );
@@ -269,11 +269,11 @@
public void testPattern3Formatter()
{
final Formatter formatter = new PatternFormatter( PATTERN3 );
-
+
final String result1 = formatter.format( E1 );
final String result2 = formatter.format( E2 );
final String result3 = formatter.format( E3 );
-
+
assertEquals( "Pattern3 formatting of E1", E1_PATTERN3, result1 );
assertEquals( "Pattern3 formatting of E2", E2_PATTERN3, result2 );
assertEquals( "Pattern3 formatting of E3", E3_PATTERN3, result3 );
@@ -282,7 +282,7 @@
public void testPattern4Formatter()
{
final Formatter formatter = new PatternFormatter( PATTERN4 );
-
+
final String result1 = formatter.format( E1 );
final String result2 = formatter.format( E2 );
final String result3 = formatter.format( E3 );
@@ -295,7 +295,7 @@
public void testPattern5Formatter()
{
final Formatter formatter = new PatternFormatter( PATTERN5 );
-
+
final String result1 = formatter.format( E1 );
final String result2 = formatter.format( E2 );
final String result3 = formatter.format( E3 );
@@ -308,7 +308,7 @@
public void testPattern6Formatter()
{
final Formatter formatter = new PatternFormatter( PATTERN6 );
-
+
final String result1 = formatter.format( E1 );
final String result2 = formatter.format( E2 );
final String result3 = formatter.format( E3 );
@@ -321,7 +321,7 @@
public void testPattern7Formatter()
{
final Formatter formatter = new PatternFormatter( PATTERN7 );
-
+
final String result1 = formatter.format( E1 );
final String result2 = formatter.format( E2 );
final String result3 = formatter.format( E3 );
@@ -334,7 +334,7 @@
public void testPattern8Formatter()
{
final Formatter formatter = new PatternFormatter( PATTERN8 );
-
+
final String result1 = formatter.format( E1 );
final String result2 = formatter.format( E2 );
final String result3 = formatter.format( E3 );
@@ -343,30 +343,30 @@
assertEquals( "Pattern8 formatting of E2", E2_PATTERN8, result2 );
assertEquals( "Pattern8 formatting of E3", E3_PATTERN8, result3 );
}
-/*
- public void testPattern9Formatter()
- {
- final Formatter formatter = new PatternFormatter( PATTERN9 );
-
- final String result1 = formatter.format( E1 );
- final String result2 = formatter.format( E2 );
- final String result3 = formatter.format( E3 );
-
- System.out.println( "results1: " + result1 );
- System.out.println( "results2: " + result2 );
- System.out.println( "results3: " + result3 );
+ /*
+ public void testPattern9Formatter()
+ {
+ final Formatter formatter = new PatternFormatter( PATTERN9 );
- assertEquals( "Pattern9 formatting of E1", E1_PATTERN9, result1 );
- assertTrue( "Pattern9 formatting of E2", result2.startsWith( E2_PATTERN9_START ) );
- assertTrue( "Pattern9 end formatting of E2", result2.endsWith( E2_PATTERN9_END ) );
- assertTrue( "Pattern9 formatting of E3", result3.startsWith( E3_PATTERN9_START ) );
- assertTrue( "Pattern9 end formatting of E3", result3.endsWith( E3_PATTERN9_END ) );
- }
-*/
+ final String result1 = formatter.format( E1 );
+ final String result2 = formatter.format( E2 );
+ final String result3 = formatter.format( E3 );
+
+ System.out.println( "results1: " + result1 );
+ System.out.println( "results2: " + result2 );
+ System.out.println( "results3: " + result3 );
+
+ assertEquals( "Pattern9 formatting of E1", E1_PATTERN9, result1 );
+ assertTrue( "Pattern9 formatting of E2", result2.startsWith( E2_PATTERN9_START ) );
+ assertTrue( "Pattern9 end formatting of E2", result2.endsWith( E2_PATTERN9_END ) );
+ assertTrue( "Pattern9 formatting of E3", result3.startsWith( E3_PATTERN9_START ) );
+ assertTrue( "Pattern9 end formatting of E3", result3.endsWith( E3_PATTERN9_END ) );
+ }
+ */
public void testPattern10Formatter()
{
final Formatter formatter = new PatternFormatter( PATTERN10 );
-
+
final String result1 = formatter.format( E1 );
final String result2 = formatter.format( E2 );
final String result3 = formatter.format( E3 );
@@ -379,7 +379,7 @@
public void testPattern11Formatter()
{
final Formatter formatter = new PatternFormatter( PATTERN11 );
-
+
final String result1 = formatter.format( E1 );
final String result2 = formatter.format( E2 );
final String result3 = formatter.format( E3 );
1.3 +25 -36 jakarta-avalon-logkit/src/test/org/apache/log/output/test/DBTargetTestCase.java
Index: DBTargetTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/test/org/apache/log/output/test/DBTargetTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DBTargetTestCase.java 19 Nov 2001 12:18:35 -0000 1.2
+++ DBTargetTestCase.java 27 Mar 2002 22:07:58 -0000 1.3
@@ -7,26 +7,15 @@
*/
package org.apache.log.output.test;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
+import junit.framework.TestCase;
import org.apache.log.Hierarchy;
import org.apache.log.LogTarget;
import org.apache.log.Logger;
-import org.apache.log.Priority;
-import org.apache.log.format.ExtendedPatternFormatter;
-import org.apache.log.format.PatternFormatter;
-import org.apache.log.format.RawFormatter;
-import org.apache.log.output.AbstractOutputTarget;
-import org.apache.log.output.MemoryTarget;
-import org.apache.log.output.io.FileTarget;
-import org.apache.log.output.io.SafeFileTarget;
-import org.apache.log.output.io.StreamTarget;
-import org.apache.log.output.io.WriterTarget;
-import org.apache.log.output.db.*;
-import junit.framework.TestCase;
+import org.apache.log.output.db.ColumnInfo;
+import org.apache.log.output.db.ColumnType;
+import org.apache.log.output.db.DefaultDataSource;
+import org.apache.log.output.db.DefaultJDBCTarget;
+import org.apache.log.output.db.NormalizedJDBCTarget;
/**
* Test suite for the DB output target.
@@ -47,19 +36,19 @@
public void testBasicTarget()
throws Exception
{
- final DefaultDataSource dataSource =
+ final DefaultDataSource dataSource =
new DefaultDataSource( "jdbc:postgresql:avalon-logkit", "avalon", "" );
final ColumnInfo[] columns =
- {
- new ColumnInfo( "TIME", ColumnType.TIME, null ),
- new ColumnInfo( "PRIORITY", ColumnType.PRIORITY, null ),
- new ColumnInfo( "CATEGORY", ColumnType.CATEGORY, null ),
- new ColumnInfo( "HOSTNAME", ColumnType.STATIC, "helm.realityforge.net" ),
- new ColumnInfo( "MESSAGE", ColumnType.MESSAGE, null )
- };
+ {
+ new ColumnInfo( "TIME", ColumnType.TIME, null ),
+ new ColumnInfo( "PRIORITY", ColumnType.PRIORITY, null ),
+ new ColumnInfo( "CATEGORY", ColumnType.CATEGORY, null ),
+ new ColumnInfo( "HOSTNAME", ColumnType.STATIC, "helm.realityforge.net" ),
+ new ColumnInfo( "MESSAGE", ColumnType.MESSAGE, null )
+ };
- final DefaultJDBCTarget target =
+ final DefaultJDBCTarget target =
new DefaultJDBCTarget( dataSource, "log_entrys", columns );
final Logger logger = getNewLogger( target );
@@ -69,19 +58,19 @@
public void testNumericConstants()
throws Exception
{
- final DefaultDataSource dataSource =
+ final DefaultDataSource dataSource =
new DefaultDataSource( "jdbc:postgresql:avalon-logkit", "avalon", "" );
final ColumnInfo[] columns =
- {
- new ColumnInfo( "TIME", ColumnType.TIME, null ),
- new ColumnInfo( "PRIORITY", ColumnType.PRIORITY, null ),
- new ColumnInfo( "CATEGORY", ColumnType.CATEGORY, null ),
- new ColumnInfo( "HOSTNAME", ColumnType.STATIC, "helm.realityforge.net" ),
- new ColumnInfo( "MESSAGE", ColumnType.MESSAGE, null )
- };
+ {
+ new ColumnInfo( "TIME", ColumnType.TIME, null ),
+ new ColumnInfo( "PRIORITY", ColumnType.PRIORITY, null ),
+ new ColumnInfo( "CATEGORY", ColumnType.CATEGORY, null ),
+ new ColumnInfo( "HOSTNAME", ColumnType.STATIC, "helm.realityforge.net" ),
+ new ColumnInfo( "MESSAGE", ColumnType.MESSAGE, null )
+ };
- final NormalizedJDBCTarget target =
+ final NormalizedJDBCTarget target =
new NormalizedJDBCTarget( dataSource, "log_entrys2", columns );
final Logger logger = getNewLogger( target );
@@ -95,7 +84,7 @@
{
final Hierarchy hierarchy = new Hierarchy();
final Logger logger = hierarchy.getLoggerFor( "myCategory" );
- logger.setLogTargets( new LogTarget[] { target } );
+ logger.setLogTargets( new LogTarget[]{target} );
return logger;
}
}
1.7 +9 -10 jakarta-avalon-logkit/src/test/org/apache/log/output/test/DatagramTest.java
Index: DatagramTest.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/test/org/apache/log/output/test/DatagramTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DatagramTest.java 19 Nov 2001 12:18:35 -0000 1.6
+++ DatagramTest.java 27 Mar 2002 22:07:58 -0000 1.7
@@ -1,17 +1,16 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE file.
- */
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE file.
+ */
package org.apache.log.output.test;
import java.net.InetAddress;
-import org.apache.log.Hierarchy;
+import org.apache.log.Hierarchy;
import org.apache.log.LogTarget;
import org.apache.log.Logger;
-import org.apache.log.Priority;
import org.apache.log.format.Formatter;
import org.apache.log.format.RawFormatter;
import org.apache.log.format.SyslogFormatter;
@@ -49,7 +48,7 @@
new DatagramOutputTarget( address, 514, formatter );
final Logger logger = Hierarchy.getDefaultHierarchy().getLoggerFor( "foo" );
- logger.setLogTargets( new LogTarget[] { target } );
+ logger.setLogTargets( new LogTarget[]{target} );
logger.warn( message, new Exception() );
}
1.3 +6 -8 jakarta-avalon-logkit/src/test/org/apache/log/output/test/OutputTargetTestCase.java
Index: OutputTargetTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/test/org/apache/log/output/test/OutputTargetTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OutputTargetTestCase.java 19 Nov 2001 12:18:35 -0000 1.2
+++ OutputTargetTestCase.java 27 Mar 2002 22:07:58 -0000 1.3
@@ -12,12 +12,11 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import junit.framework.TestCase;
import org.apache.log.Hierarchy;
import org.apache.log.LogTarget;
import org.apache.log.Logger;
import org.apache.log.Priority;
-import org.apache.log.format.ExtendedPatternFormatter;
-import org.apache.log.format.PatternFormatter;
import org.apache.log.format.RawFormatter;
import org.apache.log.output.AbstractOutputTarget;
import org.apache.log.output.MemoryTarget;
@@ -25,7 +24,6 @@
import org.apache.log.output.io.SafeFileTarget;
import org.apache.log.output.io.StreamTarget;
import org.apache.log.output.io.WriterTarget;
-import junit.framework.TestCase;
/**
* Test suite for the formatters.
@@ -51,14 +49,14 @@
private static RawFormatter FORMATTER = new RawFormatter();
- private final File m_logFile;
+ private final File m_logFile;
public OutputTargetTestCase( final String name )
throws IOException
{
super( name );
- m_logFile = (new File( "test/log/logfile.txt" )).getCanonicalFile();
+ m_logFile = ( new File( "test/log/logfile.txt" ) ).getCanonicalFile();
}
private String getResult( final ByteArrayOutputStream output )
@@ -188,7 +186,7 @@
target.push();
final String resultPP = getResult( output );
- assertEquals( "Targets HEAD+R1 debug output", HEAD+R1, resultPP );
+ assertEquals( "Targets HEAD+R1 debug output", HEAD + R1, resultPP );
logger.debug( M2 );
final String result2 = getResult( output );
@@ -202,14 +200,14 @@
assertEquals( "Targets R2 debug output", "", result2 );
assertEquals( "Targets R3 debug output", "", result3 );
- assertEquals( "Targets R3 debug output", R2+R3+R3, result4 );
+ assertEquals( "Targets R3 debug output", R2 + R3 + R3, result4 );
}
private Logger getNewLogger( final LogTarget target )
{
final Hierarchy hierarchy = new Hierarchy();
final Logger logger = hierarchy.getLoggerFor( "myCategory" );
- logger.setLogTargets( new LogTarget[] { target } );
+ logger.setLogTargets( new LogTarget[]{target} );
return logger;
}
1.4 +25 -25 jakarta-avalon-logkit/src/test/org/apache/log/output/test/TestRotatingFileOutputLogTarget.java
Index: TestRotatingFileOutputLogTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/test/org/apache/log/output/test/TestRotatingFileOutputLogTarget.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestRotatingFileOutputLogTarget.java 21 Aug 2001 09:31:43 -0000 1.3
+++ TestRotatingFileOutputLogTarget.java 27 Mar 2002 22:07:58 -0000 1.4
@@ -12,71 +12,71 @@
import org.apache.log.LogTarget;
import org.apache.log.Logger;
import org.apache.log.format.RawFormatter;
-import org.apache.log.output.io.rotate.RotatingFileTarget;
import org.apache.log.output.io.rotate.FileStrategy;
import org.apache.log.output.io.rotate.RevolvingFileStrategy;
-import org.apache.log.output.io.rotate.UniqueFileStrategy;
import org.apache.log.output.io.rotate.RotateStrategy;
-import org.apache.log.output.io.rotate.RotateStrategyByTime;
import org.apache.log.output.io.rotate.RotateStrategyBySize;
+import org.apache.log.output.io.rotate.RotateStrategyByTime;
+import org.apache.log.output.io.rotate.RotatingFileTarget;
+import org.apache.log.output.io.rotate.UniqueFileStrategy;
-/**
- *
+/**
+ *
* @author <a href="mailto:bh22351@i-one.at">Bernhard Huber</a>
*/
-public class TestRotatingFileOutputLogTarget
+public class TestRotatingFileOutputLogTarget
{
private RawFormatter m_formatter = new RawFormatter();
/** test file rotation by size, using unique filenames
*/
- public void testSizeUnique()
+ public void testSizeUnique()
throws Exception
{
final File file = new File( "test/size-unique.log" );
final FileStrategy fileStrategy = new UniqueFileStrategy( file );
final RotateStrategy rotateStrategy = new RotateStrategyBySize( 128 * 1024 );
final Logger logger = getLogger( fileStrategy, rotateStrategy );
-
+
doTest( logger );
}
/** test file rotation by size, using revolving filenames
*/
- public void testSizeRevoling()
+ public void testSizeRevoling()
throws Exception
{
final File file = new File( "test/size-revolve.log" );
final FileStrategy fileStrategy = new RevolvingFileStrategy( file, 20 );
final RotateStrategy rotateStrategy = new RotateStrategyBySize( 128 * 1024 );
final Logger logger = getLogger( fileStrategy, rotateStrategy );
-
+
doTest( logger );
}
/** test file rotation by time, using unique filenames
*/
- public void testTimeUnique()
+ public void testTimeUnique()
throws Exception
{
final File file = new File( "test/time-unique.log" );
final FileStrategy fileStrategy = new UniqueFileStrategy( file );
final RotateStrategy rotateStrategy = new RotateStrategyByTime( 3 * 1000 );
final Logger logger = getLogger( fileStrategy, rotateStrategy );
-
+
doTest( logger );
}
/** test file rotation by time, using revolving filenames
*/
- public void testTimeRevolving()
+ public void testTimeRevolving()
throws Exception
{
final File file = new File( "test/time-revolve.log" );
final FileStrategy fileStrategy = new RevolvingFileStrategy( file, 5 );
final RotateStrategy rotateStrategy = new RotateStrategyByTime( 3 * 1000 );
final Logger logger = getLogger( fileStrategy, rotateStrategy );
-
+
doTest( logger );
}
@@ -87,22 +87,22 @@
long endTime = startTime;
int size = 0;
- for( int i = 0; (endTime - startTime) < diffTime; i++ )
+ for( int i = 0; ( endTime - startTime ) < diffTime; i++ )
{
- size += generateMessages( logger, i, size, (endTime - startTime ) );
+ size += generateMessages( logger, i, size, ( endTime - startTime ) );
endTime = System.currentTimeMillis();
}
}
/** just generate some logger messages
*/
- private int generateMessages( final Logger logger,
- final int i,
- final long totalSize,
+ private int generateMessages( final Logger logger,
+ final int i,
+ final long totalSize,
final long diffTime )
{
- final String message =
- "Message " + i + ": total size " + totalSize + " diff time " + diffTime;
+ final String message =
+ "Message " + i + ": total size " + totalSize + " diff time " + diffTime;
logger.debug( message );
logger.info( message );
logger.warn( message );
@@ -112,21 +112,21 @@
return message.length();
}
- private Logger getLogger( final FileStrategy fileStrategy,
+ private Logger getLogger( final FileStrategy fileStrategy,
final RotateStrategy rotateStrategy )
throws Exception
{
- final RotatingFileTarget target =
+ final RotatingFileTarget target =
new RotatingFileTarget( m_formatter, rotateStrategy, fileStrategy );
final Hierarchy hierarchy = new Hierarchy();
final Logger logger = hierarchy.getLoggerFor( "myCat" );
- logger.setLogTargets( new LogTarget[] { target } );
+ logger.setLogTargets( new LogTarget[]{target} );
return logger;
}
- public static void main( final String args[] )
+ public static void main( final String args[] )
throws Exception
{
TestRotatingFileOutputLogTarget trfolt = new TestRotatingFileOutputLogTarget();
1.4 +8 -8 jakarta-avalon-logkit/src/test/org/apache/log/test/InheritanceTestCase.java
Index: InheritanceTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/test/org/apache/log/test/InheritanceTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InheritanceTestCase.java 22 Dec 2001 02:54:07 -0000 1.3
+++ InheritanceTestCase.java 27 Mar 2002 22:07:58 -0000 1.4
@@ -8,13 +8,13 @@
package org.apache.log.test;
import java.io.ByteArrayOutputStream;
+import junit.framework.TestCase;
import org.apache.log.Hierarchy;
import org.apache.log.LogTarget;
import org.apache.log.Logger;
import org.apache.log.Priority;
import org.apache.log.format.PatternFormatter;
import org.apache.log.output.io.StreamTarget;
-import junit.framework.TestCase;
/**
* Test suite for inheritance features of Logger.
@@ -139,8 +139,8 @@
final ByteArrayOutputStream output2 = new ByteArrayOutputStream();
final StreamTarget target2 = new StreamTarget( output2, FORMATTER2 );
- final LogTarget[] targets1 = new LogTarget[] { target1 };
- final LogTarget[] targets2 = new LogTarget[] { target2 };
+ final LogTarget[] targets1 = new LogTarget[]{target1};
+ final LogTarget[] targets2 = new LogTarget[]{target2};
final Hierarchy hierarchy = new Hierarchy();
hierarchy.setDefaultLogTarget( target1 );
@@ -228,12 +228,12 @@
final Hierarchy hierarchy = new Hierarchy();
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final StreamTarget target = new StreamTarget( output, FORMATTER );
- final LogTarget[] targets = new LogTarget[] { target };
+ final LogTarget[] targets = new LogTarget[]{target};
final Logger b = hierarchy.getLoggerFor( "b" );
final Logger bc = hierarchy.getLoggerFor( "b.c" );
final Logger bcd = hierarchy.getLoggerFor( "b.c.d" );
-
+
b.setLogTargets( targets );
bc.setLogTargets( targets );
bcd.setLogTargets( targets );
@@ -303,13 +303,13 @@
final StreamTarget target1 = new StreamTarget( output1, FORMATTER );
final StreamTarget target2 = new StreamTarget( output2, FORMATTER );
- final LogTarget[] targets1 = new LogTarget[] { target1 };
- final LogTarget[] targets2 = new LogTarget[] { target2 };
+ final LogTarget[] targets1 = new LogTarget[]{target1};
+ final LogTarget[] targets2 = new LogTarget[]{target2};
final Logger b = hierarchy.getLoggerFor( "b" );
final Logger bc = hierarchy.getLoggerFor( "b.c" );
final Logger bcd = hierarchy.getLoggerFor( "b.c.d" );
-
+
b.setLogTargets( targets1 );
bc.setLogTargets( targets2 );
bc.setAdditivity( true );
1.4 +1 -4 jakarta-avalon-logkit/src/test/org/apache/log/util/test/UtilTestCase.java
Index: UtilTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-logkit/src/test/org/apache/log/util/test/UtilTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- UtilTestCase.java 19 Nov 2001 12:18:35 -0000 1.3
+++ UtilTestCase.java 27 Mar 2002 22:07:58 -0000 1.4
@@ -9,16 +9,13 @@
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
+import junit.framework.TestCase;
import org.apache.log.Hierarchy;
-import org.apache.log.LogTarget;
import org.apache.log.Logger;
import org.apache.log.Priority;
-import org.apache.log.format.PatternFormatter;
import org.apache.log.format.RawFormatter;
import org.apache.log.output.io.StreamTarget;
import org.apache.log.util.LoggerOutputStream;
-import org.apache.log.util.StackIntrospector;
-import junit.framework.TestCase;
/**
* Test suite for utility features of Logger.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>