Search in sources :

Example 36 with FormattingTuple

use of org.slf4j.helpers.FormattingTuple in project hive by apache.

the class TestLogger method debug.

@Override
public void debug(String format, Object arg) {
    FormattingTuple ft = MessageFormatter.format(format, arg);
    log(LEVEL.DEBUG, ft.getMessage(), ft.getThrowable());
}
Also used : FormattingTuple(org.slf4j.helpers.FormattingTuple)

Example 37 with FormattingTuple

use of org.slf4j.helpers.FormattingTuple in project hive by apache.

the class TestLogger method warn.

@Override
public void warn(String format, Object arg) {
    FormattingTuple ft = MessageFormatter.format(format, arg);
    log(LEVEL.WARN, ft.getMessage(), ft.getThrowable());
}
Also used : FormattingTuple(org.slf4j.helpers.FormattingTuple)

Example 38 with FormattingTuple

use of org.slf4j.helpers.FormattingTuple in project opennms by OpenNMS.

the class LogAdapter method format.

default String format(String message, Object... args) {
    FormattingTuple tp = MessageFormatter.arrayFormat(message, args);
    String formattedMessage = tp.getMessage();
    return formattedMessage.replaceAll("%t", "\t").replaceAll("%n", "\n");
}
Also used : FormattingTuple(org.slf4j.helpers.FormattingTuple)

Example 39 with FormattingTuple

use of org.slf4j.helpers.FormattingTuple in project opennms by OpenNMS.

the class MockLogger method formatAndLog.

/**
 * For formatted messages, first substitute arguments and then log.
 *
 * @param level
 * @param format
 * @param arg1
 * @param arg2
 */
private void formatAndLog(Level level, String format, Object arg1, Object arg2) {
    if (!isLevelEnabled(level)) {
        return;
    }
    FormattingTuple tp = MessageFormatter.format(format, arg1, arg2);
    log(level, tp.getMessage(), tp.getThrowable());
}
Also used : FormattingTuple(org.slf4j.helpers.FormattingTuple)

Example 40 with FormattingTuple

use of org.slf4j.helpers.FormattingTuple in project Javacord by BtoBastian.

the class JavacordLogger method error.

@Override
public final void error(String format, Object arg1, Object arg2) {
    FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
    LogRecord record = new LogRecord(Level.SEVERE, ft.getMessage());
    record.setThrown(ft.getThrowable());
    record.setLoggerName(name);
    Logger.getLogger(name).log(record);
}
Also used : LogRecord(java.util.logging.LogRecord) FormattingTuple(org.slf4j.helpers.FormattingTuple)

Aggregations

FormattingTuple (org.slf4j.helpers.FormattingTuple)61 LocationAwareLogger (org.slf4j.spi.LocationAwareLogger)5 LogRecord (java.util.logging.LogRecord)4 LogTask (alien4cloud.topology.task.LogTask)3 LogCapture (org.opendaylight.infrautils.testutils.LogCapture)2 DolphinLoggerBridge (com.canoo.platform.logging.spi.DolphinLoggerBridge)1 LogMessage (com.canoo.platform.logging.spi.LogMessage)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 JsonObject (javax.json.JsonObject)1 Test (org.junit.Test)1