public class LogMessage extends Object implements Comparable<LogMessage>
| Constructor and Description |
|---|
LogMessage(org.apache.log4j.spi.LoggingEvent event,
org.apache.log4j.Layout layout)
Constructs an instance from a Log4J event, using the specified layout.
|
LogMessage(long timestamp,
String message)
Constructs an instance from a simple string.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(LogMessage that)
Compares instances based on their timestamp.
|
byte[] |
getBytes()
Returns the UTF-8 message bytes.
|
String |
getMessage()
Returns the original message string.
|
long |
getTimestamp()
Returns the timestamp of the original logging event.
|
int |
size()
Returns the size of the message after conversion to UTF-8.
|
public LogMessage(long timestamp,
String message)
RuntimeException - if UTF-8 encoding is not supported by the JVM (which
should never happen).public LogMessage(org.apache.log4j.spi.LoggingEvent event,
org.apache.log4j.Layout layout)
RuntimeException - if any error occurred during formatting or conversion.
Will include any root cause other than UnsupportedEncodingException.public long getTimestamp()
public int size()
public String getMessage()
public byte[] getBytes()
public int compareTo(LogMessage that)
Note that an "equal" comparison is not consistent with equals(),
which uses default instance equality. This is intentional: one the one hand,
there's no reason to test equality for two instances; they should be considered
opaque. On the other, we don't want the comparision to do more than it should:
we're using a stable sort, and rely on that fact to order two messages with the
same timestamp in the order they were passed to append().
compareTo in interface Comparable<LogMessage>Copyright © 2018. All rights reserved.