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, but no value.
        Parameters:
        source - The class which generated the additional log item.
        key - The log item key.
        Returns:
        The new additional log item.
      • quotedKeyValue

        public static AdditionalLogItem quotedKeyValue​(Class<?> source,
                                                       String key,
                                                       Object 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 log item value.
        Returns:
        The new additional log item.
      • unquotedKeyValue

        public static AdditionalLogItem unquotedKeyValue​(Class<?> source,
                                                         String key,
                                                         Object 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 log item value, or null if this log item does not have a value.
      • isQuoted

        public boolean isQuoted()
        Returns true if this item's value should be surrounded by quotes during serialization.
        Returns:
        true if this item's value should be surrounded by quotes during serialization.
      • 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.