Class DermisLogger


  • public class DermisLogger
    extends java.lang.Object
    Class to get a pre-defined message from a exceptions.properties file in this library
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addResourceBundle​(java.lang.String key, java.util.ResourceBundle resourceBundle)
      Add Resource bundle to map
      static void endPerformTimer​(java.lang.String message)
      Stops a timer that was previously started by calling DermisLogger.startPerformTimer().
      static java.lang.String getString​(java.lang.String key)
      Retrieve message with default locale (en_EN) If given key isn't found in the resources, returns the original key
      static java.lang.String getString​(java.lang.String resourceID, java.lang.String[] args)
      Retrieve message with default locale (en_EN) for the given resourceID and arguments.
      static void logAuditMessage​(java.lang.Class class1, java.lang.String message, java.lang.String[] arguments)
      Log message at the DEBUG level - This is for audit purposes.
      static void logErrorAndDebug​(java.lang.Class clazz, java.lang.String errorMsg, java.lang.Exception e)
      Logs the given string at error level and a given string plus the given cause at debug level This method should be used for logging when the underlying exception may contain user data as no user data should be logged at above debug level
      static void logErrorAndDebug​(java.lang.Class clazz, java.lang.String errorMsg, java.lang.String debugMsg)
      Logs the given error and debug message at error and debug level respectively This method should be used for logging when we want to log message containing user data as no user data should be logged at above debug level
      static void logMessage​(java.lang.Class class1, int severity, java.lang.String resourceID)
      Log message at the given severity level, against the given resourceID.
      static void logMessage​(java.lang.Class class1, int severity, java.lang.String resourceID, java.lang.String[] args)
      Log message at the given severity level, against the given resourceID and arguments.
      static void logMessage​(java.lang.Class class1, int severity, java.lang.String resourceID, java.lang.String[] args, java.lang.Throwable cause)
      Log message at the given severity level, against the given resourceID and arguments.
      static long logPerformance​(java.lang.Class class1, java.lang.String message, java.lang.String[] arguments, boolean diff, long timeStamp)
      Log message at the TRACE level - This is for performance logging purposes.
      static java.lang.String replaceString​(java.lang.String message, java.lang.String[] args)  
      static void startPerformTimer​(java.lang.String message)
      Starts a timer which can be used to track how long an operation takes.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • addResourceBundle

        public static void addResourceBundle​(java.lang.String key,
                                             java.util.ResourceBundle resourceBundle)
        Add Resource bundle to map
        Parameters:
        key -
        resourceBundle -
      • getString

        public static java.lang.String getString​(java.lang.String key)
        Retrieve message with default locale (en_EN) If given key isn't found in the resources, returns the original key
        Parameters:
        key - key of message
        Returns:
        the translated resource string
      • logMessage

        public static void logMessage​(java.lang.Class class1,
                                      int severity,
                                      java.lang.String resourceID,
                                      java.lang.String[] args)
        Log message at the given severity level, against the given resourceID and arguments.
        Parameters:
        class1 - Class for the logger
        severity - severity of the log
        resourceID - resource bundle identifier
        args - necessary arguments for the error message
      • logMessage

        public static void logMessage​(java.lang.Class class1,
                                      int severity,
                                      java.lang.String resourceID,
                                      java.lang.String[] args,
                                      java.lang.Throwable cause)
        Log message at the given severity level, against the given resourceID and arguments.
        Parameters:
        class1 - Class for the logger
        severity - severity of the log
        resourceID - resource bundle identifier
        args - necessary arguments for the error message
        cause - root cause of exception
      • logMessage

        public static void logMessage​(java.lang.Class class1,
                                      int severity,
                                      java.lang.String resourceID)
        Log message at the given severity level, against the given resourceID.
        Parameters:
        class1 - Class for the logger
        severity - severity of the log
        resourceID - resource bundle identifier
      • logAuditMessage

        public static void logAuditMessage​(java.lang.Class class1,
                                           java.lang.String message,
                                           java.lang.String[] arguments)
        Log message at the DEBUG level - This is for audit purposes.
        Parameters:
        class1 - Class for the logger
        message - Message to be logged
        arguments - necessary arguments for the audit message
      • logPerformance

        public static long logPerformance​(java.lang.Class class1,
                                          java.lang.String message,
                                          java.lang.String[] arguments,
                                          boolean diff,
                                          long timeStamp)
        Log message at the TRACE level - This is for performance logging purposes.
        Parameters:
        class1 - Class for the logger
        message - Message to be logged
        arguments - necessary arguments for the audit message
        diff - necessary to indicate if the message is beginning or end of performance log
      • startPerformTimer

        public static void startPerformTimer​(java.lang.String message)
        Starts a timer which can be used to track how long an operation takes. Each timer have a unique name, and may have up to 100 timers running at time. When you call DermisLogger.endPerformTimer() with the same name, the program will output the time, in milliseconds, that elapsed since the timer was started.
        Parameters:
        message - The name to give the new timer. This will identify the timer; use the same name when calling ermisLogger.endPerformTimer() to stop the timer and print the output in log of type trace.
      • endPerformTimer

        public static void endPerformTimer​(java.lang.String message)
        Stops a timer that was previously started by calling DermisLogger.startPerformTimer().
        Parameters:
        message - The name of the timer to stop. Once stopped, the elapsed time is automatically logged into log file of type trace.
      • getString

        public static java.lang.String getString​(java.lang.String resourceID,
                                                 java.lang.String[] args)
        Retrieve message with default locale (en_EN) for the given resourceID and arguments.
        Parameters:
        resourceID - resource bundle identifier
        args - necessary arguments for the error message
        Returns:
        the translated resource string
      • replaceString

        public static java.lang.String replaceString​(java.lang.String message,
                                                     java.lang.String[] args)
      • logErrorAndDebug

        public static void logErrorAndDebug​(java.lang.Class clazz,
                                            java.lang.String errorMsg,
                                            java.lang.Exception e)
        Logs the given string at error level and a given string plus the given cause at debug level This method should be used for logging when the underlying exception may contain user data as no user data should be logged at above debug level
        Parameters:
        clazz - Class for the logger
        errorMsg - The string to be logged as error
        e - The actual exception
      • logErrorAndDebug

        public static void logErrorAndDebug​(java.lang.Class clazz,
                                            java.lang.String errorMsg,
                                            java.lang.String debugMsg)
        Logs the given error and debug message at error and debug level respectively This method should be used for logging when we want to log message containing user data as no user data should be logged at above debug level
        Parameters:
        clazz - Class for the logger
        errorMsg - The string to be logged as error
        debugMsg - The actual exception