use of org.apache.logging.log4j.message.ReusableMessage in project logging-log4j2 by apache.
the class Log4jLogEventTest method testToImmutableNotSame.
@Test
public void testToImmutableNotSame() {
final LogEvent logEvent = new Log4jLogEvent.Builder().setMessage(new ReusableObjectMessage()).build();
LogEvent immutable = logEvent.toImmutable();
Assert.assertSame(logEvent, immutable);
Assert.assertFalse(immutable.getMessage() instanceof ReusableMessage);
}
use of org.apache.logging.log4j.message.ReusableMessage in project logging-log4j2 by apache.
the class MutableLogEvent method setMessage.
public void setMessage(final Message msg) {
if (msg instanceof ReusableMessage) {
final ReusableMessage reusable = (ReusableMessage) msg;
reusable.formatTo(getMessageTextForWriting());
if (parameters != null) {
parameters = reusable.swapParameters(parameters);
parameterCount = reusable.getParameterCount();
}
} else {
// if the Message instance is reused, there is no point in freezing its message here
if (msg != null && !canFormatMessageInBackground(msg)) {
// LOG4J2-763: ask message to freeze parameters
msg.getFormattedMessage();
}
this.message = msg;
}
}
use of org.apache.logging.log4j.message.ReusableMessage in project logging-log4j2 by apache.
the class RingBufferLogEvent method setMessage.
private void setMessage(final Message msg) {
if (msg instanceof ReusableMessage) {
final ReusableMessage reusable = (ReusableMessage) msg;
reusable.formatTo(getMessageTextForWriting());
if (parameters != null) {
parameters = reusable.swapParameters(parameters);
parameterCount = reusable.getParameterCount();
}
} else {
// if the Message instance is reused, there is no point in freezing its message here
if (msg != null && !canFormatMessageInBackground(msg)) {
// LOG4J2-763: ask message to freeze parameters
msg.getFormattedMessage();
}
this.message = msg;
}
}
Aggregations