Class KibanaLogFields

java.lang.Object
org.hawaiiframework.logging.model.KibanaLogFields

public final class KibanaLogFields extends Object
Class that holds the extra fields used for Kibana logging.

Log lines for Kibana will contain all fields set, until the log fields are cleared by invoking clear().

Since:
2.0.0
  • Method Details

    • tag

      public static KibanaLogField tag(KibanaLogField field, Enum<?> value)
      Sets the Kibana log field field to the value.
      Parameters:
      field - The field to set.
      value - The value to set.
      Returns:
      The field, set.
    • tag

      public static KibanaLogField tag(KibanaLogField field, int value)
      Sets the Kibana log field field to the value.
      Parameters:
      field - The field to set.
      value - The value to set.
      Returns:
      The field, set.
    • tag

      public static KibanaLogField tag(KibanaLogField field, String value)
      Sets the Kibana log field field to the value.
      Parameters:
      field - The field to set.
      value - The value to set.
      Returns:
      The field, set.
    • tag

      public static KibanaLogField tag(KibanaLogField field, Collection<String> values)
      Sets the Kibana log field field to the value.
      Parameters:
      field - The field to set.
      values - The values to set.
      Returns:
      The field, set.
    • tagCloseable

      public static AutoCloseableKibanaLogField tagCloseable(KibanaLogField field, Enum<?> value)
      Sets the Kibana log field field to the value, returns an auto closeable.
      Parameters:
      field - The field to set.
      value - The value to set.
      Returns:
      a closable field.
    • tagCloseable

      public static AutoCloseableKibanaLogField tagCloseable(KibanaLogField field, int value)
      Sets the Kibana log field field to the value, returns an auto closeable.
      Parameters:
      field - The field to set.
      value - The value to set.
      Returns:
      a closable field.
    • tagCloseable

      public static AutoCloseableKibanaLogField tagCloseable(KibanaLogField field, String value)
      Sets the Kibana log field field to the value, returns an auto closeable.
      Parameters:
      field - The field to set.
      value - The value to set.
      Returns:
      a closable field.
    • tagCloseable

      public static AutoCloseableKibanaLogField tagCloseable(KibanaLogField field, Collection<String> values)
      Sets the Kibana log field field to the value, returns an auto closeable.
      Parameters:
      field - The field to set.
      values - The value to set.
      Returns:
      a closable field.
    • get

      public static String get(KibanaLogField field)
      Retrieves the value for the field. It will return null if no value is set.
      Parameters:
      field - The field to retrieve the value for.
      Returns:
      The fields value, possibly null.
    • getOrDefault

      public static String getOrDefault(KibanaLogField field, String defaultValue)
      Retrieves the value for the field. It will return defaultValue if no value is set.
      Parameters:
      field - The field to retrieve the value for.
      defaultValue - The value if there is no value set.
      Returns:
      The field's value or the default.
    • clear

      public static void clear(KibanaLogField field)
      Removes the value for the field field.
      Parameters:
      field - The field to remove.
    • clear

      public static void clear(KibanaLogField... fields)
      Removes the value for the fields fields.
      Parameters:
      fields - The fields to remove the values for.
    • clear

      public static void clear()
      Removes all values set for all fields.
    • getValuesAsLogString

      public static String getValuesAsLogString()
      Getter for the log string.
      Returns:
      the log string
    • populateFromContext

      public static void populateFromContext(KibanaLogContext logContext)
      Update log fields based on the KibanaLogContext.

      See getContext().

      Parameters:
      logContext - The context to copy.
    • getContext

      public static KibanaLogContext getContext()
      Create a new log context for the current thread's kibana log fields.

      See KibanaLogContext.registerKibanaLogFieldsInThisThread().

      Returns:
      a log context to use in another thread.