You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@apache.org on 2001/02/03 23:39:24 UTC
cvs commit: jakarta-log4j/org/apache/log4j/xml/examples XCategory.java
ceki 01/02/03 14:39:24
Modified: org/apache/log4j Category.java DefaultCategoryFactory.java
PropertyConfigurator.java
org/apache/log4j/examples MyCategory.java
MyCategoryFactory.java
org/apache/log4j/examples/appserver AppServerCategory.java
AppServerCategoryFactory.java
org/apache/log4j/spi RootCategory.java
org/apache/log4j/xml XMLLayout.java
org/apache/log4j/xml/examples XCategory.java
Log:
Simplified handling of FCQN variables in Category, CategoryFactory and subclasses.
Added <![[CDATA .. ]] to the output of certain elements.
Revision Changes Path
1.22 +23 -28 jakarta-log4j/org/apache/log4j/Category.java
Index: Category.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/Category.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Category.java 2001/02/02 20:18:05 1.21
+++ Category.java 2001/02/03 22:39:22 1.22
@@ -160,7 +160,7 @@
/**
The fully qualified name of the class that this Category
object. Subclasses should override this variable. */
- public final String instanceFQCN;
+ private static final String FQCN = Category.class.getName();
protected ResourceBundle resourceBundle;
@@ -187,13 +187,10 @@
create categories directly.
@param name The name of the category.
- @param instanceFQCN The fully qualified name of the class that this
- category instance belongs to. Subclasses of Category
- must specify their own fully qualified class name. */
+ */
protected
- Category(String name, String instanceFQCN) {
+ Category(String name) {
this.name = name;
- this.instanceFQCN = instanceFQCN;
}
/**
@@ -303,7 +300,7 @@
if(hierarchy.disable >= Priority.DEBUG_INT)
return;
if(Priority.DEBUG.isGreaterOrEqual(this.getChainedPriority())) {
- forcedLog(instanceFQCN, Priority.DEBUG, message, null);
+ forcedLog(FQCN, Priority.DEBUG, message, null);
}
}
@@ -321,8 +318,7 @@
void debug(Object message, Throwable t) {
if(hierarchy.disable >= Priority.DEBUG_INT) return;
if(this.isEnabledFor(Priority.DEBUG))
- forcedLog(instanceFQCN, Priority.DEBUG, message, t);
-
+ forcedLog(FQCN, Priority.DEBUG, message, t);
}
//public
@@ -356,7 +352,7 @@
void error(Object message) {
if(hierarchy.disable >= Priority.ERROR_INT) return;
if(this.isEnabledFor(Priority.ERROR))
- forcedLog(instanceFQCN, Priority.ERROR, message, null);
+ forcedLog(FQCN, Priority.ERROR, message, null);
}
/**
@@ -372,7 +368,7 @@
void error(Object message, Throwable t) {
if(hierarchy.disable >= Priority.ERROR_INT) return;
if(this.isEnabledFor(Priority.ERROR))
- forcedLog(instanceFQCN, Priority.ERROR, message, t);
+ forcedLog(FQCN, Priority.ERROR, message, t);
}
@@ -412,7 +408,7 @@
void fatal(Object message) {
if(hierarchy.disable >= Priority.FATAL_INT) return;
if(Priority.FATAL.isGreaterOrEqual(this.getChainedPriority()))
- forcedLog(instanceFQCN, Priority.FATAL, message, null);
+ forcedLog(FQCN, Priority.FATAL, message, null);
}
/**
@@ -428,7 +424,7 @@
void fatal(Object message, Throwable t) {
if(hierarchy.disable >= Priority.FATAL_INT) return;
if(Priority.FATAL.isGreaterOrEqual(this.getChainedPriority()))
- forcedLog(instanceFQCN, Priority.FATAL, message, t);
+ forcedLog(FQCN, Priority.FATAL, message, t);
}
@@ -436,8 +432,8 @@
This method creates a new logging event and logs the event
without further checks. */
protected
- void forcedLog(String FQCN, Priority priority, Object message, Throwable t) {
- callAppenders(new LoggingEvent(FQCN, this, priority, message, t));
+ void forcedLog(String fqcn, Priority priority, Object message, Throwable t) {
+ callAppenders(new LoggingEvent(fqcn, this, priority, message, t));
}
@@ -525,7 +521,7 @@
attached.
@since 1.1 */
- public
+ public
Hierarchy getHierarchy() {
return hierarchy;
}
@@ -686,7 +682,7 @@
void info(Object message) {
if(hierarchy.disable >= Priority.INFO_INT) return;
if(Priority.INFO.isGreaterOrEqual(this.getChainedPriority()))
- forcedLog(instanceFQCN, Priority.INFO, message, null);
+ forcedLog(FQCN, Priority.INFO, message, null);
}
/**
@@ -702,7 +698,7 @@
void info(Object message, Throwable t) {
if(hierarchy.disable >= Priority.INFO_INT) return;
if(Priority.INFO.isGreaterOrEqual(this.getChainedPriority()))
- forcedLog(instanceFQCN, Priority.INFO, message, t);
+ forcedLog(FQCN, Priority.INFO, message, t);
}
/**
@@ -798,7 +794,7 @@
if(msg == null) {
msg = key;
}
- forcedLog(instanceFQCN, priority, msg, t);
+ forcedLog(FQCN, priority, msg, t);
}
}
/**
@@ -822,7 +818,7 @@
msg = key;
else
msg = java.text.MessageFormat.format(pattern, params);
- forcedLog(instanceFQCN, priority, msg, t);
+ forcedLog(FQCN, priority, msg, t);
}
}
@@ -835,11 +831,11 @@
return;
}
if(priority.isGreaterOrEqual(this.getChainedPriority()))
- forcedLog(instanceFQCN, priority, message, t);
+ forcedLog(FQCN, priority, message, t);
}
/**
- This generic form is intended to be used by wrappers.
+ This generic form is intended to be used by wrappers.
*/
public
void log(Priority priority, Object message) {
@@ -847,19 +843,18 @@
return;
}
if(priority.isGreaterOrEqual(this.getChainedPriority()))
- forcedLog(instanceFQCN, priority, message, null);
+ forcedLog(FQCN, priority, message, null);
}
/**
This is the most generic printing method. It is intended to be
- invoked by wrapper classes.
+ invoked by <b>wrapper</b> classes.
@param callerFQCN The wrapper class' fully qualified class name.
@param priority The priority of the logging request.
@param message The message of the logging request.
- @param t The throwable of the logging request, may be null.
- */
+ @param t The throwable of the logging request, may be null. */
public
void log(String callerFQCN, Priority priority, Object message, Throwable t) {
if(hierarchy.disable >= priority.level) {
@@ -996,7 +991,7 @@
public
void warn(Object message) {
if(this.isEnabledFor(Priority.WARN))
- forcedLog(instanceFQCN, Priority.WARN, message, null);
+ forcedLog(FQCN, Priority.WARN, message, null);
}
/**
@@ -1011,6 +1006,6 @@
public
void warn(Object message, Throwable t) {
if(this.isEnabledFor(Priority.WARN))
- forcedLog(instanceFQCN, Priority.WARN, message, t);
+ forcedLog(FQCN, Priority.WARN, message, t);
}
}
1.4 +1 -3 jakarta-log4j/org/apache/log4j/DefaultCategoryFactory.java
Index: DefaultCategoryFactory.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/DefaultCategoryFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultCategoryFactory.java 2001/01/24 10:24:05 1.3
+++ DefaultCategoryFactory.java 2001/02/03 22:39:22 1.4
@@ -11,13 +11,11 @@
class DefaultCategoryFactory implements CategoryFactory {
- private static final String DEFAULT_FQN = "org.apache.log4j.Category";
-
DefaultCategoryFactory() {
}
public
Category makeNewCategoryInstance(String name) {
- return new Category(name, DEFAULT_FQN);
+ return new Category(name);
}
}
1.13 +1 -1 jakarta-log4j/org/apache/log4j/PropertyConfigurator.java
Index: PropertyConfigurator.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/PropertyConfigurator.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- PropertyConfigurator.java 2001/01/26 09:05:00 1.12
+++ PropertyConfigurator.java 2001/02/03 22:39:22 1.13
@@ -171,7 +171,7 @@
<p>Similar to the root category syntax, each <i>appenderName</i>
(seperated by commas) will be attached to the named category.
- <p>See the <a href="../../manual.html#additivity">appender
+ <p>See the <a href="../../../../manual.html#additivity">appender
additivity rule</a> in the user manual for the meaning of the
<code>additivity</code> flag.
1.4 +4 -2 jakarta-log4j/org/apache/log4j/examples/MyCategory.java
Index: MyCategory.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/examples/MyCategory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MyCategory.java 2001/01/24 10:24:06 1.3
+++ MyCategory.java 2001/02/03 22:39:22 1.4
@@ -27,6 +27,8 @@
*/
public class MyCategory extends Category {
+ private static String FQCN = MyCategory.class.getName();
+
// It's enough to instantiate a factory once and for all.
private static MyCategoryFactory myFactory = new MyCategoryFactory();
@@ -80,8 +82,8 @@
/**
Just calls the parent constuctor.
*/
- public MyCategory(String name, String instanceFQCN) {
- super(name, instanceFQCN);
+ public MyCategory(String name) {
+ super(name);
}
1.4 +1 -3 jakarta-log4j/org/apache/log4j/examples/MyCategoryFactory.java
Index: MyCategoryFactory.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/examples/MyCategoryFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MyCategoryFactory.java 2001/01/24 10:24:06 1.3
+++ MyCategoryFactory.java 2001/02/03 22:39:22 1.4
@@ -18,8 +18,6 @@
@author Ceki Gülcü */
public class MyCategoryFactory implements CategoryFactory {
-
- private static String FQCN = MyCategory.class.getName();
/**
The constructor should be public as it will be called by
@@ -30,6 +28,6 @@
public
Category makeNewCategoryInstance(String name) {
- return new MyCategory(name, FQCN);
+ return new MyCategory(name);
}
}
1.4 +5 -2 jakarta-log4j/org/apache/log4j/examples/appserver/AppServerCategory.java
Index: AppServerCategory.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/examples/appserver/AppServerCategory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AppServerCategory.java 2001/01/24 10:24:08 1.3
+++ AppServerCategory.java 2001/02/03 22:39:23 1.4
@@ -45,6 +45,9 @@
* @author Paul Glezen
*/
public class AppServerCategory extends Category {
+
+ private static String FQCN = AppServerCategory.class.getName();
+
/** The name of the component using this category. */
protected String component;
@@ -80,9 +83,9 @@
* @param version the version identifier of the component. This may
* may be null.
*/
- protected AppServerCategory( String categoryName, String instanceFCQN, String hostname,
+ protected AppServerCategory( String categoryName, String hostname,
String server, String component, String version ) {
- super(categoryName, instanceFCQN);
+ super(categoryName);
this.hostname = hostname;
this.server = server;
1.3 +1 -3 jakarta-log4j/org/apache/log4j/examples/appserver/AppServerCategoryFactory.java
Index: AppServerCategoryFactory.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/examples/appserver/AppServerCategoryFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AppServerCategoryFactory.java 2001/01/24 10:24:09 1.2
+++ AppServerCategoryFactory.java 2001/02/03 22:39:23 1.3
@@ -27,8 +27,6 @@
*/
public class AppServerCategoryFactory implements CategoryFactory {
- private final String FCQN = AppServerCategory.class.getName();
-
/** The hostname on which this factory resides. This is
determined dynamically using the java.net.InetAddress
class. */
@@ -115,7 +113,7 @@
* using the information contained in this instance.
*/
public Category makeNewCategoryInstance(String name) {
- Category result = new AppServerCategory(name, FCQN, hostname, server,
+ Category result = new AppServerCategory(name, hostname, server,
component, version);
if ( messageBundle != null )
result.setResourceBundle( messageBundle );
1.5 +1 -3 jakarta-log4j/org/apache/log4j/spi/RootCategory.java
Index: RootCategory.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/spi/RootCategory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RootCategory.java 2001/01/24 22:41:25 1.4
+++ RootCategory.java 2001/02/03 22:39:23 1.5
@@ -27,15 +27,13 @@
*/
final public class RootCategory extends Category {
- final private static String FQCN = RootCategory.class.getName();
-
/**
The root category names itself as "root". However, the root
category cannot be retrieved by name.
*/
public
RootCategory(Priority priority) {
- super("root", FQCN);
+ super("root");
setPriority(priority);
}
1.8 +2 -2 jakarta-log4j/org/apache/log4j/xml/XMLLayout.java
Index: XMLLayout.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/xml/XMLLayout.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XMLLayout.java 2001/01/30 00:04:19 1.7
+++ XMLLayout.java 2001/02/03 22:39:23 1.8
@@ -107,9 +107,9 @@
String t = event.getThrowableInformation();
if(t != null) {
- buf.append("<log4j:throwable>");
+ buf.append("<log4j:throwable><![CDATA[");
buf.append(t);
- buf.append("</log4j:throwable>\r\n");
+ buf.append("]]></log4j:throwable>\r\n");
}
if(locationInfo) {
1.9 +9 -9 jakarta-log4j/org/apache/log4j/xml/examples/XCategory.java
Index: XCategory.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/xml/examples/XCategory.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XCategory.java 2001/01/26 13:47:11 1.8
+++ XCategory.java 2001/02/03 22:39:24 1.9
@@ -34,6 +34,8 @@
*/
public class XCategory extends Category implements OptionHandler {
+ final private static String FQCN = XCategory.class.getName();
+
// It's enough to instantiate a factory once and for all.
private static XFactory factory = new XFactory();
@@ -44,8 +46,8 @@
/**
Just calls the parent constuctor.
*/
- protected XCategory(String name, String instanceFQN) {
- super(name, instanceFQN);
+ protected XCategory(String name) {
+ super(name);
}
/**
@@ -105,7 +107,7 @@
if(hierarchy.isDisabled(XPriority.LETHAL_INT))
return;
if(XPriority.LETHAL.isGreaterOrEqual(this.getChainedPriority()))
- forcedLog(instanceFQCN, XPriority.LETHAL, message, t);
+ forcedLog(FQCN, XPriority.LETHAL, message, t);
}
/**
@@ -117,7 +119,7 @@
if(hierarchy.isDisabled(XPriority.LETHAL_INT))
return;
if(XPriority.LETHAL.isGreaterOrEqual(this.getChainedPriority()))
- forcedLog(instanceFQCN, XPriority.LETHAL, message, null);
+ forcedLog(FQCN, XPriority.LETHAL, message, null);
}
@@ -155,7 +157,7 @@
if(hierarchy.isDisabled(XPriority.TRACE_INT))
return;
if(XPriority.TRACE.isGreaterOrEqual(this.getChainedPriority()))
- forcedLog(instanceFQCN, XPriority.TRACE, message, t);
+ forcedLog(FQCN, XPriority.TRACE, message, t);
}
/**
@@ -167,7 +169,7 @@
if(hierarchy.isDisabled(XPriority.TRACE_INT))
return;
if(XPriority.TRACE.isGreaterOrEqual(this.getChainedPriority()))
- callAppenders(new LoggingEvent(instanceFQCN, this, XPriority.TRACE,
+ callAppenders(new LoggingEvent(FQCN, this, XPriority.TRACE,
message, null));
}
@@ -177,14 +179,12 @@
// CategoryFactory.
public static class XFactory implements CategoryFactory {
- static String INSTANCE_FQCN = XCategory.class.getName();
-
public XFactory() {
}
public
Category makeNewCategoryInstance(String name) {
- return new XCategory(name, INSTANCE_FQCN);
+ return new XCategory(name);
}
}
}