Java Code Examples for sun.util.logging.PlatformLogger#Level

The following examples show how to use sun.util.logging.PlatformLogger#Level . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlatformLoggerTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void checkLoggerLevel(PlatformLogger logger, Level level) {
    PlatformLogger.Level plevel = PlatformLogger.Level.valueOf(level.getName());
    if (plevel != logger.level()) {
        throw new RuntimeException("Retrieved PlatformLogger level "
                + logger.level()
                + " is not the same as set level " + plevel);
    }

    // check the level set in java.util.logging.Logger
    Logger javaLogger = LogManager.getLogManager().getLogger(logger.getName());
    Level javaLevel = javaLogger.getLevel();
    if (javaLogger.getLevel() != level) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
                + javaLevel + " is not the expected " + level);
    }
}
 
Example 2
Source File: BootstrapLogger.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static LogEvent valueOf(BootstrapLogger bootstrap, PlatformLogger.Level level,
                        String sourceClass, String sourceMethod,
                        ResourceBundle bundle, String msg, Object[] params) {
    return new LogEvent(Objects.requireNonNull(bootstrap),
                        Objects.requireNonNull(level), sourceClass,
                        sourceMethod, bundle, msg, null, params);
}
 
Example 3
Source File: SimpleConsoleLogger.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void logp(PlatformLogger.Level level, String sourceClass,
        String sourceMethod, Throwable thrown, Supplier<String> msgSupplier) {
    if (isLoggable(level)) {
        publish(getCallerInfo(sourceClass, sourceMethod), logLevel(level), msgSupplier.get(), thrown);
    }
}
 
Example 4
Source File: SimpleConsoleLogger.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public final void log(PlatformLogger.Level level, Throwable thrown,
        Supplier<String> msgSupplier) {
    if (isLoggable(level)) {
        publish(getCallerInfo(), logLevel(level), msgSupplier.get(), thrown);
    }
}
 
Example 5
Source File: PlatformLoggerTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void checkPlatformLoggerLevelMapping(Level level) {
    // map the given level to PlatformLogger.Level of the same name and value
    PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName());
    if (platformLevel.intValue() != level.intValue()) {
        throw new RuntimeException("Mismatched level: " + level
                + " PlatformLogger.Level" + platformLevel);
    }
    if (!platformLevel.name().equals(level.getName())) {
        throw new RuntimeException("The value of PlatformLogger." + level.getName() + ".name() is "
                                   + platformLevel.name() + " but expected " + level.getName());
    }
}
 
Example 6
Source File: PlatformLoggerTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkPlatformLoggerLevelMapping(Level level) {
    // map the given level to PlatformLogger.Level of the same name and value
    PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName());
    if (platformLevel.intValue() != level.intValue()) {
        throw new RuntimeException("Mismatched level: " + level
                + " PlatformLogger.Level" + platformLevel);
    }
    if (!platformLevel.name().equals(level.getName())) {
        throw new RuntimeException("The value of PlatformLogger." + level.getName() + ".name() is "
                                   + platformLevel.name() + " but expected " + level.getName());
    }
}
 
Example 7
Source File: BootstrapLogger.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public void logrb(PlatformLogger.Level level, ResourceBundle bundle,
        String msg, Object... params) {
    if (checkBootstrapping()) {
        push(LogEvent.valueOf(this, level, null, null, bundle, msg, params));
    } else {
        final PlatformLogger.Bridge spi = holder.platform();
        spi.logrb(level, bundle, msg, params);
    }
}
 
Example 8
Source File: BootstrapLogger.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
static LogEvent valueOf(BootstrapLogger bootstrap, PlatformLogger.Level level,
                        String sourceClass, String sourceMethod,
                        ResourceBundle bundle, String msg, Object[] params) {
    return new LogEvent(Objects.requireNonNull(bootstrap),
                        Objects.requireNonNull(level), sourceClass,
                        sourceMethod, bundle, msg, null, params);
}
 
Example 9
Source File: BootstrapLogger.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public void log(PlatformLogger.Level level, String msg, Object... params) {
    if (checkBootstrapping()) {
        push(LogEvent.valueOf(this, level, msg, params));
    } else {
        final PlatformLogger.Bridge spi = holder.platform();
        spi.log(level, msg, params);
    }
}
 
