Class LoggingEvent

java.lang.Object
com.log4rich.util.LoggingEvent

public class LoggingEvent extends Object
Represents a single logging event with all associated metadata. This class is immutable and thread-safe.
  • Constructor Details

    • LoggingEvent

      public LoggingEvent(LogLevel level, String message, String loggerName, LocationInfo locationInfo, Throwable throwable)
      Creates a new LoggingEvent with all parameters.
      Parameters:
      level - the log level
      message - the log message
      loggerName - the name of the logger
      locationInfo - location information where the log occurred
      throwable - optional exception associated with the log event
    • LoggingEvent

      public LoggingEvent(LogLevel level, String message, String loggerName, LocationInfo locationInfo)
      Creates a new LoggingEvent without an exception.
      Parameters:
      level - the log level
      message - the log message
      loggerName - the name of the logger
      locationInfo - location information where the log occurred
  • Method Details

    • getLevel

      public LogLevel getLevel()
      Gets the log level of this event.
      Returns:
      the log level
    • getMessage

      public String getMessage()
      Gets the log message.
      Returns:
      the log message
    • getLoggerName

      public String getLoggerName()
      Gets the name of the logger that created this event.
      Returns:
      the logger name
    • getTimestamp

      public long getTimestamp()
      Gets the timestamp when this event was created.
      Returns:
      the timestamp in milliseconds since epoch
    • getThreadName

      public String getThreadName()
      Gets the name of the thread that created this event.
      Returns:
      the thread name
    • getLocationInfo

      public LocationInfo getLocationInfo()
      Gets the location information where this event occurred.
      Returns:
      the location information, or null if not available
    • getThrowable

      public Throwable getThrowable()
      Gets the throwable associated with this event.
      Returns:
      the throwable, or null if none
    • hasThrowable

      public boolean hasThrowable()
      Checks if this event has an associated throwable.
      Returns:
      true if this event has a throwable, false otherwise
    • getRenderedMessage

      public String getRenderedMessage()
      Gets the rendered message, including throwable stack trace if present. This method combines the log message with the exception information to provide a complete view of the log event.
      Returns:
      the complete message with stack trace if applicable
    • toString

      public String toString()
      Returns a string representation of this logging event.
      Overrides:
      toString in class Object
      Returns:
      a formatted string containing level, logger name, and message