use of java.lang.System.Logger in project logging-log4j2 by apache.
the class Log4jSystemLoggerTest method testLogWithCallingClass.
@Test
public void testLogWithCallingClass() throws Exception {
final Logger log = System.getLogger("Test.CallerClass");
log.log(Logger.Level.INFO, "Calling from LoggerTest");
final List<String> messages = stringAppender.getMessages();
assertThat(messages, hasSize(1));
final String message = messages.get(0);
assertEquals(Log4jSystemLoggerTest.class.getName(), message);
}
use of java.lang.System.Logger in project Bytecoder by mirkosertic.
the class AbstractLoggerWrapper method logp.
@Override
public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier<String> msgSupplier) {
final PlatformLogger.Bridge platformProxy = platformProxy();
if (platformProxy == null) {
// best effort
if (sourceClass == null && sourceMethod == null) {
wrapped().log(level.systemLevel(), msgSupplier, thrown);
} else {
Level systemLevel = level.systemLevel();
Logger wrapped = wrapped();
if (wrapped.isLoggable(systemLevel)) {
final String sClass = sourceClass == null ? "" : sourceClass;
final String sMethod = sourceMethod == null ? "" : sourceMethod;
wrapped.log(systemLevel, () -> String.format("[%s %s] %s", sClass, sMethod, msgSupplier.get()), thrown);
}
}
} else {
platformProxy.logp(level, sourceClass, sourceMethod, thrown, msgSupplier);
}
}
use of java.lang.System.Logger in project Bytecoder by mirkosertic.
the class AbstractLoggerWrapper method logrb.
@Override
public void logrb(PlatformLogger.Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Object... params) {
final PlatformLogger.Bridge platformProxy = platformProxy();
if (platformProxy == null) {
// best effort
if (bundle != null || sourceClass == null && sourceMethod == null) {
wrapped().log(level.systemLevel(), bundle, msg, params);
} else {
Level systemLevel = level.systemLevel();
Logger wrapped = wrapped();
if (wrapped.isLoggable(systemLevel)) {
sourceClass = sourceClass == null ? "" : sourceClass;
sourceMethod = sourceMethod == null ? "" : sourceMethod;
msg = msg == null ? "" : msg;
wrapped.log(systemLevel, bundle, String.format("[%s %s] %s", sourceClass, sourceMethod, msg), params);
}
}
} else {
platformProxy.logrb(level, sourceClass, sourceMethod, bundle, msg, params);
}
}
use of java.lang.System.Logger in project Bytecoder by mirkosertic.
the class AbstractLoggerWrapper method logp.
@Override
public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, String msg) {
final PlatformLogger.Bridge platformProxy = platformProxy();
if (platformProxy == null) {
if (sourceClass == null && sourceMethod == null) {
// best effort
wrapped().log(level.systemLevel(), msg);
} else {
Level systemLevel = level.systemLevel();
Logger wrapped = wrapped();
if (wrapped.isLoggable(systemLevel)) {
sourceClass = sourceClass == null ? "" : sourceClass;
sourceMethod = sourceMethod == null ? "" : sourceMethod;
msg = msg == null ? "" : msg;
wrapped.log(systemLevel, String.format("[%s %s] %s", sourceClass, sourceMethod, msg));
}
}
} else {
platformProxy.logp(level, sourceClass, sourceMethod, msg);
}
}
use of java.lang.System.Logger in project Bytecoder by mirkosertic.
the class BootstrapLogger method log.
@Override
public void log(Level level, Supplier<String> msgSupplier, Throwable thrown) {
if (checkBootstrapping()) {
push(LogEvent.valueOf(this, level, msgSupplier, thrown));
} else {
final Logger spi = holder.wrapped();
spi.log(level, msgSupplier, thrown);
}
}
Aggregations