use of org.slf4j.helpers.FormattingTuple in project ACS by ACS-Community.
the class JDK14LoggerAdapter method debug.
/**
* Log a message at level FINE according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the FINE level.
* </p>
*
* @param format
* the format string
* @param argArray
* an array of arguments
*/
public void debug(String format, Object... argArray) {
if (logger.isLoggable(Level.FINE)) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
log(SELF, Level.FINE, ft.getMessage(), ft.getThrowable());
}
}
use of org.slf4j.helpers.FormattingTuple in project ACS by ACS-Community.
the class JDK14LoggerAdapter method trace.
/**
* Log a message at level FINEST according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the FINEST level.
* </p>
*
* @param format
* the format string
* @param argArray
* an array of arguments
*/
public void trace(String format, Object... argArray) {
if (logger.isLoggable(Level.FINEST)) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
log(SELF, Level.FINEST, ft.getMessage(), ft.getThrowable());
}
}
use of org.slf4j.helpers.FormattingTuple in project ACS by ACS-Community.
the class JDK14LoggerAdapter method error.
/**
* Log a message at the SEVERE level according to the specified format and
* argument.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the SEVERE level.
* </p>
*
* @param format
* the format string
* @param arg
* the argument
*/
public void error(String format, Object arg) {
if (logger.isLoggable(Level.SEVERE)) {
FormattingTuple ft = MessageFormatter.format(format, arg);
log(SELF, Level.SEVERE, ft.getMessage(), ft.getThrowable());
}
}
use of org.slf4j.helpers.FormattingTuple in project sling by apache.
the class JSONRecordingTest method logs.
@Test
public void logs() throws Exception {
StringWriter sw = new StringWriter();
JSONRecording r = new JSONRecording("abc", request, true);
FormattingTuple tp1 = MessageFormatter.arrayFormat("{} is going", new Object[] { "Jack" });
r.log(tc, Level.INFO, "foo", tp1);
r.log(tc, Level.WARN, "foo.bar", MessageFormatter.arrayFormat("Jill is going", null));
r.log(tc, Level.ERROR, "foo.bar", MessageFormatter.arrayFormat("Jack and {} is going", new Object[] { "Jill", new Exception() }));
r.done();
r.render(sw);
JsonObject json = Json.createReader(new StringReader(sw.toString())).readObject();
assertEquals(3, json.getJsonArray("logs").size());
JsonObject l1 = json.getJsonArray("logs").getJsonObject(0);
assertEquals("INFO", l1.getString("level"));
assertEquals("foo", l1.getString("logger"));
assertEquals(tp1.getMessage(), l1.getString("message"));
assertEquals(1, l1.getJsonArray("params").size());
assertFalse(l1.containsKey("exception"));
assertFalse(l1.containsKey("caller"));
assertTrue(l1.containsKey("timestamp"));
JsonObject l3 = json.getJsonArray("logs").getJsonObject(2);
assertNotNull(l3.get("exception"));
}
use of org.slf4j.helpers.FormattingTuple in project sling by apache.
the class DefaultDistributionLog method internalLog.
private void internalLog(LogLevel level, String fmt, Object... objects) {
try {
FormattingTuple fmtp = MessageFormatter.arrayFormat(fmt, objects);
internalLog(level, fmtp.getMessage());
} catch (Throwable e) {
logger.error("cannot add entry log", e);
}
}
Aggregations