Enum Class Severity

java.lang.Object
java.lang.Enum<Severity>
codes.grow.packages.betterstack.logging.Severity
All Implemented Interfaces:
Serializable, Comparable<Severity>, Constable

public enum Severity extends Enum<Severity>
Log severity with the OpenTelemetry severity numbers.
  • Enum Constant Details

    • TRACE

      public static final Severity TRACE
      OTel severity 1.
    • DEBUG

      public static final Severity DEBUG
      OTel severity 5.
    • INFO

      public static final Severity INFO
      OTel severity 9.
    • WARN

      public static final Severity WARN
      OTel severity 13.
    • ERROR

      public static final Severity ERROR
      OTel severity 17.
    • FATAL

      public static final Severity FATAL
      OTel severity 21.
  • Method Details

    • values

      public static Severity[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Severity valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • number

      public int number()
      Returns the OpenTelemetry severity number.
      Returns:
      1, 5, 9, 13, 17 or 21
    • text

      public String text()
      Returns the canonical severity text ("TRACE" … "FATAL").
      Returns:
      the upper-case name
    • fromNumber

      public static Severity fromNumber(int number)
      Maps any OpenTelemetry severity number (1–24) to its severity range; 0 or less maps to INFO (unspecified) and numbers above 24 to FATAL.
      Parameters:
      number - OTel severity number
      Returns:
      the severity whose range contains number
    • parse

      public static Optional<Severity> parse(String text)
      Parses a severity text case-insensitively. Accepts the canonical names plus the common aliases WARNING, ERR, CRITICAL, PANIC, SEVERE, FINE, FINEST and INFORMATION.
      Parameters:
      text - severity text
      Returns:
      the severity, or empty when the text is not recognised