Search in sources :

Example 1 with PlatformLogger

use of sun.util.logging.PlatformLogger in project jdk8u_jdk by JetBrains.

the class PlatformLoggerTest method main.

public static void main(String[] args) throws Exception {
    final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo";
    final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar";
    final String GOO_PLATFORM_LOGGER = "test.platformlogger.goo";
    final String BAR_LOGGER = "test.logger.bar";
    PlatformLogger goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER);
    // test the PlatformLogger methods
    testLogMethods(goo);
    // Create a platform logger using the default
    PlatformLogger foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER);
    checkPlatformLogger(foo, FOO_PLATFORM_LOGGER);
    // create a java.util.logging.Logger
    // now java.util.logging.Logger should be created for each platform logger
    Logger logger = Logger.getLogger(BAR_LOGGER);
    logger.setLevel(Level.WARNING);
    PlatformLogger bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER);
    checkPlatformLogger(bar, BAR_PLATFORM_LOGGER);
    // test the PlatformLogger methods
    testLogMethods(goo);
    testLogMethods(bar);
    checkLogger(FOO_PLATFORM_LOGGER, Level.FINER);
    checkLogger(BAR_PLATFORM_LOGGER, Level.FINER);
    checkLogger(GOO_PLATFORM_LOGGER, null);
    checkLogger(BAR_LOGGER, Level.WARNING);
    foo.setLevel(PlatformLogger.Level.SEVERE);
    checkLogger(FOO_PLATFORM_LOGGER, Level.SEVERE);
    checkPlatformLoggerLevels(foo, bar);
}
Also used : PlatformLogger(sun.util.logging.PlatformLogger) PlatformLogger(sun.util.logging.PlatformLogger)

Example 2 with PlatformLogger

use of sun.util.logging.PlatformLogger in project jdk8u_jdk by JetBrains.

the class PlatformLoggerTest method checkLoggerLevel.

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

Example 3 with PlatformLogger

use of sun.util.logging.PlatformLogger in project jdk8u_jdk by JetBrains.

the class InputContext method logCreationFailed.

private void logCreationFailed(Throwable throwable) {
    PlatformLogger logger = PlatformLogger.getLogger("sun.awt.im");
    if (logger.isLoggable(PlatformLogger.Level.CONFIG)) {
        String errorTextFormat = Toolkit.getProperty("AWT.InputMethodCreationFailed", "Could not create {0}. Reason: {1}");
        Object[] args = { inputMethodLocator.getDescriptor().getInputMethodDisplayName(null, Locale.getDefault()), throwable.getLocalizedMessage() };
        MessageFormat mf = new MessageFormat(errorTextFormat);
        logger.config(mf.format(args));
    }
}
Also used : MessageFormat(java.text.MessageFormat) PlatformLogger(sun.util.logging.PlatformLogger)

Example 4 with PlatformLogger

use of sun.util.logging.PlatformLogger in project jdk8u_jdk by JetBrains.

the class HttpsClient method New.

static HttpClient New(SSLSocketFactory sf, URL url, HostnameVerifier hv, Proxy p, boolean useCache, int connectTimeout, HttpURLConnection httpuc) throws IOException {
    if (p == null) {
        p = Proxy.NO_PROXY;
    }
    PlatformLogger logger = HttpURLConnection.getHttpLogger();
    if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
        logger.finest("Looking for HttpClient for URL " + url + " and proxy value of " + p);
    }
    HttpsClient ret = null;
    if (useCache) {
        /* see if one's already around */
        ret = (HttpsClient) kac.get(url, sf);
        if (ret != null && httpuc != null && httpuc.streaming() && httpuc.getRequestMethod() == "POST") {
            if (!ret.available())
                ret = null;
        }
        if (ret != null) {
            if ((ret.proxy != null && ret.proxy.equals(p)) || (ret.proxy == null && p == Proxy.NO_PROXY)) {
                synchronized (ret) {
                    ret.cachedHttpClient = true;
                    assert ret.inCache;
                    ret.inCache = false;
                    if (httpuc != null && ret.needsTunneling())
                        httpuc.setTunnelState(TUNNELING);
                    if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
                        logger.finest("KeepAlive stream retrieved from the cache, " + ret);
                    }
                }
            } else {
                // to the same host will not use the same proxy.
                synchronized (ret) {
                    if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
                        logger.finest("Not returning this connection to cache: " + ret);
                    }
                    ret.inCache = false;
                    ret.closeServer();
                }
                ret = null;
            }
        }
    }
    if (ret == null) {
        ret = new HttpsClient(sf, url, p, connectTimeout);
    } else {
        SecurityManager security = System.getSecurityManager();
        if (security != null) {
            if (ret.proxy == Proxy.NO_PROXY || ret.proxy == null) {
                security.checkConnect(InetAddress.getByName(url.getHost()).getHostAddress(), url.getPort());
            } else {
                security.checkConnect(url.getHost(), url.getPort());
            }
        }
        ret.url = url;
    }
    ret.setHostnameVerifier(hv);
    return ret;
}
Also used : PlatformLogger(sun.util.logging.PlatformLogger)

Example 5 with PlatformLogger

use of sun.util.logging.PlatformLogger in project jdk8u_jdk by JetBrains.

the class LocaleServiceProviderPool method config.

static void config(Class<? extends Object> caller, String message) {
    PlatformLogger logger = PlatformLogger.getLogger(caller.getCanonicalName());
    logger.config(message);
}
Also used : PlatformLogger(sun.util.logging.PlatformLogger)

Aggregations

PlatformLogger (sun.util.logging.PlatformLogger)14 Level (sun.util.logging.PlatformLogger.Level)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 InvalidObjectException (java.io.InvalidObjectException)1 StreamTokenizer (java.io.StreamTokenizer)1 PrivilegedActionException (java.security.PrivilegedActionException)1 MessageFormat (java.text.MessageFormat)1 DateTimeException (java.time.DateTimeException)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Vector (java.util.Vector)1