com.sun.jdo.spi.persistence.utility.logging
Class LoggerJDK14

java.lang.Object
  extended by java.util.logging.Logger
      extended by com.sun.jdo.spi.persistence.utility.logging.LoggerJDK14
All Implemented Interfaces:
Logger

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.

Version:
1.0
Author:
Craig Russell

Field Summary
protected  String sourceClassName
          Class that issued logging call; set by inferCaller.
protected  String sourceMethodName
          Method that issued logging call; set by inferCaller.
 
Fields inherited from class java.util.logging.Logger
global, GLOBAL_LOGGER_NAME
 
Fields inherited from interface com.sun.jdo.spi.persistence.utility.logging.Logger
ALL, CONFIG, FINE, FINER, FINEST, INFO, OFF, SEVERE, WARNING
 
Constructor Summary
LoggerJDK14(String loggerName, String bundleName)
          Creates new LoggerJDK14.
 
Method Summary
protected  Level convertLevel(int level)
          Convert an int level used by jdo logger to the Level instance used by JDK 1.4 logger.
 void fine(String msg, Object o1)
          Log a FINE message.
 void fine(String msg, Object[] o)
          Log a FINE message.
 void fine(String msg, Object o1, Object o2)
          Log a FINE message.
 void fine(String msg, Object o1, Object o2, Object o3)
          Log a FINE message.
 void finer(String msg, Object o1)
          Log a FINER message.
 void finer(String msg, Object[] o)
          Log a FINER message.
 void finer(String msg, Object o1, Object o2)
          Log a FINER message.
 void finer(String msg, Object o1, Object o2, Object o3)
          Log a FINER message.
 void finest(String msg, Object o1)
          Log a FINEST message.
 void finest(String msg, Object[] o)
          Log a FINEST message.
 void finest(String msg, Object o1, Object o2)
          Log a FINEST message.
 void finest(String msg, Object o1, Object o2, Object o3)
          Log a FINEST message.
protected  void inferCaller()
          Method to infer the caller's class name and method name.
 boolean isLoggable()
          Return whether logging is enabled at the FINE level.
 boolean isLoggable(int levelValue)
          Check if a message of the given level would actually be logged by this logger.
protected  boolean isLoggerClass(String className)
          This method is a helper method for inferCaller().
 void log(int level, String msg)
          Log a message.
 void log(int level, String msg, Object o1)
          Log a message.
 void log(int level, String msg, Object[] o)
          Log a message.
 void log(int level, String msg, Object o1, Object o2)
          Log a message.
 void log(int level, String msg, Object o1, Object o2, Object o3)
          Log a message.
 void log(int level, String msg, Throwable thrown)
          Log a message.
 String toString()
          Prepare a printable version of this instance.
 
Methods inherited from class java.util.logging.Logger
addHandler, config, entering, entering, entering, exiting, exiting, fine, finer, finest, getAnonymousLogger, getAnonymousLogger, getFilter, getHandlers, getLevel, getLogger, getLogger, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, info, isLoggable, log, log, log, log, log, logp, logp, logp, logp, logrb, logrb, logrb, logrb, removeHandler, setFilter, setLevel, setParent, setUseParentHandlers, severe, throwing, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sun.jdo.spi.persistence.utility.logging.Logger
config, entering, entering, entering, exiting, exiting, fine, finer, finest, getName, info, severe, throwing, warning
 

Field Detail

sourceClassName

protected String sourceClassName
Class that issued logging call; set by inferCaller.


sourceMethodName

protected String sourceMethodName
Method that issued logging call; set by inferCaller.

Constructor Detail

LoggerJDK14

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.

Parameters:
loggerName - the full domain name of this logger
bundleName - the bundle name for message translation
Method Detail

isLoggable

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.

Specified by:
isLoggable in interface Logger
Returns:
whether logging is enabled at the fine level.

fine

public void fine(String msg,
                 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.

Specified by:
fine in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o - Objects to be inserted into the message

fine

public void fine(String msg,
                 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.

Specified by:
fine in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message

fine

public void fine(String msg,
                 Object o1,
                 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.

Specified by:
fine in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message
o2 - A parameter to be inserted into the message

fine

public void fine(String msg,
                 Object o1,
                 Object o2,
                 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.

Specified by:
fine in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message
o2 - A parameter to be inserted into the message
o3 - A parameter to be inserted into the message

finer

public void finer(String msg,
                  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.

Specified by:
finer in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o - Objects to be inserted into the message

finer

public void finer(String msg,
                  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.

Specified by:
finer in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message

finer

public void finer(String msg,
                  Object o1,
                  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.

Specified by:
finer in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message
o2 - A parameter to be inserted into the message

finer

public void finer(String msg,
                  Object o1,
                  Object o2,
                  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.

Specified by:
finer in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message
o2 - A parameter to be inserted into the message
o3 - A parameter to be inserted into the message

finest

public void finest(String msg,
                   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.

Specified by:
finest in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o - Objects to be inserted into the message

finest

public void finest(String msg,
                   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.

Specified by:
finest in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message

finest

public void finest(String msg,
                   Object o1,
                   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.

Specified by:
finest in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message
o2 - A parameter to be inserted into the message

finest

public void finest(String msg,
                   Object o1,
                   Object o2,
                   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.

Specified by:
finest in interface Logger
Parameters:
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message
o2 - A parameter to be inserted into the message
o3 - A parameter to be inserted into the message

toString

public String toString()
Prepare a printable version of this instance.

Overrides:
toString in class Object
Returns:
the String representation of this object

log

public void log(int level,
                String msg,
                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.

Specified by:
log in interface Logger
Parameters:
level - The level for this message
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message

log

public void log(int level,
                String msg,
                Object o1,
                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.

Specified by:
log in interface Logger
Parameters:
level - The level for this message
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message
o2 - A parameter to be inserted into the message

log

public void log(int level,
                String msg,
                Object o1,
                Object o2,
                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.

Specified by:
log in interface Logger
Parameters:
level - The level for this message
msg - The string message (or a key in the message catalog)
o1 - A parameter to be inserted into the message
o2 - A parameter to be inserted into the message
o3 - A parameter to be inserted into the message

log

public void log(int level,
                String msg,
                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.

Specified by:
log in interface Logger
Parameters:
level - The level for this message
msg - The string message (or a key in the message catalog)
o - Objects to be inserted into the message

log

public void log(int level,
                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.

Specified by:
log in interface Logger
Parameters:
level - The level for this message
msg - The string message (or a key in the message catalog)

log

public void log(int level,
                String msg,
                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.

Specified by:
log in interface Logger
Parameters:
level - The level for this message
msg - The string message (or a key in the message catalog)
thrown - The exception to log

isLoggable

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.

Specified by:
isLoggable in interface Logger
Parameters:
levelValue - the level to check
Returns:
true if the given message level is currently being logged.

convertLevel

protected 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.

Parameters:
level - the level to convert
Returns:
the Level instance corresponding to the int level

inferCaller

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.


isLoggerClass

protected boolean isLoggerClass(String className)
This method is a helper method for 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.

Parameters:
className - the class name to be checked.
Returns:
true if the specified name denotes a logger class; false otherwise.


Copyright © 2012 GlassFish Community. All Rights Reserved.