Search in sources :

Example 1 with Level

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, 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);
    }
}
Also used : Level(java.lang.System.Logger.Level) PlatformLogger(sun.util.logging.PlatformLogger) PlatformLogger(sun.util.logging.PlatformLogger) Logger(java.lang.System.Logger)

Example 2 with Level

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, 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);
    }
}
Also used : Level(java.lang.System.Logger.Level) PlatformLogger(sun.util.logging.PlatformLogger) PlatformLogger(sun.util.logging.PlatformLogger) Logger(java.lang.System.Logger)

Example 3 with Level

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) {
    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);
    }
}
Also used : Level(java.lang.System.Logger.Level) PlatformLogger(sun.util.logging.PlatformLogger) PlatformLogger(sun.util.logging.PlatformLogger) Logger(java.lang.System.Logger)

Example 4 with Level

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, Supplier<String> msgSupplier) {
    final PlatformLogger.Bridge platformProxy = platformProxy();
    if (platformProxy == null) {
        // best effort
        if (sourceClass == null && sourceMethod == null) {
            wrapped().log(level.systemLevel(), msgSupplier);
        } 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()));
            }
        }
    } else {
        platformProxy.logp(level, sourceClass, sourceMethod, msgSupplier);
    }
}
Also used : Level(java.lang.System.Logger.Level) PlatformLogger(sun.util.logging.PlatformLogger) PlatformLogger(sun.util.logging.PlatformLogger) Logger(java.lang.System.Logger)

Example 5 with Level

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, Throwable thrown) {
    final PlatformLogger.Bridge platformProxy = platformProxy();
    if (platformProxy == null) {
        // best effort
        if (sourceClass == null && sourceMethod == null) {
            wrapped().log(level.systemLevel(), 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, String.format("[%s %s] %s", sourceClass, sourceMethod, msg), thrown);
            }
        }
    } else {
        platformProxy.logp(level, sourceClass, sourceMethod, msg, thrown);
    }
}
Also used : Level(java.lang.System.Logger.Level) PlatformLogger(sun.util.logging.PlatformLogger) PlatformLogger(sun.util.logging.PlatformLogger) Logger(java.lang.System.Logger)

Aggregations

Level (java.lang.System.Logger.Level)8 Logger (java.lang.System.Logger)7 PlatformLogger (sun.util.logging.PlatformLogger)7 EventListener (org.cojen.tupl.diag.EventListener)1