psdi.app.ci

Class CILogger

  • java.lang.Object
    • psdi.app.ci.CILogger


  • public class CILogger
    extends java.lang.Object
    CiacLogger is a thin wrapper over MXLogger that adds some convenience features. These features are
    • Parameters for class name and method name
    • Parameters for printing the input parameters to a method
    • A parameter for printing the output value of a method

    CiacLogger uses the following logging levels, from highest to lowest:

    • Fatal
    • Error
    • Warn
    • Info
    • Debug
    If a particular level is enabled, then messages at that level and all higher levels will go to the log. For any levels not enabled, messages written at those levels will not appear in the log. This allows the user to set the logging to the desired level of verbosity.

    The isLEVEL() methods are included to improve performance. Before calling one of the logging methods with parameters that would require string concatenation, object creation, or other expensive operations, the corresponding isLEVEL() call can be made first. For example:

     if (log.isDebug()) {
         log.debug(CLASSNAME, METHOD, "Value " + value + " for key " + key + " is within range.");
     }
     
    In the code sample above, calling isDebug() prevents the string concatenation from occuring when the Debug level is not enabled, thus improving performance.
    • Constructor Summary

      Constructors 
      Constructor and Description
      CILogger(MXLogger logger)
      Creates an CiacLogger from an MXLogger
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void debug(java.lang.String className, java.lang.String method, java.lang.String msg)
      Writes a message to the log at Debug level.
      void debug(java.lang.String className, java.lang.String method, java.lang.String msg, java.lang.Throwable t)
      Writes a message to the log at Debug level, along with a Throwable.
      void debugEntry(java.lang.String className, java.lang.String method)
      Logs the entry to a method that has no input parameters.
      void debugEntry(java.lang.String className, java.lang.String method, java.lang.Object param1)
      Logs the entry to a method that has one input parameter.
      void debugEntry(java.lang.String className, java.lang.String method, java.lang.Object[] params)
      Writes a message to the log at Debug level indicating that a new method has just been entered.
      void debugEntry(java.lang.String className, java.lang.String method, java.lang.Object param1, java.lang.Object param2)
      Logs the entry to a method that has two input parameters.
      void debugEntry(java.lang.String className, java.lang.String method, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3)
      Logs the entry to a method that has three input parameters.
      void debugEntry(java.lang.String className, java.lang.String method, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4)
      Logs the entry to a method that has four input parameters.
      void debugExit(java.lang.String className, java.lang.String method)
      Writes a message to the log at Debug level indicating the normal exit point of a method that returns void.
      void debugExit(java.lang.String className, java.lang.String method, java.lang.Object returnValue)
      Writes a message to the log at Debug level indicating the normal exit point of a method that returns a value.
      void error(java.lang.String className, java.lang.String method, java.lang.String msg)
      Writes a message to the log at Error level.
      void error(java.lang.String className, java.lang.String method, java.lang.String msg, java.lang.Throwable t)
      Writes a message to the log at Error level, along with a Throwable.
      void fatal(java.lang.String className, java.lang.String method, java.lang.String msg)
      Writes a message to the log at Fatal level.
      void fatal(java.lang.String className, java.lang.String method, java.lang.String msg, java.lang.Throwable t)
      Writes a message to the log at Fatal level, along with a Throwable.
      void info(java.lang.String className, java.lang.String method, java.lang.String msg)
      Writes a message to the log at Info level.
      void info(java.lang.String className, java.lang.String method, java.lang.String msg, java.lang.Throwable t)
      Writes a message to the log at Info level, along with a Throwable.
      boolean isDebug()
      Indicates whether the Debug level is enabled.
      boolean isError()
      Indicates whether the Error level is enabled.
      boolean isInfo()
      Indicates whether the Info level is enabled.
      boolean isWarn()
      Indicates whether the Warn level is enabled.
      void warn(java.lang.String className, java.lang.String method, java.lang.String msg)
      Writes a message to the log at Warn level.
      void warn(java.lang.String className, java.lang.String method, java.lang.String msg, java.lang.Throwable t)
      Writes a message to the log at Warn level, along with a Throwable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CILogger

        public CILogger(MXLogger logger)
        Creates an CiacLogger from an MXLogger
    • Method Detail

      • isDebug

        public boolean isDebug()
        Indicates whether the Debug level is enabled.
        Returns:
        true if Debug and higher levels are enabled; false otherwise
      • isInfo

        public boolean isInfo()
        Indicates whether the Info level is enabled.
        Returns:
        true if Info and higher levels are enabled; false otherwise
      • isWarn

        public boolean isWarn()
        Indicates whether the Warn level is enabled.
        Returns:
        true if Warn and higher levels are enabled; false otherwise
      • isError

        public boolean isError()
        Indicates whether the Error level is enabled.
        Returns:
        true if Error and higher levels are enabled; false otherwise
      • debug

        public void debug(java.lang.String className,
                          java.lang.String method,
                          java.lang.String msg)
        Writes a message to the log at Debug level.
        Parameters:
        className - the name of the class that contains this call
        method - the name of the method that contains this call
        msg - the message to be written to the log
      • debug

        public void debug(java.lang.String className,
                          java.lang.String method,
                          java.lang.String msg,
                          java.lang.Throwable t)
        Writes a message to the log at Debug level, along with a Throwable.
        Parameters:
        className - the name of the class that contains this call
        method - the name of the method that contains this call
        msg - the message to be written to the log
        t - a Throwable related to the message
      • info

        public void info(java.lang.String className,
                         java.lang.String method,
                         java.lang.String msg)
        Writes a message to the log at Info level.
        Parameters:
        className - the name of the class that contains this call
        method - the name of the method that contains this call
        msg - the message to be written to the log
      • info

        public void info(java.lang.String className,
                         java.lang.String method,
                         java.lang.String msg,
                         java.lang.Throwable t)
        Writes a message to the log at Info level, along with a Throwable.
        Parameters:
        className - the name of the class that contains this call
        method - the name of the method that contains this call
        msg - the message to be written to the log
        t - a Throwable related to the message
      • warn

        public void warn(java.lang.String className,
                         java.lang.String method,
                         java.lang.String msg)
        Writes a message to the log at Warn level.
        Parameters:
        className - the name of the class that contains this call
        method - the name of the method that contains this call
        msg - the message to be written to the log
      • warn

        public void warn(java.lang.String className,
                         java.lang.String method,
                         java.lang.String msg,
                         java.lang.Throwable t)
        Writes a message to the log at Warn level, along with a Throwable.
        Parameters:
        className - the name of the class that contains this call
        method - the name of the method that contains this call
        msg - the message to be written to the log
        t - a Throwable related to the message
      • error

        public void error(java.lang.String className,
                          java.lang.String method,
                          java.lang.String msg)
        Writes a message to the log at Error level.
        Parameters:
        className - the name of the class that contains this call
        method - the name of the method that contains this call
        msg - the message to be written to the log
      • error

        public void error(java.lang.String className,
                          java.lang.String method,
                          java.lang.String msg,
                          java.lang.Throwable t)
        Writes a message to the log at Error level, along with a Throwable.
        Parameters:
        className - the name of the class that contains this call
        method - the name of the method that contains this call
        msg - the message to be written to the log
        t - a Throwable related to the message
      • fatal

        public void fatal(java.lang.String className,
                          java.lang.String method,
                          java.lang.String msg)
        Writes a message to the log at Fatal level.
        Parameters:
        className - the name of the class that contains this call
        method - the name of the method that contains this call
        msg - the message to be written to the log
      • fatal

        public void fatal(java.lang.String className,
                          java.lang.String method,
                          java.lang.String msg,
                          java.lang.Throwable t)
        Writes a message to the log at Fatal level, along with a Throwable.
        Parameters:
        className - the name of the class that contains this call
        method - the name of the method that contains this call
        msg - the message to be written to the log
        t - a Throwable related to the message
      • debugEntry

        public void debugEntry(java.lang.String className,
                               java.lang.String method,
                               java.lang.Object[] params)
        Writes a message to the log at Debug level indicating that a new method has just been entered. The output message will include the class and method name that is being entered, as well as the value of each input parameter of the entered method. This method is intended to be called at the very top of the enclosing method.

        This is the most general purpose of the debugEntry() methods. In practice, this method is only necessary for methods that take more than four parameters, as there are convenience methods for use with methods that take four or fewer params. The convenience methods will also give better performance.

        Parameters:
        className - the name of the class containing the method that is being entered
        method - the name of the method that is being entered
        params - an array of the parameters to the method being entered. May be null or empty.
      • debugEntry

        public void debugEntry(java.lang.String className,
                               java.lang.String method)
        Logs the entry to a method that has no input parameters. This is a convenience method that does the same thing as CILogger.debugEntry(String,String,Object[]).
        Parameters:
        className - the name of the class containing the method that is being entered
        method - the name of the method that is being entered
      • debugEntry

        public void debugEntry(java.lang.String className,
                               java.lang.String method,
                               java.lang.Object param1)
        Logs the entry to a method that has one input parameter. This is a convenience method that does the same thing as general method CILogger.debugEntry(String,String,Object[]).
        Parameters:
        className - the name of the class containing the method that is being entered
        method - the name of the method that is being entered
        param1 - the first parameter of the method being entered.
      • debugEntry

        public void debugEntry(java.lang.String className,
                               java.lang.String method,
                               java.lang.Object param1,
                               java.lang.Object param2)
        Logs the entry to a method that has two input parameters. This is a convenience method that does the same thing as CILogger.debugEntry(String,String,Object[]).
        Parameters:
        className - the name of the class containing the method that is being entered
        method - the name of the method that is being entered
        param1 - the first parameter of the method being entered.
        param2 - the second parameter of the method being entered.
      • debugEntry

        public void debugEntry(java.lang.String className,
                               java.lang.String method,
                               java.lang.Object param1,
                               java.lang.Object param2,
                               java.lang.Object param3)
        Logs the entry to a method that has three input parameters. This is a convenience method that does the same thing as CILogger.debugEntry(String,String,Object[]).
        Parameters:
        className - the name of the class containing the method that is being entered
        method - the name of the method that is being entered
        param1 - the first parameter of the method being entered.
        param2 - the second parameter of the method being entered.
        param3 - the third parameter of the method being entered.
      • debugEntry

        public void debugEntry(java.lang.String className,
                               java.lang.String method,
                               java.lang.Object param1,
                               java.lang.Object param2,
                               java.lang.Object param3,
                               java.lang.Object param4)
        Logs the entry to a method that has four input parameters. This is a convenience method that does the same thing as CILogger.debugEntry(String,String,Object[]).
        Parameters:
        className - the name of the class containing the method that is being entered
        method - the name of the method that is being entered
        param1 - the first parameter of the method being entered.
        param2 - the second parameter of the method being entered.
        param3 - the third parameter of the method being entered.
        param4 - the fourth parameter of the method being entered.
      • debugExit

        public void debugExit(java.lang.String className,
                              java.lang.String method,
                              java.lang.Object returnValue)
        Writes a message to the log at Debug level indicating the normal exit point of a method that returns a value. The output message will include the class and method name of the method that is being exited, as well as the method's return value. This method is intended to be the very last line of the method being exited, except for the return line.

        NOTE: This method should be used for normal exit only (before a return statement), and NOT before a throw statement. If there are multiple return statements in a method, this method should be called before each one.

        For methods that return void, use CILogger.debugExit(String,String) instead. This will make it possible to distinguish in the log between methods returning null and methods that return void.

        Parameters:
        className - the name of the class containing the method that is being exited
        method - the name of the method that is being exited
        returnValue - the value being returned by the method being exited
      • debugExit

        public void debugExit(java.lang.String className,
                              java.lang.String method)
        Writes a message to the log at Debug level indicating the normal exit point of a method that returns void. The output message will include the class and method name of the method that is being exited. This method is intended to be the very last line of code of the method being exited (except for the return statement, if any).

        NOTE: This method should be used for normal exit only (before a return statement or at the bottom of the method), and NOT before a throw statement. If there are multiple return statements, this method should be called just before each one, as well as at the bottom of the method.

        For methods that return a value, even if it is null, use CILogger.debugExit(String,String,Object) instead. This will make it possible to distinguish in the log between methods returning null and methods that return void.

        Parameters:
        className - the name of the class containing the method that is being exited
        method - the name of the method that is being exited