java.lang.Object
eu.mulk.quarkus.googlecloud.jsonlogging.Label

public final class Label extends Object
A label usable to tag a log message.

Instances of Label can be passed as log parameters to the *f family of logging functions on Logger.

Example:

logger.logf("Request rejected: unauthorized.", Label.of("requestId", "123"));

Result:

{
  "textPayload": "Request rejected: unauthorized.",
  "labels": {
    "requestId": "123"
  }
}
See Also:
  • Method Details

    • of

      public static Label of(String key, String value)
      Constructs a Label from a key (i.e. name) and a value.

      It is often useful for the key to be a String constant that is shared by multiple parts of the program.

      Parameters:
      key - the key (name) of the label.
      value - the value of the label.
      Returns:
      the newly constructed Label, ready to be passed to a logging function.
    • key

      public String key()
      The name of the label.

      It is often useful for this to be a String constant that is shared by multiple parts of the program.

      Returns:
      the name of the label.
    • value

      public String value()
      The value of the label.
      Returns:
      the value of the label.
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object