Record Class LogEntry

java.lang.Object
java.lang.Record
org.apache.sling.commons.log.logback.store.LogEntry

public record LogEntry(long timeMillis, LogLevel level, String loggerName, String threadName, String formattedMessage, String throwableClassName, String throwableMessage, String throwableText, Map<String,String> mdc) extends Record
Snapshot of a log entry.

Stores only the lightweight, stable parts of a log event so the log store does not retain full logging event object graphs.

The throwable that accompanies the event, if any, is decomposed into three optional fields. throwableClassName() and throwableMessage() are the binary name and detail message of the leaf Throwable for structured consumption (alerting, attribute mapping). throwableText() is the formatted representation of the full throwable chain including any cause and suppressed throwables; it is suitable for verbatim display such as stack traces in log viewers.

  • Constructor Details

    • LogEntry

      public LogEntry(long timeMillis, LogLevel level, String loggerName, String threadName, String formattedMessage, String throwableClassName, String throwableMessage, String throwableText, Map<String,String> mdc)
      Creates an instance of a LogEntry record class.
      Parameters:
      timeMillis - the value for the timeMillis record component
      level - the value for the level record component
      loggerName - the value for the loggerName record component
      threadName - the value for the threadName record component
      formattedMessage - the value for the formattedMessage record component
      throwableClassName - the value for the throwableClassName record component
      throwableMessage - the value for the throwableMessage record component
      throwableText - the value for the throwableText record component
      mdc - the value for the mdc record component
    • LogEntry

      public LogEntry(long timeMillis, LogLevel level, String loggerName, String threadName, String formattedMessage, String throwableText, Map<String,String> mdc)
      Backwards-compatible constructor without the structured throwable fields.

      Retained so the package stays binary compatible with 1.0.0; delegates to the canonical constructor with no throwableClassName() or throwableMessage().

  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • timeMillis

      public long timeMillis()
      Returns the value of the timeMillis record component.
      Returns:
      the value of the timeMillis record component
    • level

      public LogLevel level()
      Returns the value of the level record component.
      Returns:
      the value of the level record component
    • loggerName

      public String loggerName()
      Returns the value of the loggerName record component.
      Returns:
      the value of the loggerName record component
    • threadName

      public String threadName()
      Returns the value of the threadName record component.
      Returns:
      the value of the threadName record component
    • formattedMessage

      public String formattedMessage()
      Returns the value of the formattedMessage record component.
      Returns:
      the value of the formattedMessage record component
    • throwableClassName

      public String throwableClassName()
      Returns the value of the throwableClassName record component.
      Returns:
      the value of the throwableClassName record component
    • throwableMessage

      public String throwableMessage()
      Returns the value of the throwableMessage record component.
      Returns:
      the value of the throwableMessage record component
    • throwableText

      public String throwableText()
      Returns the value of the throwableText record component.
      Returns:
      the value of the throwableText record component
    • mdc

      public Map<String,String> mdc()
      Returns the value of the mdc record component.
      Returns:
      the value of the mdc record component