Skip to content

Commit

Permalink
formatting changes only
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Nov 28, 2022
1 parent cd95c1c commit 789a2b0
Show file tree
Hide file tree
Showing 24 changed files with 597 additions and 805 deletions.
31 changes: 13 additions & 18 deletions src/main/java/org/apache/log4j/Appender.java
Expand Up @@ -22,8 +22,7 @@
import org.apache.log4j.spi.LoggingEvent;

/**
* Implement this interface for your own strategies for outputting log
* statements.
* Implement this interface for your own strategies for outputting log statements.
*
* @author Ceki G&uuml;lc&uuml;
*/
Expand All @@ -37,8 +36,8 @@ public interface Appender {
void addFilter(Filter newFilter);

/**
* Returns the head Filter. The Filters are organized in a linked list and so
* all Filters on this Appender are available through the result.
* Returns the head Filter. The Filters are organized in a linked list and so all Filters on this Appender are
* available through the result.
*
* @return the head Filter or null, if no Filters are present
* @since 1.1
Expand All @@ -53,8 +52,7 @@ public interface Appender {
public void clearFilters();

/**
* Release any resources allocated within the appender such as file handles,
* network connections, etc.
* Release any resources allocated within the appender such as file handles, network connections, etc.
*
* <p>
* It is a programming error to append to a closed appender.
Expand All @@ -64,9 +62,8 @@ public interface Appender {
public void close();

/**
* Log in <code>Appender</code> specific way. When appropriate, Loggers will
* call the <code>doAppend</code> method of appender implementations in order to
* log.
* Log in <code>Appender</code> specific way. When appropriate, Loggers will call the <code>doAppend</code> method
* of appender implementations in order to log.
*/
public void doAppend(LoggingEvent event);

Expand Down Expand Up @@ -106,25 +103,23 @@ public interface Appender {
public Layout getLayout();

/**
* Set the name of this appender. The name is used by other components to
* identify this appender.
* Set the name of this appender. The name is used by other components to identify this appender.
*
* @since 0.8.1
*/
public void setName(String name);

/**
* Configurators call this method to determine if the appender requires a
* layout. If this method returns <code>true</code>, meaning that layout is
* required, then the configurator will configure an layout using the
* Configurators call this method to determine if the appender requires a layout. If this method returns
* <code>true</code>, meaning that layout is required, then the configurator will configure an layout using the
* configuration information at its disposal. If this method returns
* <code>false</code>, meaning that a layout is not required, then layout
* configuration will be skipped even if there is available layout configuration
* information at the disposal of the configurator..
* configuration will be skipped even if there is available layout configuration information at the disposal of the
* configurator..
*
* <p>
* In the rather exceptional case, where the appender implementation admits a
* layout but can also work without it, then the appender should return
* In the rather exceptional case, where the appender implementation admits a layout but can also work without it,
* then the appender should return
* <code>true</code>.
*
* @since 0.8.4
Expand Down
57 changes: 24 additions & 33 deletions src/main/java/org/apache/log4j/AppenderSkeleton.java
Expand Up @@ -27,17 +27,16 @@
/**
* Abstract superclass of the other appenders in the package.
* <p>
* This class provides the code for common functionality, such as support for
* threshold filtering and support for general filters.
* This class provides the code for common functionality, such as support for threshold filtering and support for
* general filters.
*
* @author Ceki G&uuml;lc&uuml;
* @since 0.8.1
*/
public abstract class AppenderSkeleton implements Appender, OptionHandler {

/**
* The layout variable does not need to be set if the appender implementation
* has its own layout.
* The layout variable does not need to be set if the appender implementation has its own layout.
*/
protected Layout layout;

Expand Down Expand Up @@ -80,17 +79,15 @@ public AppenderSkeleton() {
/**
* Create new instance. Provided for compatibility with log4j 1.3.
*
* @param isActive true if appender is ready for use upon construction. Not used
* in log4j 1.2.x.
* @param isActive true if appender is ready for use upon construction. Not used in log4j 1.2.x.
* @since 1.2.15
*/
protected AppenderSkeleton(final boolean isActive) {
super();
}

/**
* Derived appenders should override this method if option structure requires
* it.
* Derived appenders should override this method if option structure requires it.
*/
public void activateOptions() {
}
Expand All @@ -110,9 +107,8 @@ public void addFilter(Filter newFilter) {
}

/**
* Subclasses of <code>AppenderSkeleton</code> should implement this method to
* perform actual logging. See also {@link #doAppend AppenderSkeleton.doAppend}
* method.
* Subclasses of <code>AppenderSkeleton</code> should implement this method to perform actual logging. See also
* {@link #doAppend AppenderSkeleton.doAppend} method.
*
* @since 0.9.0
*/
Expand All @@ -128,8 +124,7 @@ public void clearFilters() {
}

/**
* Finalize this appender by calling the derived class' <code>close</code>
* method.
* Finalize this appender by calling the derived class' <code>close</code> method.
*
* @since 0.8.4
*/
Expand Down Expand Up @@ -162,8 +157,8 @@ public Filter getFilter() {
}

/**
* Return the first filter in the filter chain for this Appender. The return
* value may be <code>null</code> if no is filter is set.
* Return the first filter in the filter chain for this Appender. The return value may be <code>null</code> if no is
* filter is set.
*/
public final Filter getFirstFilter() {
return headFilter;
Expand All @@ -186,8 +181,7 @@ public final String getName() {
}

/**
* Returns this appenders threshold level. See the {@link #setThreshold} method
* for the meaning of this option.
* Returns this appenders threshold level. See the {@link #setThreshold} method for the meaning of this option.
*
* @since 1.1
*/
Expand All @@ -196,17 +190,16 @@ public Priority getThreshold() {
}

/**
* Check whether the message level is below the appender's threshold. If there
* is no threshold set, then the return value is always <code>true</code>.
* Check whether the message level is below the appender's threshold. If there is no threshold set, then the return
* value is always <code>true</code>.
*/
public boolean isAsSevereAsThreshold(Priority priority) {
return ((threshold == null) || priority.isGreaterOrEqual(threshold));
}

/**
* This method performs threshold checks and invokes filters before delegating
* actual logging to the subclasses specific {@link AppenderSkeleton#append}
* method.
* This method performs threshold checks and invokes filters before delegating actual logging to the subclasses
* specific {@link AppenderSkeleton#append} method.
*/
public synchronized void doAppend(LoggingEvent event) {
if (closed) {
Expand All @@ -223,12 +216,12 @@ public synchronized void doAppend(LoggingEvent event) {
FILTER_LOOP:
while (f != null) {
switch (f.decide(event)) {
case Filter.DENY:
return;
case Filter.ACCEPT:
break FILTER_LOOP;
case Filter.NEUTRAL:
f = f.getNext();
case Filter.DENY:
return;
case Filter.ACCEPT:
break FILTER_LOOP;
case Filter.NEUTRAL:
f = f.getNext();
}
}

Expand All @@ -251,9 +244,8 @@ public synchronized void setErrorHandler(ErrorHandler eh) {
}

/**
* Set the layout for this appender. Note that some appenders have their own
* (fixed) layouts or do not use one. For example, the
* {@link org.apache.log4j.net.SocketAppender} ignores the layout set here.
* Set the layout for this appender. Note that some appenders have their own (fixed) layouts or do not use one. For
* example, the {@link org.apache.log4j.net.SocketAppender} ignores the layout set here.
*/
public void setLayout(Layout layout) {
this.layout = layout;
Expand All @@ -267,8 +259,7 @@ public void setName(String name) {
}

/**
* Set the threshold level. All log events with lower level than the threshold
* level are ignored by the appender.
* Set the threshold level. All log events with lower level than the threshold level are ignored by the appender.
*
* <p>
* In configuration files this option is specified by setting the value of the
Expand Down
46 changes: 20 additions & 26 deletions src/main/java/org/apache/log4j/AsyncAppender.java
Expand Up @@ -35,9 +35,8 @@
* The AsyncAppender lets users log events asynchronously.
* <p/>
* <p/>
* The AsyncAppender will collect the events sent to it and then dispatch them
* to all the appenders that are attached to it. You can attach multiple
* appenders to an AsyncAppender.
* The AsyncAppender will collect the events sent to it and then dispatch them to all the appenders that are attached to
* it. You can attach multiple appenders to an AsyncAppender.
* </p>
* <p/>
* <p/>
Expand All @@ -59,8 +58,7 @@ public class AsyncAppender extends AppenderSkeleton implements AppenderAttachabl
public static final int DEFAULT_BUFFER_SIZE = 128;

/**
* Event buffer, also used as monitor to protect itself and discardMap from
* simulatenous modifications.
* Event buffer, also used as monitor to protect itself and discardMap from simulatenous modifications.
*/
private final List buffer = new ArrayList();

Expand Down Expand Up @@ -222,8 +220,8 @@ public void append(final LoggingEvent event) {
}

/**
* Close this <code>AsyncAppender</code> by interrupting the dispatcher thread
* which will process all pending events before exiting.
* Close this <code>AsyncAppender</code> by interrupting the dispatcher thread which will process all pending events
* before exiting.
*/
public void close() {
/**
Expand All @@ -239,8 +237,8 @@ public void close() {
dispatcher.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
org.apache.log4j.helpers.LogLog
.error("Got an InterruptedException while waiting for the " + "dispatcher to finish.", e);
org.apache.log4j.helpers.LogLog.error(
"Got an InterruptedException while waiting for the " + "dispatcher to finish.", e);
}

//
Expand Down Expand Up @@ -344,15 +342,13 @@ public void removeAppender(final String name) {
}

/**
* The <b>LocationInfo</b> option takes a boolean value. By default, it is set
* to false which means there will be no effort to extract the location
* information related to the event. As a result, the event that will be
* ultimately logged will likely to contain the wrong location information (if
* present in the log format).
* The <b>LocationInfo</b> option takes a boolean value. By default, it is set to false which means there will be no
* effort to extract the location information related to the event. As a result, the event that will be ultimately
* logged will likely to contain the wrong location information (if present in the log format).
* <p/>
* <p/>
* Location information extraction is comparatively very slow and should be
* avoided unless performance is not a concern.
* Location information extraction is comparatively very slow and should be avoided unless performance is not a
* concern.
* </p>
*
* @param flag true if location information should be extracted.
Expand All @@ -362,9 +358,9 @@ public void setLocationInfo(final boolean flag) {
}

/**
* Sets the number of messages allowed in the event buffer before the calling
* thread is blocked (if blocking is true) or until messages are summarized and
* discarded. Changing the size will not affect messages already in the buffer.
* Sets the number of messages allowed in the event buffer before the calling thread is blocked (if blocking is
* true) or until messages are summarized and discarded. Changing the size will not affect messages already in the
* buffer.
*
* @param size buffer size, must be positive.
*/
Expand Down Expand Up @@ -396,8 +392,7 @@ public int getBufferSize() {
}

/**
* Sets whether appender should wait if there is no space available in the event
* buffer or immediately return.
* Sets whether appender should wait if there is no space available in the event buffer or immediately return.
*
* @param value true if appender should wait until available space in buffer.
* @since 1.2.14
Expand All @@ -410,9 +405,8 @@ public void setBlocking(final boolean value) {
}

/**
* Gets whether appender should block calling thread when buffer is full. If
* false, messages will be counted by logger and a summary message appended
* after the contents of the buffer have been appended.
* Gets whether appender should block calling thread when buffer is full. If false, messages will be counted by
* logger and a summary message appended after the contents of the buffer have been appended.
*
* @return true if calling thread will be blocked when buffer is full.
* @since 1.2.14
Expand Down Expand Up @@ -465,7 +459,7 @@ public void add(final LoggingEvent event) {
*/
public LoggingEvent createEvent() {
String msg = MessageFormat.format("Discarded {0} messages due to full event buffer including: {1}",
new Object[]{new Integer(count), maxEvent.getMessage()});
new Object[] { new Integer(count), maxEvent.getMessage() });

return new LoggingEvent("org.apache.log4j.AsyncAppender.DONT_REPORT_LOCATION",
Logger.getLogger(maxEvent.getLoggerName()), maxEvent.getLevel(), msg, null);
Expand Down Expand Up @@ -505,7 +499,7 @@ private static class Dispatcher implements Runnable {
* @param appenders appenders, may not be null.
*/
public Dispatcher(final AsyncAppender parent, final List buffer, final Map discardMap,
final AppenderAttachableImpl appenders) {
final AppenderAttachableImpl appenders) {

this.parent = parent;
this.buffer = buffer;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/apache/log4j/BasicConfigurator.java
Expand Up @@ -25,9 +25,8 @@
* Use this class to quickly configure the package.
*
* <p>
* For file based configuration see {@link PropertyConfigurator}. For XML based
* configuration see {@link org.apache.log4j.xml.DOMConfigurator
* DOMConfigurator}.
* For file based configuration see {@link PropertyConfigurator}. For XML based configuration see
* {@link org.apache.log4j.xml.DOMConfigurator DOMConfigurator}.
*
* @author Ceki G&uuml;lc&uuml;
* @since 0.8.1
Expand Down

0 comments on commit 789a2b0

Please sign in to comment.