use of java.lang.System.Logger.Level in project Bytecoder by mirkosertic.
the class AbstractLoggerWrapper method logp.
@Override
public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, String msg, Object... params) {
final PlatformLogger.Bridge platformProxy = platformProxy();
if (platformProxy == null) {
// best effort
if (sourceClass == null && sourceMethod == null) {
wrapped().log(level.systemLevel(), 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, String.format("[%s %s] %s", sourceClass, sourceMethod, msg), params);
}
}
} else {
platformProxy.logp(level, sourceClass, sourceMethod, msg, params);
}
}
use of java.lang.System.Logger.Level 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, Throwable thrown) {
final PlatformLogger.Bridge platformProxy = platformProxy();
if (platformProxy == null) {
// best effort
if (bundle != null || sourceClass == null && sourceMethod == null) {
wrapped().log(level.systemLevel(), bundle, msg, thrown);
} 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), thrown);
}
}
} else {
platformProxy.logrb(level, sourceClass, sourceMethod, bundle, msg, thrown);
}
}
use of java.lang.System.Logger.Level in project Tupl by cojen.
the class EventListenerTest method ignore.
@Test
public void ignore() throws Exception {
var listener = new Listener();
assertSame(listener, listener.ignore(new EventType.Category[0]));
assertSame(listener, listener.ignore(new Level[0]));
EventListener filtered = listener.ignore(EventType.Category.DEBUG);
filtered.notify(EventType.DEBUG, "hello");
filtered.notify(EventType.CHECKPOINT_BEGIN, "world");
assertEquals("[CHECKPOINT_BEGIN:world:[]]", listener.mEvents.toString());
assertSame(filtered, filtered.ignore(EventType.Category.DEBUG));
listener = new Listener();
filtered = listener.ignore(Level.DEBUG);
filtered.notify(EventType.DEBUG, "hello");
filtered.notify(EventType.CHECKPOINT_FAILED, "world");
assertEquals("[CHECKPOINT_FAILED:world:[]]", listener.mEvents.toString());
assertSame(filtered, filtered.ignore(Level.DEBUG));
listener.mEvents.clear();
filtered = filtered.ignore(Level.WARNING);
filtered.notify(EventType.DEBUG, "hello");
filtered.notify(EventType.CHECKPOINT_FAILED, "world");
assertEquals("[]", listener.mEvents.toString());
listener.mEvents.clear();
filtered = filtered.observe(Level.WARNING);
filtered.notify(EventType.DEBUG, "hello");
filtered.notify(EventType.CHECKPOINT_FAILED, "world");
assertEquals("[]", listener.mEvents.toString());
}
Aggregations