User: user57
Date: 02/01/03 16:33:39
Modified: src/main/org/jboss/system BootstrapLogger.java
Log:
o Added verbose property, to show categoryType (disabled by default)
to enable simply: run.sh -Dorg.jboss.system.BootstrapLogger.verbose=true
o Replaced Void.class usage with MAGIC_TOKEN for clarity
Revision Changes Path
1.4 +27 -7 jboss/src/main/org/jboss/system/BootstrapLogger.java
Index: BootstrapLogger.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/BootstrapLogger.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BootstrapLogger.java 2002/01/04 00:14:17 1.3
+++ BootstrapLogger.java 2002/01/04 00:33:39 1.4
@@ -17,7 +17,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class BootstrapLogger
{
@@ -67,6 +67,9 @@
/** The threashold used when uninitialized */
private static int threshold = INFO;
+ /** True to enable more verbose logging when log4j is not yet initialized. */
+ private static boolean verbose = false;
+
// Externalize behavior using properties
static
{
@@ -75,6 +78,7 @@
logInitFailures =
Boolean.getBoolean("org.jboss.system.BootstrapLogger.logInitFailures");
maxInitAttempts =
Integer.getInteger("org.jboss.system.BootstrapLogger.maxInitAttempts",
maxInitAttempts).intValue();
threshold =
Integer.getInteger("org.jboss.system.BootstrapLogger.threshold", threshold).intValue();
+ verbose = Boolean.getBoolean("org.jboss.system.BootstrapLogger.verbose");
}
catch(Exception e)
{
@@ -220,6 +224,14 @@
}
/**
+ * A magical token to tell _log() which log4j varaity to use.
+ *
+ * If this value is passed as the second argument to _log(), then
+ * the single argument log4j method will be called.
+ */
+ private static final Object MAGIC_TOKEN = new Object();
+
+ /**
* The log method is called by all explicit priority log methods
* that do not accept a Throwable.
*
@@ -229,7 +241,7 @@
*/
private void log(int idx, Object msg)
{
- _log(idx, msg, Void.class);
+ _log(idx, msg, MAGIC_TOKEN);
}
/**
@@ -247,7 +259,7 @@
}
/**
- * Consolidates both logging calls. If extends is Void.class then
+ * Consolidates both logging calls. If ex is MAGIC_TOKEN then
* the one argument log() method will be invoked, else the two
* arg version will be used.
*/
@@ -261,11 +273,19 @@
{
if (!isEnabledFor(idx)) return;
+ // construct the message to print
+ StringBuffer buff = new StringBuffer();
+ buff.append(PRIORITY_NAMES[idx]).append(" ");
+ if (verbose) {
+ buff.append("[").append(categoryType).append("] ");
+ }
+ buff.append(msg);
+
// Failed, dump the msg to System.out & print stack trace
- System.out.println(PRIORITY_NAMES[idx] + " " + msg);
+ System.out.println(buff);
- // If extends is not Void.class then it is an exception
- if (ex != Void.class) {
+ // If ex is not MAGIC_TOKEN then it is an exception
+ if (ex != MAGIC_TOKEN) {
if (ex != null) {
((Throwable)ex).printStackTrace();
}
@@ -283,7 +303,7 @@
{
Object pri = log4jPriorities[idx];
Object[] args;
- if (ex != Void.class) {
+ if (ex != MAGIC_TOKEN) {
args = new Object[] { pri, msg, ex };
log4jMethods[LOG_PRIORITY_MSG_EX].invoke(category, args);
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development