Class AdditionalLogItem


  • public final class AdditionalLogItem
    extends Object
    An additional log item for an operation which may be processed in the access log.

    Log items comprise of a source class, a key, and an optional value. If no value is present then only the key will be displayed in the log, otherwise both the key and value will usually be displayed using the format key=value. Log item values are Object instances whose string representation will be derived using the object's toString() method.

    Log implementations may use the source class and/or key in order to filter out unwanted log items.

    • Method Detail

      • keyOnly

        public static AdditionalLogItem keyOnly​(Class<?> source,
                                                String key)
        Creates a new additional log item using the provided source and key and a value equal to the boolean true.
        Parameters:
        source - The class which generated the additional log item.
        key - The log item key.
        Returns:
        The new additional log item.
      • keyValue

        public static AdditionalLogItem keyValue​(Class<?> source,
                                                 String key,
                                                 CharSequence value)
        Creates a new additional log item using the provided source, key, and value. The value will be surrounded by quotes when serialized as a string.
        Parameters:
        source - The class which generated the additional log item.
        key - The log item key.
        value - The not-null log item value that will be converted to a String. Null is not accepted because it cannot be distinguished from "not present" using mining tools
        Returns:
        The new additional log item.
      • keyValue

        public static AdditionalLogItem keyValue​(Class<?> source,
                                                 String key,
                                                 long value)
        Creates a new additional log item using the provided source, key, and value. The value will not be surrounded by quotes when serialized as a string.
        Parameters:
        source - The class which generated the additional log item.
        key - The log item key.
        value - The log item value.
        Returns:
        The new additional log item.
      • getKey

        public String getKey()
        Returns the log item key.
        Returns:
        The log item key.
      • getSource

        public Class<?> getSource()
        Returns the class which generated the additional log item.
        Returns:
        The class which generated the additional log item.
      • getValue

        public Object getValue()
        Returns the log item value, or null if this log item does not have a value.
        Returns:
        The non-null log item value which type is either Boolean, Long, or String.
      • toString

        public StringBuilder toString​(StringBuilder builder)
        Appends the string representation of this additional log item to the provided string builder.
        Parameters:
        builder - The string builder
        Returns:
        A reference to the updated string builder.