Class SLogger.Formatter

  • All Implemented Interfaces:
    Supplier<String>
    Enclosing class:
    SLogger

    public static class SLogger.Formatter
    extends Object
    implements Supplier<String>
    Container class to format an object for logging.

    The format is only derived when toString() is called, meaning that if you log one of these and the log level is not enabled, a slow string conversion will never occur.

    Null values are transformed into the special string ‘(null)’.

    Formatted values are cached after the first format operation, even if the underlying object is modified.

    The following types are handled by the Formatter:

    • null
    • Strings
    • Arrays of Objects
    • Arrays of StackTraceElements
    • Collections of Objects
    • Maps
    • Dates and Calendars
    • XML Documents
    • Various SailPointObjects

    Nested objects (e.g., the items in a list) are also passed through Formatter.

    • Constructor Detail

      • Formatter

        public Formatter​(Object Item)
        Creates a new formatter.
        Parameters:
        Item - The item to format.
    • Method Detail

      • format

        public static String format​(Object obj)
        Formats the given object for logging
        Parameters:
        obj - The object to format
        Returns:
        The formatted object
      • get

        public String get()
        Returns the formatted string of the item when invoked via the Supplier interface.

        This output will NOT be cached, unlike a call to toString().

        Specified by:
        get in interface Supplier<String>
        Returns:
        The formatted string, freshly calculated
        See Also:
        Supplier.get()
      • toString

        public String toString()
        If the formatted value exists, the cached version will be returned.

        Otherwise, the format string will be calculated at this time, cached, and then returned.

        Overrides:
        toString in class Object
        See Also:
        Object.toString()