edu.northwestern.at.utils.logger

## Class LoggerUtils

- java.lang.Object
- - edu.northwestern.at.utils.logger.LoggerUtils

-     public class LoggerUtils
      extends java.lang.Object

  Logger utilities.

  This static class provides various utility methods for writing information to a log file using a `Logger`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DATE_TIME_FORMAT` Date and time format for display.
    `static java.text.SimpleDateFormat` | `DATE_TIME_FORMATTER`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `LoggerUtils()` Allow overrides but not instantiation.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `getFormattedCurrentDateAndTime()` Get formatted version of current date and time.
    `static void` | `logArray(Logger logger, int level, java.lang.String arrayLabel, java.lang.Object[] array)` Debugging support -- Print contents of an array.
    `static void` | `logByteArray(Logger logger, int logLevelTitle, int logLevelData, java.lang.String arrayLabel, byte[] bytes, int nBytes, int pctPrintable)` Logs an array of bytes in string or hex dump format.
    `static <K,V> void` | `logMap(Logger logger, int level, java.lang.String mapLabel, java.util.Map<K,V> map)` Log contents of a map (HashMap, TreeMap, etc.).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DATE_TIME_FORMAT

          public static final java.lang.String DATE_TIME_FORMAT

      Date and time format for display.
      See Also:
        Constant Field Values

    - #### DATE_TIME_FORMATTER

          public static final java.text.SimpleDateFormat DATE_TIME_FORMATTER

  - ### Constructor Detail

    - #### LoggerUtils

          protected LoggerUtils()

      Allow overrides but not instantiation.

  - ### Method Detail

    - #### logByteArray

          public static void logByteArray(Logger logger,
                          int logLevelTitle,
                          int logLevelData,
                          java.lang.String arrayLabel,
                          byte[] bytes,
                          int nBytes,
                          int pctPrintable)

      Logs an array of bytes in string or hex dump format.
      Parameters:
        `logger` - The logger.
        `logLevelTitle` - The Logger level for the title/summary. See LoggerConstants.
        `logLevelData` - The Logger level for the data. See LoggerConstants.
        `arrayLabel` - A label for the array in the log output.
        `bytes` - The array of bytes to log.
        `nBytes` - The number of bytes to log.
        `pctPrintable` - The percent used to decide if the bytes are written in plain text format or hex dump format.

        If less than "pctPrintable" of the bytes are unprintable, the bytes are logged as text. Unprintable characters are replaced by "[hex]" where "hex" is the hexademical value of the character. When "pctPrintable" or more of the characters are unprintable, the characters are logged in a side-by-side format. The left side displays the data in string format with unprintable characters replaced by a ".". The right side displays the data in hex format.

        The method is adapted from code written by Carl Forde.

    - #### logMap

          public static <K,V> void logMap(Logger logger,
                          int level,
                          java.lang.String mapLabel,
                          java.util.Map<K,V> map)

      Log contents of a map (HashMap, TreeMap, etc.).
      Parameters:
        `logger` - The logger.
        `level` - Logging level.
        `mapLabel` - Label for map.
        `map` - The map to log.

        N.B. This method assumes both the keys and values have toString() methods.

    - #### logArray

          public static void logArray(Logger logger,
                      int level,
                      java.lang.String arrayLabel,
                      java.lang.Object[] array)

      Debugging support -- Print contents of an array.
      Parameters:
        `logger` - The logger.
        `level` - Logging level.
        `arrayLabel` - Label for array.
        `array` - The array.

        N.B. This method assumes the array values have toString() methods.

    - #### getFormattedCurrentDateAndTime

          public static java.lang.String getFormattedCurrentDateAndTime()

      Get formatted version of current date and time.
      Returns:
        Formatted current date and time in yyyy/mm/dd hh:mm:ss format.