Search in sources :

Example 1 with MessageSupplier

use of org.apache.logging.log4j.util.MessageSupplier in project logging-log4j2 by apache.

the class AbstractLoggerTest method testMessageSupplierWithoutThrowable.

@Test
public void testMessageSupplierWithoutThrowable() {
    final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
    final ThrowableMessage message = new ThrowableMessage(null);
    final MessageSupplier supplier = new MessageSupplier() {

        @Override
        public Message get() {
            return message;
        }
    };
    logger.debug(supplier);
    logger.error(supplier);
    logger.fatal(supplier);
    logger.info(supplier);
    logger.trace(supplier);
    logger.warn(supplier);
    logger.log(Level.INFO, supplier);
    logger.debug(MARKER, supplier);
    logger.error(MARKER, supplier);
    logger.fatal(MARKER, supplier);
    logger.info(MARKER, supplier);
    logger.trace(MARKER, supplier);
    logger.warn(MARKER, supplier);
    logger.log(Level.INFO, MARKER, supplier);
}
Also used : MessageSupplier(org.apache.logging.log4j.util.MessageSupplier) Test(org.junit.Test)

Example 2 with MessageSupplier

use of org.apache.logging.log4j.util.MessageSupplier in project logging-log4j2 by apache.

the class AbstractLoggerTest method testMessageSupplierWithThrowable.

@Test
public void testMessageSupplierWithThrowable() {
    final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(true);
    final ThrowableMessage message = new ThrowableMessage(t);
    final MessageSupplier supplier = new MessageSupplier() {

        @Override
        public Message get() {
            return message;
        }
    };
    logger.debug(supplier);
    logger.error(supplier);
    logger.fatal(supplier);
    logger.info(supplier);
    logger.trace(supplier);
    logger.warn(supplier);
    logger.log(Level.INFO, supplier);
    logger.debug(MARKER, supplier);
    logger.error(MARKER, supplier);
    logger.fatal(MARKER, supplier);
    logger.info(MARKER, supplier);
    logger.trace(MARKER, supplier);
    logger.warn(MARKER, supplier);
    logger.log(Level.INFO, MARKER, supplier);
}
Also used : MessageSupplier(org.apache.logging.log4j.util.MessageSupplier) Test(org.junit.Test)

Aggregations

MessageSupplier (org.apache.logging.log4j.util.MessageSupplier)2 Test (org.junit.Test)2