LoggerJDK14public class LoggerJDK14 extends Logger implements LoggerThis class is used with JDK 1.4 (and higher) programs to log messages from
jdo components. It extends a java.util.logging.Logger which does
the actual logging. |
Fields Summary |
---|
protected String | sourceClassNameClass that issued logging call; set by inferCaller. | protected String | sourceMethodNameMethod that issued logging call; set by inferCaller. |
Constructors Summary |
---|
public LoggerJDK14(String loggerName, String bundleName)Creates new LoggerJDK14. The Thread context class loader or the
loader which loaded this class must be able to load the bundle.
super (loggerName, bundleName);
|
Methods Summary |
---|
protected java.util.logging.Level | convertLevel(int level)Convert an int level used by jdo logger to the Level instance used
by JDK 1.4 logger.
This is done to allow components to use logging outside the JDK 1.4
environment.
switch (level) {
case 300: return Level.FINEST;
case 400: return Level.FINER;
case 500: return Level.FINE;
case 700: return Level.CONFIG;
case 800: return Level.INFO;
case 900: return Level.WARNING;
case 1000: return Level.SEVERE;
default: return Level.CONFIG;
}
| public void | fine(java.lang.String msg, java.lang.Object[] o)Log a FINE message.
If the logger is currently enabled for the FINE message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINE)) {
inferCaller();
logp(Level.FINE, sourceClassName, sourceMethodName, msg, o);
}
| public void | fine(java.lang.String msg, java.lang.Object o1)Log a FINE message.
If the logger is currently enabled for the FINE message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINE)) {
inferCaller();
logp(Level.FINE, sourceClassName, sourceMethodName, msg, o1);
}
| public void | fine(java.lang.String msg, java.lang.Object o1, java.lang.Object o2)Log a FINE message.
If the logger is currently enabled for the FINE message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINE)) {
inferCaller();
logp(Level.FINE, sourceClassName, sourceMethodName, msg, new Object[]{o1, o2});
}
| public void | fine(java.lang.String msg, java.lang.Object o1, java.lang.Object o2, java.lang.Object o3)Log a FINE message.
If the logger is currently enabled for the FINE message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINE)) {
inferCaller();
logp(Level.FINE, sourceClassName, sourceMethodName, msg, new Object[]{o1, o2, o3});
}
| public void | finer(java.lang.String msg, java.lang.Object o1, java.lang.Object o2, java.lang.Object o3)Log a FINER message.
If the logger is currently enabled for the FINER message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINER)) {
inferCaller();
logp(Level.FINER, sourceClassName, sourceMethodName, msg,
new Object[]{o1, o2, o3});
}
| public void | finer(java.lang.String msg, java.lang.Object[] o)Log a FINER message.
If the logger is currently enabled for the FINER message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINER)) {
inferCaller();
logp(Level.FINER, sourceClassName, sourceMethodName, msg, o);
}
| public void | finer(java.lang.String msg, java.lang.Object o1)Log a FINER message.
If the logger is currently enabled for the FINER message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINER)) {
inferCaller();
logp(Level.FINER, sourceClassName, sourceMethodName, msg, o1);
}
| public void | finer(java.lang.String msg, java.lang.Object o1, java.lang.Object o2)Log a FINER message.
If the logger is currently enabled for the FINER message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINER)) {
inferCaller();
logp(Level.FINER, sourceClassName, sourceMethodName, msg,
new Object[]{o1, o2});
}
| public void | finest(java.lang.String msg, java.lang.Object[] o)Log a FINEST message.
If the logger is currently enabled for the FINEST message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINEST)) {
inferCaller();
logp(Level.FINEST, sourceClassName, sourceMethodName, msg, o);
}
| public void | finest(java.lang.String msg, java.lang.Object o1)Log a FINEST message.
If the logger is currently enabled for the FINEST message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINEST)) {
inferCaller();
logp(Level.FINEST, sourceClassName, sourceMethodName, msg, o1);
}
| public void | finest(java.lang.String msg, java.lang.Object o1, java.lang.Object o2)Log a FINEST message.
If the logger is currently enabled for the FINEST message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINEST)) {
inferCaller();
logp(Level.FINEST, sourceClassName, sourceMethodName, msg,
new Object[]{o1, o2});
}
| public void | finest(java.lang.String msg, java.lang.Object o1, java.lang.Object o2, java.lang.Object o3)Log a FINEST message.
If the logger is currently enabled for the FINEST message
level then the given message is forwarded to all the
registered output Handler objects.
if (isLoggable(Level.FINEST)) {
inferCaller();
logp(Level.FINEST, sourceClassName, sourceMethodName, msg,
new Object[]{o1, o2, o3});
}
| protected void | inferCaller()Method to infer the caller's class name and method name.
The method analyses the current stack trace, to find the method that
issued the logger call. It stores the callers class and method name
into fields sourceClassName and sourceMethodName.
// Get the stack trace.
StackTraceElement[] stack = (new Throwable()).getStackTrace();
// Search for the first frame before the "Logger" class.
for(int ix = 0; ix < stack.length; ix++) {
StackTraceElement frame = stack[ix];
String cname = frame.getClassName();
if (!isLoggerClass(cname)) {
// We've found the relevant frame.
sourceClassName = cname;
sourceMethodName = frame.getMethodName();
return;
}
}
| public boolean | isLoggable()Return whether logging is enabled
at the FINE level. This method
is not exact because to make it
accurately reflect the logging level
we would have to include the JDK 1.4
java.util.logging.Level class.
return isLoggable(Level.FINE);
| public boolean | isLoggable(int levelValue)Check if a message of the given level would actually be logged
by this logger. This check is based on the Loggers effective level,
which may be inherited from its parent.
return isLoggable(convertLevel(levelValue));
| protected boolean | isLoggerClass(java.lang.String className)This method is a helper method for {@link #inferCaller}. It returns
true if the specified class name denotes a logger class
that should be ignored when analysing the stack trace to infer the
caller of a log message.
return "com.sun.jdo.spi.persistence.utility.logging.LoggerJDK14". //NOI18N
equals(className);
| public void | log(int level, java.lang.String msg, java.lang.Object o1)Log a message.
If the logger is currently enabled for the message
level then the given message is forwarded to all the
registered output Handler objects.
Level lvl = convertLevel(level);
if (isLoggable(lvl)) {
inferCaller();
logp(lvl, sourceClassName, sourceMethodName, msg, o1);
}
| public void | log(int level, java.lang.String msg, java.lang.Object o1, java.lang.Object o2)Log a message.
If the logger is currently enabled for the message
level then the given message is forwarded to all the
registered output Handler objects.
Level lvl = convertLevel(level);
if (isLoggable(lvl)) {
inferCaller();
logp(lvl, sourceClassName, sourceMethodName, msg, new Object[]{o1, o2});
}
| public void | log(int level, java.lang.String msg, java.lang.Object o1, java.lang.Object o2, java.lang.Object o3)Log a message.
If the logger is currently enabled for the message
level then the given message is forwarded to all the
registered output Handler objects.
Level lvl = convertLevel(level);
if (isLoggable(lvl)) {
inferCaller();
logp(lvl, sourceClassName, sourceMethodName, msg,
new Object[] {o1, o2, o3});
}
| public void | log(int level, java.lang.String msg, java.lang.Object[] o)Log a message.
If the logger is currently enabled for the message
level then the given message is forwarded to all the
registered output Handler objects.
Level lvl = convertLevel(level);
if (isLoggable(lvl)) {
inferCaller();
logp(lvl, sourceClassName, sourceMethodName, msg, o);
}
| public void | log(int level, java.lang.String msg)Log a message.
If the logger is currently enabled for the message
level then the given message is forwarded to all the
registered output Handler objects.
Level lvl = convertLevel(level);
if (isLoggable(lvl)) {
inferCaller();
logp(lvl, sourceClassName, sourceMethodName, msg);
}
| public void | log(int level, java.lang.String msg, java.lang.Throwable thrown)Log a message.
If the logger is currently enabled for the message
level then the given message, and the exception dump,
is forwarded to all the
registered output Handler objects.
Level lvl = convertLevel(level);
if (isLoggable(lvl)) {
inferCaller();
logp(lvl, sourceClassName, sourceMethodName, msg, thrown);
}
| public java.lang.String | toString()Prepare a printable version of this instance.
StringBuffer buf = new StringBuffer ("LoggerJDK14: "); //NOI18N
buf.append (" name: "); buf.append (getName()); //NOI18N
buf.append (", super: "); buf.append (super.toString()); //NOI18N
buf.append (", logging level: "); buf.append (getLevel()); //NOI18N
return buf.toString();
|
|