FileDocCategorySizeDatePackage
LoggerJDK14.javaAPI DocGlassfish v2 API18611Wed Jul 11 12:57:14 BST 2007com.sun.jdo.spi.persistence.utility.logging

LoggerJDK14

public class LoggerJDK14 extends Logger implements Logger
This 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.
author
Craig Russell
version
1.0

Fields Summary
protected String
sourceClassName
Class that issued logging call; set by inferCaller.
protected String
sourceMethodName
Method 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.

param
loggerName the full domain name of this logger
param
bundleName the bundle name for message translation

        super (loggerName, bundleName);
    
Methods Summary
protected java.util.logging.LevelconvertLevel(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.

param
level the level to convert
return
the Level instance corresponding to the int level

        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 voidfine(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.

param
msg The string message (or a key in the message catalog)
param
o Objects to be inserted into the message

        if (isLoggable(Level.FINE)) {
            inferCaller();
            logp(Level.FINE, sourceClassName, sourceMethodName, msg, o);
        }
    
public voidfine(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.

param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message

        if (isLoggable(Level.FINE)) {
            inferCaller();
            logp(Level.FINE, sourceClassName, sourceMethodName, msg, o1);
        }
    
public voidfine(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.

param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message
param
o2 A parameter to be inserted into the message

        if (isLoggable(Level.FINE)) {
            inferCaller();
            logp(Level.FINE, sourceClassName, sourceMethodName, msg, new Object[]{o1, o2});
        }
    
public voidfine(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.

param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message
param
o2 A parameter to be inserted into the message
param
o3 A parameter to be inserted into the message

        if (isLoggable(Level.FINE)) {
            inferCaller();
            logp(Level.FINE, sourceClassName, sourceMethodName, msg, new Object[]{o1, o2, o3});
        }
    
public voidfiner(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.

param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message
param
o2 A parameter to be inserted into the message
param
o3 A parameter to be inserted into the message

        if (isLoggable(Level.FINER)) {
            inferCaller();
            logp(Level.FINER, sourceClassName, sourceMethodName, msg, 
                 new Object[]{o1, o2, o3});
        }
    
public voidfiner(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.

param
msg The string message (or a key in the message catalog)
param
o Objects to be inserted into the message

        if (isLoggable(Level.FINER)) {
            inferCaller();
            logp(Level.FINER, sourceClassName, sourceMethodName, msg, o);
        }
    
public voidfiner(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.

param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message

        if (isLoggable(Level.FINER)) {
            inferCaller();
            logp(Level.FINER, sourceClassName, sourceMethodName, msg, o1);
        }
    
public voidfiner(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.

param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message
param
o2 A parameter to be inserted into the message

        if (isLoggable(Level.FINER)) {
            inferCaller();
            logp(Level.FINER, sourceClassName, sourceMethodName, msg, 
                 new Object[]{o1, o2});
        }
    
public voidfinest(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.

param
msg The string message (or a key in the message catalog)
param
o Objects to be inserted into the message

        if (isLoggable(Level.FINEST)) {
            inferCaller();
            logp(Level.FINEST, sourceClassName, sourceMethodName, msg, o);
        }
    
public voidfinest(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.

param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message

        if (isLoggable(Level.FINEST)) {
            inferCaller();
            logp(Level.FINEST, sourceClassName, sourceMethodName, msg, o1);
        }
    
public voidfinest(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.

param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message
param
o2 A parameter to be inserted into the message

        if (isLoggable(Level.FINEST)) {
            inferCaller();
            logp(Level.FINEST, sourceClassName, sourceMethodName, msg, 
                 new Object[]{o1, o2});
        }
    
public voidfinest(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.

param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message
param
o2 A parameter to be inserted into the message
param
o3 A parameter to be inserted into the message

        if (isLoggable(Level.FINEST)) {
            inferCaller();
            logp(Level.FINEST, sourceClassName, sourceMethodName, msg, 
                 new Object[]{o1, o2, o3});
        }
    
protected voidinferCaller()
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 booleanisLoggable()
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
whether logging is enabled at the fine level.

        return isLoggable(Level.FINE);
    
public booleanisLoggable(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
true if the given message level is currently being logged.
param
levelValue the level to check

        return isLoggable(convertLevel(levelValue));
    
protected booleanisLoggerClass(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.

param
className the class name to be checked.
return
true if the specified name denotes a logger class; false otherwise.

        return "com.sun.jdo.spi.persistence.utility.logging.LoggerJDK14". //NOI18N
            equals(className);
    
public voidlog(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.

param
level The level for this message
param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message

        Level lvl = convertLevel(level);
        if (isLoggable(lvl)) {
            inferCaller();
            logp(lvl, sourceClassName, sourceMethodName, msg, o1);
        }
    
public voidlog(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.

param
level The level for this message
param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message
param
o2 A parameter to be inserted into the message

        Level lvl = convertLevel(level);
        if (isLoggable(lvl)) {
            inferCaller();
            logp(lvl, sourceClassName, sourceMethodName, msg, new Object[]{o1, o2});
        }
    
public voidlog(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.

param
level The level for this message
param
msg The string message (or a key in the message catalog)
param
o1 A parameter to be inserted into the message
param
o2 A parameter to be inserted into the message
param
o3 A parameter to be inserted into the message

        Level lvl = convertLevel(level);
        if (isLoggable(lvl)) {
            inferCaller();
            logp(lvl, sourceClassName, sourceMethodName, msg, 
                 new Object[] {o1, o2, o3});
        }
    
public voidlog(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.

param
level The level for this message
param
msg The string message (or a key in the message catalog)
param
o Objects to be inserted into the message

        Level lvl = convertLevel(level);
        if (isLoggable(lvl)) {
            inferCaller();
            logp(lvl, sourceClassName, sourceMethodName, msg, o);
        }
    
public voidlog(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.

param
level The level for this message
param
msg The string message (or a key in the message catalog)

        Level lvl = convertLevel(level);
        if (isLoggable(lvl)) {
            inferCaller();
            logp(lvl, sourceClassName, sourceMethodName, msg);
        }
    
public voidlog(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.

param
level The level for this message
param
msg The string message (or a key in the message catalog)
param
thrown The exception to log

        Level lvl = convertLevel(level);
        if (isLoggable(lvl)) {
            inferCaller();
            logp(lvl, sourceClassName, sourceMethodName, msg, thrown);
        }
    
public java.lang.StringtoString()
Prepare a printable version of this instance.

return
the String representation of this object

        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();