use of org.apache.logging.log4j.test.TestLogger 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));
}
use of org.apache.logging.log4j.test.TestLogger in project logging-log4j2 by apache.
the class LoggerTest method getLogger_String_SimpleMessageFactory.
@Test
public void getLogger_String_SimpleMessageFactory() {
final SimpleMessageFactory messageFactory = SimpleMessageFactory.INSTANCE;
final TestLogger testLogger = (TestLogger) LogManager.getLogger("getLogger_String_StringFormatterMessageFactory", messageFactory);
assertNotNull(testLogger);
assertEqualMessageFactory(messageFactory, testLogger);
testLogger.debug("{} %,d {foo}", Integer.MAX_VALUE);
assertEquals(1, testLogger.getEntries().size());
assertEquals(" DEBUG {} %,d {foo}", testLogger.getEntries().get(0));
}
use of org.apache.logging.log4j.test.TestLogger in project logging-log4j2 by apache.
the class TestLoggerContext method getLogger.
@Override
public ExtendedLogger getLogger(final String name) {
final ExtendedLogger extendedLogger = map.get(name);
if (extendedLogger != null) {
return extendedLogger;
}
final ExtendedLogger logger = new TestLogger(name);
map.put(name, logger);
return logger;
}
use of org.apache.logging.log4j.test.TestLogger in project logging-log4j2 by apache.
the class LoggerTest method getLogger_Object_StringFormatterMessageFactory.
@Test
public void getLogger_Object_StringFormatterMessageFactory() {
// 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 StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
final TestLogger testLogger = (TestLogger) LogManager.getLogger(new TestStringFormatterMessageFactory(), messageFactory);
assertNotNull(testLogger);
assertEqualMessageFactory(messageFactory, testLogger);
testLogger.debug("%,d", Integer.MAX_VALUE);
assertEquals(1, testLogger.getEntries().size());
assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
use of org.apache.logging.log4j.test.TestLogger in project logging-log4j2 by apache.
the class LoggerTest method getLogger_Class_StringFormatterMessageFactory.
@Test
public void getLogger_Class_StringFormatterMessageFactory() {
// 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 TestLogger testLogger = (TestLogger) LogManager.getLogger(TestStringFormatterMessageFactory.class, StringFormatterMessageFactory.INSTANCE);
assertNotNull(testLogger);
assertEqualMessageFactory(StringFormatterMessageFactory.INSTANCE, testLogger);
testLogger.debug("%,d", Integer.MAX_VALUE);
assertEquals(1, testLogger.getEntries().size());
assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
Aggregations