Example 10
Source File: BootstrapLogger.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
static LogEvent valueOf(BootstrapLogger bootstrap, PlatformLogger.Level level,
                        String msg, Throwable thrown) {
    return new LogEvent(Objects.requireNonNull(bootstrap),
            Objects.requireNonNull(level), null, null, null, msg, thrown, null);
}
 
Example 11
Source File: SimpleConsoleLogger.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public final void log(PlatformLogger.Level level, Supplier<String> msgSupplier) {
    if (isLoggable(level)) {
        publish(getCallerInfo(), logLevel(level), msgSupplier.get());
    }
}
 
Example 12
Source File: PlatformLoggerTest.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void checkJavaLoggerLevel(Logger logger, Level level) {
    // This method exercise the mapping of java level to platform level
    // when the java level is not one of the standard levels...

    System.out.println("Testing Java Level with: " + level.getName());

    // create a brand new java logger
    Logger javaLogger = (Logger) LoggingSupport.getLogger(logger.getName()+"."+level.getName());

    // Set a non standard java.util.logging.Level on the java logger
    // (except for OFF & ALL - which will remain unchanged)
    int intValue = level.intValue();
    if (level != Level.ALL && level != Level.OFF) {
        intValue -= 7;
    }
    javaLogger.setLevel(Level.parse(String.valueOf(intValue)));

    // check the level set in java.util.logging.Logger
    Level effectiveLevel = javaLogger.getLevel();
    System.out.println("Effective Java Level used is: " + effectiveLevel);

    if (effectiveLevel.intValue() != intValue) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level.intValue() "
                + effectiveLevel.intValue() + " is not the expected " + intValue);
    }
    if (intValue != level.intValue() && javaLogger.getLevel() == level) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
                + effectiveLevel + " is " + level);
    }
    if (intValue == level.intValue() && javaLogger.getLevel() != level) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
                + effectiveLevel + " is not " + level);
    }

    // check the level set in the PlatformLogger
    PlatformLogger plogger = PlatformLogger.getLogger(javaLogger.getName());
    PlatformLogger.Level expected = PlatformLogger.Level.valueOf(level.getName());
    if (plogger.level() != expected) {
        throw new RuntimeException("Retrieved backing PlatformLogger level "
                + plogger.level() + " is not the expected " + expected);

    }
}
 
Example 13
Source File: PlatformLoggerTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static void checkJavaLoggerLevel(Logger logger, Level level) {
    // This method exercise the mapping of java level to platform level
    // when the java level is not one of the standard levels...

    System.out.println("Testing Java Level with: " + level.getName());

    // create a brand new java logger
    Logger javaLogger = (Logger) LoggingSupport.getLogger(logger.getName()+"."+level.getName());

    // Set a non standard java.util.logging.Level on the java logger
    // (except for OFF & ALL - which will remain unchanged)
    int intValue = level.intValue();
    if (level != Level.ALL && level != Level.OFF) {
        intValue -= 7;
    }
    javaLogger.setLevel(Level.parse(String.valueOf(intValue)));

    // check the level set in java.util.logging.Logger
    Level effectiveLevel = javaLogger.getLevel();
    System.out.println("Effective Java Level used is: " + effectiveLevel);

    if (effectiveLevel.intValue() != intValue) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level.intValue() "
                + effectiveLevel.intValue() + " is not the expected " + intValue);
    }
    if (intValue != level.intValue() && javaLogger.getLevel() == level) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
                + effectiveLevel + " is " + level);
    }
    if (intValue == level.intValue() && javaLogger.getLevel() != level) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
                + effectiveLevel + " is not " + level);
    }

    // check the level set in the PlatformLogger
    PlatformLogger plogger = PlatformLogger.getLogger(javaLogger.getName());
    PlatformLogger.Level expected = PlatformLogger.Level.valueOf(level.getName());
    if (plogger.level() != expected) {
        throw new RuntimeException("Retrieved backing PlatformLogger level "
                + plogger.level() + " is not the expected " + expected);

    }
}
 
