Class AbstractLogger

java.lang.Object
com.sun.jdo.spi.persistence.utility.logging.AbstractLogger
All Implemented Interfaces:
Logger
Direct Known Subclasses:
LoggerJDK13

public abstract class AbstractLogger extends Object implements Logger
This class provides a default implementation of the com.sun.jdo.spi.persistence.utility.logging.Logger interface which implements most methods and/or delegates them to a few abstract methods which subclasses must override.
Version:
%I%
Author:
Rochelle Raccah
  • Constructor Details

    • AbstractLogger

      public AbstractLogger(String loggerName, String bundleName, ClassLoader loader)
      Creates a new AbstractLogger. The supplied 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
      loader - the loader used for looking up the bundle file and possibly the logging.properties or alternative file
  • Method Details

    • getMessages

      protected static ResourceBundle getMessages()
      Get the message bundle for the AbstractLogger itself.
    • toString

      public static String toString(int level)
      Return the string name of a level given its int value.
      Returns:
      a string representing the level
    • getBundle

      protected ResourceBundle getBundle()
      Get the message bundle for the named instance of the logger.
    • getLevel

      public int getLevel()
    • 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. This method does not delegate to isLoggable(FINE) for performance reasons.
      Specified by:
      isLoggable in interface Logger
      Returns:
      whether logging is enabled at the fine level.
    • 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 Logger's 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.
    • entering

      public void entering(String sourceClass, String sourceMethod)
      Log a method entry.

      This is a convenience method that can be used to log entry to a method. A LogRecord with message "ENTRY", log level FINER, and the given sourceMethod and sourceClass is logged.

      Specified by:
      entering in interface Logger
      Parameters:
      sourceClass - name of class that issued the logging request
      sourceMethod - name of method that is being entered
    • entering

      public void entering(String sourceClass, String sourceMethod, Object param1)
      Log a method entry, with one parameter.

      This is a convenience method that can be used to log entry to a method. A LogRecord with message "ENTRY {0}", log level FINER, and the given sourceMethod, sourceClass, and parameter is logged.

      Specified by:
      entering in interface Logger
      Parameters:
      sourceClass - name of class that issued the logging request
      sourceMethod - name of method that is being entered
      param1 - parameter to the method being entered
    • entering

      public void entering(String sourceClass, String sourceMethod, Object[] params)
      Log a method entry, with an array of parameters.

      This is a convenience method that can be used to log entry to a method. A LogRecord with message "ENTRY" (followed by a format {N} indicator for each entry in the parameter array), log level FINER, and the given sourceMethod, sourceClass, and parameters is logged.

      Specified by:
      entering in interface Logger
      Parameters:
      sourceClass - name of class that issued the logging request
      sourceMethod - name of method that is being entered
      params - array of parameters to the method being entered
    • exiting

      public void exiting(String sourceClass, String sourceMethod)
      Log a method return.

      This is a convenience method that can be used to log returning from a method. A LogRecord with message "RETURN", log level FINER, and the given sourceMethod and sourceClass is logged.

      Specified by:
      exiting in interface Logger
      Parameters:
      sourceClass - name of class that issued the logging request
      sourceMethod - name of the method
    • exiting

      public void exiting(String sourceClass, String sourceMethod, Object result)
      Log a method return, with result object.

      This is a convenience method that can be used to log returning from a method. A LogRecord with message "RETURN {0}", log level FINER, and the gives sourceMethod, sourceClass, and result object is logged.

      Specified by:
      exiting in interface Logger
      Parameters:
      sourceClass - name of class that issued the logging request
      sourceMethod - name of the method
      result - Object that is being returned
    • throwing

      public void throwing(String sourceClass, String sourceMethod, Throwable thrown)
      Log throwing an exception.

      This is a convenience method to log that a method is terminating by throwing an exception. The logging is done using the FINER level.

      If the logger is currently enabled for the given message level then the given arguments are stored in a LogRecord which is forwarded to all registered output handlers. The LogRecord's message is set to "THROW".

      Note that the thrown argument is stored in the LogRecord thrown property, rather than the LogRecord parameters property. Thus is it processed specially by output Formatters and is not treated as a formatting parameter to the LogRecord message property.

      Specified by:
      throwing in interface Logger
      Parameters:
      sourceClass - name of class that issued the logging request
      sourceMethod - name of the method.
      thrown - The Throwable that is being thrown.
    • severe

      public void severe(String msg)
      Log a SEVERE message.

      If the logger is currently enabled for the SEVERE message level then the given message is forwarded to all the registered output Handler objects.

      Specified by:
      severe in interface Logger
      Parameters:
      msg - The string message (or a key in the message catalog)
    • warning

      public void warning(String msg)
      Log a WARNING message.

      If the logger is currently enabled for the WARNING message level then the given message is forwarded to all the registered output Handler objects.

      Specified by:
      warning in interface Logger
      Parameters:
      msg - The string message (or a key in the message catalog)
    • info

      public void info(String msg)
      Log an INFO message.

      If the logger is currently enabled for the INFO message level then the given message is forwarded to all the registered output Handler objects.

      Specified by:
      info in interface Logger
      Parameters:
      msg - The string message (or a key in the message catalog)
    • config

      public void config(String msg)
      Log a CONFIG message.

      If the logger is currently enabled for the CONFIG message level then the given message is forwarded to all the registered output Handler objects.

      Specified by:
      config in interface Logger
      Parameters:
      msg - The string message (or a key in the message catalog)
    • 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, 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[] 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, 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 abstract 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
    • fine

      public void fine(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:
      fine in interface Logger
      Parameters:
      msg - The string message (or a key in the message catalog)
    • 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[] 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, 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)
      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)
    • 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)
      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)
    • 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
    • getName

      public String getName()
      Get the name for this logger.
      Specified by:
      getName in interface Logger
      Returns:
      logger name. Will be null for anonymous Loggers.
    • toString

      public String toString()
      Prepare a printable version of this instance.
      Overrides:
      toString in class Object
      Returns:
      the String representation of this object
    • getMessage

      protected String getMessage(String message)
      This method returns a string from the bundle file if possible, treating the message argument as the key. If no such key is found in the bundle, the message itself is returned.
      Parameters:
      message - the message which is used as a key to search the bundle
      Returns:
      a message either used as itself or searched in the bundle file.
    • getMessageWithPrefix

      protected String getMessageWithPrefix(int level, String message)
      This method returns a string with a formatted prefix which depends on the level.
      Parameters:
      level - the level to print
      message - the message to print
      Returns:
      a formatted string with a level prefix.
      See Also:
    • logInternal

      protected abstract void logInternal(int level, String message)
      This method does the actual logging. It is expected that if a check for isLoggable is desired for performance reasons, it has already been done, as it should not be done here.
      Parameters:
      level - the level to print
      message - the message to print