Package com.log4rich.util
Class LoggingEvent
java.lang.Object
com.log4rich.util.LoggingEvent
Represents a single logging event with all associated metadata.
This class is immutable and thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionLoggingEvent
(LogLevel level, String message, String loggerName, LocationInfo locationInfo) Creates a new LoggingEvent without an exception.LoggingEvent
(LogLevel level, String message, String loggerName, LocationInfo locationInfo, Throwable throwable) Creates a new LoggingEvent with all parameters. -
Method Summary
Modifier and TypeMethodDescriptiongetLevel()
Gets the log level of this event.Gets the location information where this event occurred.Gets the name of the logger that created this event.Gets the log message.Gets the rendered message, including throwable stack trace if present.Gets the name of the thread that created this event.Gets the throwable associated with this event.long
Gets the timestamp when this event was created.boolean
Checks if this event has an associated throwable.toString()
Returns a string representation of this logging event.
-
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 levelmessage
- the log messageloggerName
- the name of the loggerlocationInfo
- location information where the log occurredthrowable
- optional exception associated with the log event
-
LoggingEvent
Creates a new LoggingEvent without an exception.- Parameters:
level
- the log levelmessage
- the log messageloggerName
- the name of the loggerlocationInfo
- location information where the log occurred
-
-
Method Details
-
getLevel
Gets the log level of this event.- Returns:
- the log level
-
getMessage
Gets the log message.- Returns:
- the log message
-
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
Gets the name of the thread that created this event.- Returns:
- the thread name
-
getLocationInfo
Gets the location information where this event occurred.- Returns:
- the location information, or null if not available
-
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
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
Returns a string representation of this logging event.
-