Example 14
Source File: PlatformLoggerTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void checkJavaLoggerLevel(Logger logger, Level level) {
    // This method exercise the mapping of java level to platform level
    // when the java level is not one of the standard levels...

    System.out.println("Testing Java Level with: " + level.getName());

    // create a brand new java logger
    Logger javaLogger = (Logger) LoggingSupport.getLogger(logger.getName()+"."+level.getName());

    // Set a non standard java.util.logging.Level on the java logger
    // (except for OFF & ALL - which will remain unchanged)
    int intValue = level.intValue();
    if (level != Level.ALL && level != Level.OFF) {
        intValue -= 7;
    }
    javaLogger.setLevel(Level.parse(String.valueOf(intValue)));

    // check the level set in java.util.logging.Logger
    Level effectiveLevel = javaLogger.getLevel();
    System.out.println("Effective Java Level used is: " + effectiveLevel);

    if (effectiveLevel.intValue() != intValue) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level.intValue() "
                + effectiveLevel.intValue() + " is not the expected " + intValue);
    }
    if (intValue != level.intValue() && javaLogger.getLevel() == level) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
                + effectiveLevel + " is " + level);
    }
    if (intValue == level.intValue() && javaLogger.getLevel() != level) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
                + effectiveLevel + " is not " + level);
    }

    // check the level set in the PlatformLogger
    PlatformLogger plogger = PlatformLogger.getLogger(javaLogger.getName());
    PlatformLogger.Level expected = PlatformLogger.Level.valueOf(level.getName());
    if (plogger.level() != expected) {
        throw new RuntimeException("Retrieved backing PlatformLogger level "
                + plogger.level() + " is not the expected " + expected);

    }
}
 
Example 15
Source File: BootstrapLogger.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
static LogEvent valueOf(BootstrapLogger bootstrap,
                        PlatformLogger.Level level, String msg) {
    return new LogEvent(Objects.requireNonNull(bootstrap),
                        Objects.requireNonNull(level), null, null, null,
                        msg, null, null);
}
 
Example 16
Source File: PlatformLoggerTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void checkJavaLoggerLevel(Logger logger, Level level) {
    // This method exercise the mapping of java level to platform level
    // when the java level is not one of the standard levels...

    System.out.println("Testing Java Level with: " + level.getName());

    // create a brand new java logger
    Logger javaLogger = (Logger) LoggingSupport.getLogger(logger.getName()+"."+level.getName());

    // Set a non standard java.util.logging.Level on the java logger
    // (except for OFF & ALL - which will remain unchanged)
    int intValue = level.intValue();
    if (level != Level.ALL && level != Level.OFF) {
        intValue -= 7;
    }
    javaLogger.setLevel(Level.parse(String.valueOf(intValue)));

    // check the level set in java.util.logging.Logger
    Level effectiveLevel = javaLogger.getLevel();
    System.out.println("Effective Java Level used is: " + effectiveLevel);

    if (effectiveLevel.intValue() != intValue) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level.intValue() "
                + effectiveLevel.intValue() + " is not the expected " + intValue);
    }
    if (intValue != level.intValue() && javaLogger.getLevel() == level) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
                + effectiveLevel + " is " + level);
    }
    if (intValue == level.intValue() && javaLogger.getLevel() != level) {
        throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
                + effectiveLevel + " is not " + level);
    }

    // check the level set in the PlatformLogger
    PlatformLogger plogger = PlatformLogger.getLogger(javaLogger.getName());
    PlatformLogger.Level expected = PlatformLogger.Level.valueOf(level.getName());
    if (plogger.level() != expected) {
        throw new RuntimeException("Retrieved backing PlatformLogger level "
                + plogger.level() + " is not the expected " + expected);

    }
}
 
Example 17
Source File: LoggerFinderAPITest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public default void logp(PlatformLogger.Level level, String sourceClass,
                 String sourceMethod, Throwable thrown,
                 Supplier<String> msgSupplier) {
}
 
Example 18
Source File: SimpleConsoleLogger.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public final PlatformLogger.Level getPlatformLevel() {
    return level;
}
 
Example 19
Source File: PlatformLoggerTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void checkLevel(PlatformLogger logger, PlatformLogger.Level level) {
    if (logger.level() != level) {
        throw new RuntimeException("Invalid level for logger " +
            logger.getName() + ": " + logger.level() + " != " + level);
    }
}
 
Example 20
Source File: PlatformLoggerTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static void checkLevel(PlatformLogger logger, PlatformLogger.Level level) {
    if (logger.level() != level) {
        throw new RuntimeException("Invalid level for logger " +
            logger.getName() + ": " + logger.level() + " != " + level);
    }
}