Search in sources :

Example 1 with ParameterizedMessageFactory

use of org.apache.logging.log4j.message.ParameterizedMessageFactory in project geode by apache.

the class FastLoggerJUnitTest method setUp.

@Before
public void setUp() {
    this.messageFactory = new ParameterizedMessageFactory();
    this.mockedLogger = mock(ExtendedLogger.class);
    this.mockedMarker = mock(Marker.class);
    when(this.mockedLogger.getMessageFactory()).thenReturn(this.messageFactory);
    when(this.mockedMarker.getName()).thenReturn("MARKER");
}
Also used : ExtendedLogger(org.apache.logging.log4j.spi.ExtendedLogger) Marker(org.apache.logging.log4j.Marker) ParameterizedMessageFactory(org.apache.logging.log4j.message.ParameterizedMessageFactory) Before(org.junit.Before)

Example 2 with ParameterizedMessageFactory

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

the class LoggerTest method getLogger_Object_ParameterizedMessageFactory.

@Test
public void getLogger_Object_ParameterizedMessageFactory() {
    // The TestLogger logger was already created in an instance variable for this class.
    // The message factory is only used when the logger is created.
    final ParameterizedMessageFactory messageFactory = ParameterizedMessageFactory.INSTANCE;
    final TestLogger testLogger = (TestLogger) LogManager.getLogger(new TestParameterizedMessageFactory(), messageFactory);
    assertNotNull(testLogger);
    assertEqualMessageFactory(messageFactory, testLogger);
    testLogger.debug("{}", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(" DEBUG " + Integer.MAX_VALUE, testLogger.getEntries().get(0));
}
Also used : TestLogger(org.apache.logging.log4j.test.TestLogger) ParameterizedMessageFactory(org.apache.logging.log4j.message.ParameterizedMessageFactory) Test(org.junit.jupiter.api.Test)

Example 3 with ParameterizedMessageFactory

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

the class LoggerTest method getLogger_String_ParameterizedMessageFactory.

@Test
public void getLogger_String_ParameterizedMessageFactory() {
    final ParameterizedMessageFactory messageFactory = ParameterizedMessageFactory.INSTANCE;
    final TestLogger testLogger = (TestLogger) LogManager.getLogger("getLogger_String_ParameterizedMessageFactory", messageFactory);
    assertNotNull(testLogger);
    assertEqualMessageFactory(messageFactory, testLogger);
    testLogger.debug("{}", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(" DEBUG " + Integer.MAX_VALUE, testLogger.getEntries().get(0));
}
Also used : TestLogger(org.apache.logging.log4j.test.TestLogger) ParameterizedMessageFactory(org.apache.logging.log4j.message.ParameterizedMessageFactory) Test(org.junit.jupiter.api.Test)

Example 4 with ParameterizedMessageFactory

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

the class LoggerTest method getLogger_Class_ParameterizedMessageFactory.

@Test
public void getLogger_Class_ParameterizedMessageFactory() {
    // The TestLogger logger was already created in an instance variable for this class.
    // The message factory is only used when the logger is created.
    final ParameterizedMessageFactory messageFactory = ParameterizedMessageFactory.INSTANCE;
    final TestLogger testLogger = (TestLogger) LogManager.getLogger(TestParameterizedMessageFactory.class, messageFactory);
    assertNotNull(testLogger);
    assertEqualMessageFactory(messageFactory, testLogger);
    testLogger.debug("{}", Integer.MAX_VALUE);
    assertEquals(1, testLogger.getEntries().size());
    assertEquals(" DEBUG " + Integer.MAX_VALUE, testLogger.getEntries().get(0));
}
Also used : TestLogger(org.apache.logging.log4j.test.TestLogger) ParameterizedMessageFactory(org.apache.logging.log4j.message.ParameterizedMessageFactory) Test(org.junit.jupiter.api.Test)

Aggregations

ParameterizedMessageFactory (org.apache.logging.log4j.message.ParameterizedMessageFactory)4 TestLogger (org.apache.logging.log4j.test.TestLogger)3 Test (org.junit.jupiter.api.Test)3 Marker (org.apache.logging.log4j.Marker)1 ExtendedLogger (org.apache.logging.log4j.spi.ExtendedLogger)1 Before (org.junit.Before)1