You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2011/09/12 05:24:06 UTC
svn commit: r1169598 - in
/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers: ./
log4j12-api/src/main/java/org/apache/log4j/
log4j12-api/src/test/java/org/apache/log4j/
log4j2-api/src/main/java/org/apache/logging/log4j/message/
Author: rgoers
Date: Mon Sep 12 03:24:06 2011
New Revision: 1169598
URL: http://svn.apache.org/viewvc?rev=1169598&view=rev
Log:
Fix more checkstyle and findbugs errors
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/checkstyle.xml
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Level.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/LogManager.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Logger.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/LoggerFactory.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/MDC.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/NDC.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Priority.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/test/java/org/apache/log4j/LevelTest.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LocalizedMessage.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/Message.java
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/checkstyle.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/checkstyle.xml?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/checkstyle.xml (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/checkstyle.xml Mon Sep 12 03:24:06 2011
@@ -85,6 +85,8 @@
</module>
<module name="JavadocStyle">
<property name="scope" value="public"/>
+ <!-- the checkHtml check is disabled as it generates incorrect errors -->
+ <property name="checkHtml" value="false"/>
</module>
@@ -172,7 +174,7 @@
<module name="IllegalInstantiation"/>
<!-- <module name="InnerAssignment"/> -->
<module name="MagicNumber">
- <property name="ignoreNumbers" value="-1,0,1,2,3"/>
+ <property name="ignoreNumbers" value="-1,0,1,2,3,4,5,6,7"/>
</module>
<module name="RedundantThrows">
<property name="allowUnchecked" value="true"/>
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java Mon Sep 12 03:24:06 2011
@@ -23,7 +23,6 @@ import org.apache.logging.log4j.message.
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.ObjectMessage;
-import java.util.Collections;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.WeakHashMap;
@@ -32,28 +31,41 @@ import java.util.concurrent.ConcurrentMa
/**
- *
+ * Implementation of the Category class for compatibility, despite it having been deprecated a long, long time ago.
*/
public class Category {
- private static final Map<LoggerContext, ConcurrentMap<String, Logger>> contextMap =
- new WeakHashMap<LoggerContext, ConcurrentMap<String, Logger>>();
- private final org.apache.logging.log4j.core.Logger logger;
+ private static org.apache.log4j.LoggerFactory loggerFactory = new PrivateFactory();
+
+ private static final Map<LoggerContext, ConcurrentMap<String, Logger>> CONTEXT_MAP =
+ new WeakHashMap<LoggerContext, ConcurrentMap<String, Logger>>();
private static final CategoryFactory FACTORY = new CategoryFactory();
private static final String FQCN = Category.class.getName();
+ /**
+ * Resource bundle for localized messages.
+ */
protected ResourceBundle bundle = null;
- private static org.apache.log4j.LoggerFactory loggerFactory = new PrivateFactory();
+ private final org.apache.logging.log4j.core.Logger logger;
+ /**
+ * Constructor used by Logger to specify a LoggerContext.
+ * @param context The LoggerContext.
+ * @param name The name of the Logger.
+ */
protected Category(LoggerContext context, String name) {
this.logger = context.getLogger(getFactory(), name);
}
+ /**
+ * Constructor exposed by Log4j 1.2.
+ * @param name The name of the Logger.
+ */
protected Category(String name) {
- this((LoggerContext)PrivateManager.getContext(), name);
+ this((LoggerContext) PrivateManager.getContext(), name);
}
private Category(org.apache.logging.log4j.core.Logger logger) {
@@ -61,7 +73,7 @@ public class Category {
}
public static Category getInstance(String name) {
- return getInstance((LoggerContext)PrivateManager.getContext(), name, loggerFactory);
+ return getInstance((LoggerContext) PrivateManager.getContext(), name, loggerFactory);
}
static Category getInstance(LoggerContext context, String name) {
@@ -116,11 +128,11 @@ public class Category {
}
private static ConcurrentMap<String, Logger> getLoggersMap(LoggerContext context) {
- synchronized (contextMap) {
- ConcurrentMap<String, Logger> map = contextMap.get(context);
+ synchronized (CONTEXT_MAP) {
+ ConcurrentMap<String, Logger> map = CONTEXT_MAP.get(context);
if (map == null) {
map = new ConcurrentHashMap<String, Logger>();
- contextMap.put(context, map);
+ CONTEXT_MAP.put(context, map);
}
return map;
}
@@ -297,6 +309,9 @@ public class Category {
return FACTORY;
}
+ /**
+ * Private logger factory.
+ */
private static class PrivateFactory implements org.apache.log4j.LoggerFactory {
public Logger makeNewLoggerInstance(LoggerContext context, String name) {
@@ -304,6 +319,9 @@ public class Category {
}
}
+ /**
+ * Private LogManager.
+ */
private static class PrivateManager extends org.apache.logging.log4j.LogManager {
private static final String FQCN = Category.class.getName();
@@ -316,12 +334,18 @@ public class Category {
}
}
+ /**
+ * Private Category factory.
+ */
private static class CategoryFactory implements org.apache.logging.log4j.spi.LoggerFactory<LoggerContext> {
public org.apache.logging.log4j.core.Logger newInstance(LoggerContext ctx, String name) {
return new CategoryLogger(ctx, name);
}
+ /**
+ * Category Logger.
+ */
public class CategoryLogger extends org.apache.logging.log4j.core.Logger {
public CategoryLogger(LoggerContext ctx, String name) {
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Level.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Level.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Level.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Level.java Mon Sep 12 03:24:06 2011
@@ -1,21 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
+ * The ASF licenses this file to You under the Apache license, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.log4j;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -23,170 +23,211 @@ import java.io.ObjectStreamException;
import java.io.Serializable;
/**
- Defines the minimum set of levels recognized by the system, that is
- <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
- <code>WARN</code>, <code>INFO</code, <code>DEBUG</code> and
- <code>ALL</code>.
-
- <p>The <code>Level</code> class may be subclassed to define a larger
- level set.
-
+ * Defines the minimum set of levels recognized by the system, that is
+ * <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
+ * <code>WARN</code>, <code>INFO</code, <code>DEBUG</code>
+ * and
+ * <code>ALL</code>.
+ * <p/>
+ * <p>The <code>Level</code> class may be subclassed to define a larger
+ * level set.
*/
public class Level extends Priority implements Serializable {
- /**
- * TRACE level integer value.
- * @since 1.2.12
- */
- public static final int TRACE_INT = 5000;
-
- /**
- The <code>OFF</code> has the highest possible rank and is
- intended to turn off logging. */
- final static public Level OFF = new Level(OFF_INT, "OFF", 0);
-
- /**
- The <code>FATAL</code> level designates very severe error
- events that will presumably lead the application to abort.
- */
- final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0);
-
- /**
- The <code>ERROR</code> level designates error events that
- might still allow the application to continue running. */
- final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3);
-
- /**
- The <code>WARN</code> level designates potentially harmful situations.
- */
- final static public Level WARN = new Level(WARN_INT, "WARN", 4);
-
- /**
- The <code>INFO</code> level designates informational messages
- that highlight the progress of the application at coarse-grained
- level. */
- final static public Level INFO = new Level(INFO_INT, "INFO", 6);
-
- /**
- The <code>DEBUG</code> Level designates fine-grained
- informational events that are most useful to debug an
- application. */
- final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
-
- /**
- * The <code>TRACE</code> Level designates finer-grained
- * informational events than the <code>DEBUG</code level.
- * @since 1.2.12
- */
- public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7);
-
-
- /**
- The <code>ALL</code> has the lowest possible rank and is intended to
- turn on all logging. */
- final static public Level ALL = new Level(ALL_INT, "ALL", 7);
-
- /**
- * Serialization version id.
- */
- static final long serialVersionUID = 3491141966387921974L;
-
- /**
- Instantiate a Level object.
- */
- protected
- Level(int level, String levelStr, int syslogEquivalent) {
- super(level, levelStr, syslogEquivalent);
- }
-
-
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns {@link #DEBUG}.
- */
- public
- static
- Level toLevel(String sArg) {
- return (Level) toLevel(sArg, Level.DEBUG);
- }
-
- /**
- Convert an integer passed as argument to a level. If the
- conversion fails, then this method returns {@link #DEBUG}.
-
- */
- public
- static
- Level toLevel(int val) {
- return (Level) toLevel(val, Level.DEBUG);
- }
-
- /**
- Convert an integer passed as argument to a level. If the
- conversion fails, then this method returns the specified default.
- */
- public
- static
- Level toLevel(int val, Level defaultLevel) {
- switch(val) {
- case ALL_INT: return ALL;
- case DEBUG_INT: return Level.DEBUG;
- case INFO_INT: return Level.INFO;
- case WARN_INT: return Level.WARN;
- case ERROR_INT: return Level.ERROR;
- case FATAL_INT: return Level.FATAL;
- case OFF_INT: return OFF;
- case TRACE_INT: return Level.TRACE;
- default: return defaultLevel;
- }
- }
-
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns the value of
- <code>defaultLevel</code>.
- */
- public
- static
- Level toLevel(String sArg, Level defaultLevel) {
- if(sArg == null)
- return defaultLevel;
-
- String s = sArg.toUpperCase();
-
- if(s.equals("ALL")) return Level.ALL;
- if(s.equals("DEBUG")) return Level.DEBUG;
- if(s.equals("INFO")) return Level.INFO;
- if(s.equals("WARN")) return Level.WARN;
- if(s.equals("ERROR")) return Level.ERROR;
- if(s.equals("FATAL")) return Level.FATAL;
- if(s.equals("OFF")) return Level.OFF;
- if(s.equals("TRACE")) return Level.TRACE;
- //
- // For Turkish i problem, see bug 40937
- //
- if(s.equals("\u0130NFO")) return Level.INFO;
- return defaultLevel;
- }
+ /**
+ * TRACE level integer value.
+ *
+ * @since 1.2.12
+ */
+ public static final int TRACE_INT = 5000;
+
+ /**
+ * The <code>OFF</code> has the highest possible rank and is
+ * intended to turn off logging.
+ */
+ public static final Level OFF = new Level(OFF_INT, "OFF", 0);
+
+ /**
+ * The <code>FATAL</code> level designates very severe error
+ * events that will presumably lead the application to abort.
+ */
+ public static final Level FATAL = new Level(FATAL_INT, "FATAL", 0);
+
+ /**
+ * The <code>ERROR</code> level designates error events that
+ * might still allow the application to continue running.
+ */
+ public static final Level ERROR = new Level(ERROR_INT, "ERROR", 3);
+
+ /**
+ * The <code>WARN</code> level designates potentially harmful situations.
+ */
+ public static final Level WARN = new Level(WARN_INT, "WARN", 4);
+
+ /**
+ * The <code>INFO</code> level designates informational messages
+ * that highlight the progress of the application at coarse-grained
+ * level.
+ */
+ public static final Level INFO = new Level(INFO_INT, "INFO", 6);
+
+ /**
+ * The <code>DEBUG</code> Level designates fine-grained
+ * informational events that are most useful to debug an
+ * application.
+ */
+ public static final Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
+
+ /**
+ * The <code>TRACE</code> Level designates finer-grained
+ * informational events than the <code>DEBUG</code> level.
+ */
+ public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7);
+
+ /**
+ * The <code>ALL</code> has the lowest possible rank and is intended to
+ * turn on all logging.
+ */
+ public static final Level ALL = new Level(ALL_INT, "ALL", 7);
+
+ /**
+ * Serialization version id.
+ */
+ private static final long serialVersionUID = 3491141966387921974L;
+
+ /**
+ * Instantiate a Level object.
+ *
+ * @param level The logging level.
+ * @param levelStr The level name.
+ * @param syslogEquivalent The matching syslog level.
+ */
+ protected Level(int level, String levelStr, int syslogEquivalent) {
+ super(level, levelStr, syslogEquivalent);
+ }
+
+
+ /**
+ * Convert the string passed as argument to a level. If the
+ * conversion fails, then this method returns {@link #DEBUG}.
+ *
+ * @param sArg The level name.
+ * @return The Level.
+ */
+ public static Level toLevel(String sArg) {
+ return toLevel(sArg, Level.DEBUG);
+ }
+
+ /**
+ * Convert an integer passed as argument to a level. If the
+ * conversion fails, then this method returns {@link #DEBUG}.
+ *
+ * @param val The integer value of the Level.
+ * @return The Level.
+ */
+ public static Level toLevel(int val) {
+ return toLevel(val, Level.DEBUG);
+ }
+
+ /**
+ * Convert an integer passed as argument to a level. If the
+ * conversion fails, then this method returns the specified default.
+ *
+ * @param val The integer value of the Level.
+ * @param defaultLevel the default level if the integer doesn't match.
+ * @return The matching Level.
+ */
+ public static Level toLevel(int val, Level defaultLevel) {
+ switch (val) {
+ case ALL_INT:
+ return ALL;
+ case DEBUG_INT:
+ return Level.DEBUG;
+ case INFO_INT:
+ return Level.INFO;
+ case WARN_INT:
+ return Level.WARN;
+ case ERROR_INT:
+ return Level.ERROR;
+ case FATAL_INT:
+ return Level.FATAL;
+ case OFF_INT:
+ return OFF;
+ case TRACE_INT:
+ return Level.TRACE;
+ default:
+ return defaultLevel;
+ }
+ }
+
+ /**
+ * Convert the string passed as argument to a level. If the
+ * conversion fails, then this method returns the value of
+ * <code>defaultLevel</code>.
+ * @param sArg The name of the Level.
+ * @param defaultLevel The default Level to use.
+ * @return the matching Level.
+ */
+ public static Level toLevel(String sArg, Level defaultLevel) {
+ if (sArg == null) {
+ return defaultLevel;
+ }
+
+ String s = sArg.toUpperCase();
+
+ if (s.equals("ALL")) {
+ return Level.ALL;
+ }
+ if (s.equals("DEBUG")) {
+ return Level.DEBUG;
+ }
+ if (s.equals("INFO")) {
+ return Level.INFO;
+ }
+ if (s.equals("WARN")) {
+ return Level.WARN;
+ }
+ if (s.equals("ERROR")) {
+ return Level.ERROR;
+ }
+ if (s.equals("FATAL")) {
+ return Level.FATAL;
+ }
+ if (s.equals("OFF")) {
+ return Level.OFF;
+ }
+ if (s.equals("TRACE")) {
+ return Level.TRACE;
+ }
+ //
+ // For Turkish i problem, see bug 40937
+ //
+ if (s.equals("\u0130NFO")) {
+ return Level.INFO;
+ }
+ return defaultLevel;
+ }
/**
* Custom deserialization of Level.
+ *
* @param s serialization stream.
- * @throws IOException if IO exception.
+ * @throws IOException if IO exception.
* @throws ClassNotFoundException if class not found.
*/
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
- s.defaultReadObject();
- level = s.readInt();
- syslogEquivalent = s.readInt();
- levelStr = s.readUTF();
- if (levelStr == null) {
- levelStr = "";
- }
+ s.defaultReadObject();
+ level = s.readInt();
+ syslogEquivalent = s.readInt();
+ levelStr = s.readUTF();
+ if (levelStr == null) {
+ levelStr = "";
+ }
}
/**
* Serialize level.
+ *
* @param s serialization stream.
* @throws IOException if exception during serialization.
*/
@@ -200,10 +241,11 @@ public class Level extends Priority impl
/**
* Resolved deserialized level to one of the stock instances.
* May be overriden in classes derived from Level.
+ *
* @return resolved object.
* @throws ObjectStreamException if exception during resolution.
*/
- private Object readResolve() throws ObjectStreamException {
+ protected Object readResolve() throws ObjectStreamException {
//
// if the deserizalized object is exactly an instance of Level
//
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/LogManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/LogManager.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/LogManager.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/LogManager.java Mon Sep 12 03:24:06 2011
@@ -21,7 +21,10 @@ import org.apache.logging.log4j.spi.Logg
/**
*
*/
-public class LogManager {
+public final class LogManager {
+
+ private LogManager() {
+ }
public static Logger getRootLogger() {
return (Logger) PrivateManager.getLogger("");
@@ -43,6 +46,9 @@ public class LogManager {
return Logger.getLogger(name);
}
+ /**
+ * Internal LogManager.
+ */
private static class PrivateManager extends org.apache.logging.log4j.LogManager {
private static final String FQCN = LogManager.class.getName();
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Logger.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Logger.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Logger.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Logger.java Mon Sep 12 03:24:06 2011
@@ -27,7 +27,7 @@ public class Logger extends Category {
private static final String FQCN = Logger.class.getName();
protected Logger(String name) {
- super((LoggerContext)PrivateManager.getContext(), name);
+ super((LoggerContext) PrivateManager.getContext(), name);
}
Logger(LoggerContext context, String name) {
@@ -35,21 +35,24 @@ public class Logger extends Category {
}
public static Logger getLogger(String name) {
- return (Logger) Category.getInstance((LoggerContext)PrivateManager.getContext(), name);
+ return (Logger) Category.getInstance((LoggerContext) PrivateManager.getContext(), name);
}
public static Logger getLogger(Class clazz) {
- return (Logger) Category.getInstance((LoggerContext)PrivateManager.getContext(), clazz);
+ return (Logger) Category.getInstance((LoggerContext) PrivateManager.getContext(), clazz);
}
public static Logger getRootLogger() {
- return (Logger) Category.getRoot((LoggerContext)PrivateManager.getContext());
+ return (Logger) Category.getRoot((LoggerContext) PrivateManager.getContext());
}
public static Logger getLogger(String name, LoggerFactory factory) {
- return (Logger) Category.getInstance((LoggerContext)PrivateManager.getContext(), name, factory);
+ return (Logger) Category.getInstance((LoggerContext) PrivateManager.getContext(), name, factory);
}
+ /**
+ * Internal Log Manager.
+ */
private static class PrivateManager extends org.apache.logging.log4j.LogManager {
private static final String FQCN = Logger.class.getName();
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/LoggerFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/LoggerFactory.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/LoggerFactory.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/LoggerFactory.java Mon Sep 12 03:24:06 2011
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
+ * The ASF licenses this file to You under the Apache license, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
package org.apache.log4j;
/**
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/MDC.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/MDC.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/MDC.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/MDC.java Mon Sep 12 03:24:06 2011
@@ -21,7 +21,10 @@ import org.apache.logging.log4j.ThreadCo
/**
*
*/
-public class MDC {
+public final class MDC {
+
+ private MDC() {
+ }
public static void put(String key, Object value) {
ThreadContext.put(key, value);
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/NDC.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/NDC.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/NDC.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/NDC.java Mon Sep 12 03:24:06 2011
@@ -21,7 +21,11 @@ import java.util.Stack;
/**
*
*/
-public class NDC {
+public final class NDC {
+
+ private NDC() {
+ }
+
/**
* Clear any nested diagnostic information if any. This method is
* useful in cases where the same thread can be potentially used
@@ -78,7 +82,8 @@ public class NDC {
/**
- * <font color="#FF4040"><b>Never use this method directly.
+ * <font color="#FF4040"><b>Never use this method directly.</b>
+ * @return The string value of the specified key.
*/
public static String get() {
return org.apache.logging.log4j.ThreadContext.peek();
@@ -86,7 +91,7 @@ public class NDC {
/**
* Get the current nesting depth of this diagnostic context.
- *
+ * @return int The number of elements in the call stack.
* @see #setMaxDepth
*/
public static int getDepth() {
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Priority.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Priority.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Priority.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Priority.java Mon Sep 12 03:24:06 2011
@@ -1,20 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
+ * The ASF licenses this file to You under the Apache license, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.log4j;
/**
@@ -23,44 +22,75 @@ package org.apache.log4j;
*/
public class Priority {
- transient int level;
- transient String levelStr;
- transient int syslogEquivalent;
-
- public final static int OFF_INT = Integer.MAX_VALUE;
- public final static int FATAL_INT = 50000;
- public final static int ERROR_INT = 40000;
- public final static int WARN_INT = 30000;
- public final static int INFO_INT = 20000;
- public final static int DEBUG_INT = 10000;
+ /**
+ * The <code>OFF</code> has the highest possible rank and is
+ * intended to turn off logging.
+ */
+ public static final int OFF_INT = Integer.MAX_VALUE;
+ /**
+ * The <code>FATAL</code> level designates very severe error
+ * events that will presumably lead the application to abort.
+ */
+ public static final int FATAL_INT = 50000;
+ /**
+ * The <code>ERROR</code> level designates error events that
+ * might still allow the application to continue running.
+ */
+ public static final int ERROR_INT = 40000;
+ /**
+ * The <code>WARN</code> level designates potentially harmful situations.
+ */
+ public static final int WARN_INT = 30000;
+ /**
+ * The <code>INFO</code> level designates informational messages
+ * that highlight the progress of the application at coarse-grained
+ * level.
+ */
+ public static final int INFO_INT = 20000;
+ /**
+ * The <code>DEBUG</code> Level designates fine-grained
+ * informational events that are most useful to debug an
+ * application.
+ */
+ public static final int DEBUG_INT = 10000;
//public final static int FINE_INT = DEBUG_INT;
- public final static int ALL_INT = Integer.MIN_VALUE;
+ /**
+ * The <code>ALL</code> has the lowest possible rank and is intended to
+ * turn on all logging.
+ */
+ public static final int ALL_INT = Integer.MIN_VALUE;
/**
* @deprecated Use {@link Level#FATAL} instead.
*/
- final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
+ public static final Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
/**
* @deprecated Use {@link Level#ERROR} instead.
*/
- final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
+ public static final Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
/**
* @deprecated Use {@link Level#WARN} instead.
*/
- final static public Priority WARN = new Level(WARN_INT, "WARN", 4);
+ public static final Priority WARN = new Level(WARN_INT, "WARN", 4);
/**
* @deprecated Use {@link Level#INFO} instead.
*/
- final static public Priority INFO = new Level(INFO_INT, "INFO", 6);
+ public static final Priority INFO = new Level(INFO_INT, "INFO", 6);
/**
* @deprecated Use {@link Level#DEBUG} instead.
*/
- final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
+ public static final Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
+ /*
+ * These variables should be private but were not in Log4j 1.2 so are left the same way here.
+ */
+ transient int level;
+ transient String levelStr;
+ transient int syslogEquivalent;
/**
* Default constructor for deserialization.
@@ -73,6 +103,9 @@ public class Priority {
/**
* Instantiate a level object.
+ * @param level The level value.
+ * @param levelStr The level name.
+ * @param syslogEquivalent The equivalent syslog value.
*/
protected Priority(int level, String levelStr, int syslogEquivalent) {
this.level = level;
@@ -82,6 +115,8 @@ public class Priority {
/**
* Two priorities are equal if their level fields are equal.
+ * @param o The Object to check.
+ * @return true if the objects are equal, false otherwise.
*
* @since 1.2
*/
@@ -96,6 +131,7 @@ public class Priority {
/**
* Return the syslog equivalent of this priority as an integer.
+ * @return The equivalent syslog value.
*/
public
final int getSyslogEquivalent() {
@@ -110,6 +146,8 @@ public class Priority {
* <p/>
* <p>You should think twice before overriding the default
* implementation of <code>isGreaterOrEqual</code> method.
+ * @param r The Priority to check.
+ * @return true if the current level is greater or equal to the specified Priority.
*/
public boolean isGreaterOrEqual(Priority r) {
return level >= r.level;
@@ -118,11 +156,11 @@ public class Priority {
/**
* Return all possible priorities as an array of Level objects in
* descending order.
+ * @return An array of all possible Priorities.
*
* @deprecated This method will be removed with no replacement.
*/
- public
- static Priority[] getAllPossiblePriorities() {
+ public static Priority[] getAllPossiblePriorities() {
return new Priority[]{Priority.FATAL, Priority.ERROR, Level.WARN,
Priority.INFO, Priority.DEBUG};
}
@@ -130,49 +168,55 @@ public class Priority {
/**
* Returns the string representation of this priority.
+ * @return The name of the Priority.
*/
- final
- public String toString() {
+ public final String toString() {
return levelStr;
}
/**
* Returns the integer representation of this level.
+ * @return The integer value of this level.
*/
- public
- final int toInt() {
+ public final int toInt() {
return level;
}
/**
+ * @param sArg The name of the Priority.
+ * @return The Priority matching the name.
* @deprecated Please use the {@link Level#toLevel(String)} method instead.
*/
- public
- static Priority toPriority(String sArg) {
+ public static Priority toPriority(String sArg) {
return Level.toLevel(sArg);
}
/**
+ * @param val The value of the Priority.
+ * @return The Priority matching the value.
* @deprecated Please use the {@link Level#toLevel(int)} method instead.
*/
- public
- static Priority toPriority(int val) {
+ public static Priority toPriority(int val) {
return toPriority(val, Priority.DEBUG);
}
/**
+ * @param val The value of the Priority.
+ * @param defaultPriority The default Priority to use if the value is invalid.
+ * @return The Priority matching the value or the default Priority if no match is found.
* @deprecated Please use the {@link Level#toLevel(int, Level)} method instead.
*/
- public
- static Priority toPriority(int val, Priority defaultPriority) {
+ public static Priority toPriority(int val, Priority defaultPriority) {
return Level.toLevel(val, (Level) defaultPriority);
}
/**
+ * @param sArg The name of the Priority.
+ * @param defaultPriority The default Priority to use if the name is not found.
+ * @return The Priority matching the name or the default Priority if no match is found.
* @deprecated Please use the {@link Level#toLevel(String, Level)} method instead.
*/
- public
- static Priority toPriority(String sArg, Priority defaultPriority) {
+ public static Priority toPriority(String sArg, Priority defaultPriority) {
return Level.toLevel(sArg, (Level) defaultPriority);
}
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/test/java/org/apache/log4j/LevelTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/test/java/org/apache/log4j/LevelTest.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/test/java/org/apache/log4j/LevelTest.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/test/java/org/apache/log4j/LevelTest.java Mon Sep 12 03:24:06 2011
@@ -216,14 +216,6 @@ public class LevelTest {
}
/**
- * Tests Level.serialVersionUID.
- */
- @Test
- public void testSerialVersionUID() {
- assertEquals(3491141966387921974L, Level.serialVersionUID);
- }
-
- /**
* Tests Level.toLevel(Level.All_INT).
*/
@Test
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LocalizedMessage.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LocalizedMessage.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LocalizedMessage.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LocalizedMessage.java Mon Sep 12 03:24:06 2011
@@ -18,6 +18,8 @@ package org.apache.logging.log4j.message
import org.apache.logging.log4j.status.StatusLogger;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
@@ -41,7 +43,7 @@ public class LocalizedMessage extends Pa
private Locale locale;
- private StatusLogger logger = StatusLogger.getLogger();
+ private transient StatusLogger logger = StatusLogger.getLogger();
private String loggerName = null;
@@ -279,4 +281,10 @@ public class LocalizedMessage extends Pa
}
return rb;
}
+
+ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+ bundle = null;
+ logger = StatusLogger.getLogger();
+ }
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/Message.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/Message.java?rev=1169598&r1=1169597&r2=1169598&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/Message.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/Message.java Mon Sep 12 03:24:06 2011
@@ -23,6 +23,12 @@ import java.io.Serializable;
* around Objects so that user can have control over converting Objects to Strings when necessary without
* requiring complicated formatters and as a way to manipulate the message based on information available
* at runtime such as the locale of the system.
+ *
+ * Note: Message objects should not be considered to be thread safe nor should they be assumed to be
+ * safely reusable even on the same thread. The logging system may provide information to the Message
+ * objects and the Messages might be queued for asynchronous delivery. Thus, any modifications to a
+ * Message object by an application should by avoided after the Message has been passed as a parameter on
+ * a Logger method.
* @doubt Interfaces should rarely extend Serializable according to Effective Java 2nd Ed pg 291.
* (RG) That section also says "If a class or interface exists primarily to participate in a framework that
* requires all participants to implement Serializable, then it makes perfect sense for the class or