Search in sources :

Example 1 with StringFormattedMessage

use of org.apache.logging.log4j.message.StringFormattedMessage in project logging-log4j2 by apache.

the class AbstractLogger method printf.

@Override
public void printf(final Level level, final String format, final Object... params) {
    if (isEnabled(level, null, format, params)) {
        final Message msg = new StringFormattedMessage(format, params);
        logMessageSafely(FQCN, level, null, msg, msg.getThrowable());
    }
}
Also used : SimpleMessage(org.apache.logging.log4j.message.SimpleMessage) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) Message(org.apache.logging.log4j.message.Message) EntryMessage(org.apache.logging.log4j.message.EntryMessage) StringFormattedMessage(org.apache.logging.log4j.message.StringFormattedMessage) StringFormattedMessage(org.apache.logging.log4j.message.StringFormattedMessage)

Example 2 with StringFormattedMessage

use of org.apache.logging.log4j.message.StringFormattedMessage in project logging-log4j2 by apache.

the class LoggerSupplierTest method flowTracing_SupplierOfStringFormattedMessage.

@Test
public void flowTracing_SupplierOfStringFormattedMessage() {
    logger.traceEntry(() -> new StringFormattedMessage("int foo=%,d", 1234567890));
    assertThat(results).hasSize(1);
    String entry = results.get(0);
    assertThat(entry).startsWith("ENTER[ FLOW ] TRACE Enter").contains("(int foo=1,234,567,890)").doesNotContain("StringFormattedMessage");
}
Also used : StringFormattedMessage(org.apache.logging.log4j.message.StringFormattedMessage) Test(org.junit.jupiter.api.Test)

Example 3 with StringFormattedMessage

use of org.apache.logging.log4j.message.StringFormattedMessage in project logging-log4j2 by apache.

the class AbstractLogger method printf.

@Override
public void printf(final Level level, final Marker marker, final String format, final Object... params) {
    if (isEnabled(level, marker, format, params)) {
        final Message msg = new StringFormattedMessage(format, params);
        logMessageSafely(FQCN, level, marker, msg, msg.getThrowable());
    }
}
Also used : SimpleMessage(org.apache.logging.log4j.message.SimpleMessage) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) Message(org.apache.logging.log4j.message.Message) EntryMessage(org.apache.logging.log4j.message.EntryMessage) StringFormattedMessage(org.apache.logging.log4j.message.StringFormattedMessage) StringFormattedMessage(org.apache.logging.log4j.message.StringFormattedMessage)

Aggregations

StringFormattedMessage (org.apache.logging.log4j.message.StringFormattedMessage)3 EntryMessage (org.apache.logging.log4j.message.EntryMessage)2 Message (org.apache.logging.log4j.message.Message)2 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)2 SimpleMessage (org.apache.logging.log4j.message.SimpleMessage)2 Test (org.junit.jupiter.api.Test)1