Package com.dua3.utility.logging
Interface LogEntry
- All Known Implementing Classes:
LogEntryLog4J,LogEntrySlf4j,SimpleLogEntry
public interface LogEntry
The LogEntry interface represents a log entry with various properties such as message, logger name, time, level, marker, and throwable.
Note: Implementing classes should be immutable!
-
Method Summary
Modifier and TypeMethodDescriptiondefault StringFormats the log entry with the given prefix and suffix.level()Returns the log level of the LogEntry.@Nullable Stringlocation()Returns the location information if present.Returns the name of the logger associated with the log entry.marker()Returns the marker associated with this log entry.message()Retrieves the message of the log entry.@Nullable ThrowableReturns the throwable object associated with this LogEntry.time()Returns the time when the logging event was created as an Instant object.
-
Method Details
-
message
String message()Retrieves the message of the log entry.- Returns:
- The message of the log entry.
-
loggerName
String loggerName()Returns the name of the logger associated with the log entry.- Returns:
- The name of the logger.
-
time
Instant time()Returns the time when the logging event was created as an Instant object.- Returns:
- the creation time of the logging event as an Instant object
-
level
LogLevel level()Returns the log level of the LogEntry.- Returns:
- the log level of the LogEntry
-
marker
String marker()Returns the marker associated with this log entry.- Returns:
- the marker
-
throwable
@Nullable Throwable throwable()Returns the throwable object associated with this LogEntry.- Returns:
- the throwable object associated with this LogEntry, or null if no throwable is present
-
location
@Nullable String location()Returns the location information if present.- Returns:
- the location information, or null if no location is present
-
format
Formats the log entry with the given prefix and suffix.- Parameters:
prefix- the prefix to prepend to the formatted entrysuffix- the suffix to append to the formatted entry- Returns:
- the formatted log entry as a string
-