Example usage for java.util.logging Level intValue

List of usage examples for java.util.logging Level intValue

Introduction

In this page you can find the example usage for java.util.logging Level intValue.

Prototype

public final int intValue() 

Source Link

Document

Get the integer value for this level.

Usage

From source file:alma.acs.logging.adapters.JacORBFilter.java

/**
 * Sets the log level that allows this filter to discard log records.
 * This is necessary because our extended filter functionality may downgrade log levels.
 * Log records that passed the level check before may then become invalid. 
 * The JDK does not foresee this, that's why we must discard them here based on the level. 
 *///from   ww  w . j a va  2 s  .  co  m
public void setLogLevel(Level level) {
    if (level != null) {
        logLevel = level.intValue();
    }
    //      else {
    //         System.out.println("&&&& JacORB filter got null level");
    //      }
}

From source file:com.twitter.common.net.http.handlers.LogConfig.java

private void maybeAdjustHandlerLevels(Logger logger, Level newLevel) {
    do {//from  w  w w  .j a va 2 s. co m
        for (Handler handler : logger.getHandlers()) {
            Level handlerLevel = handler.getLevel();
            if (newLevel.intValue() < handlerLevel.intValue()) {
                handler.setLevel(newLevel);
            }
        }
    } while (logger.getUseParentHandlers() && (logger = logger.getParent()) != null);
}

From source file:org.callimachusproject.repository.CalliRepository.java

private void setHandlerLevel(Logger logger, Level level) {
    if (logger.getParent() != null) {
        setHandlerLevel(logger.getParent(), level);
    }//  ww  w.  ja  v a  2  s  .c  om
    Handler[] handlers = logger.getHandlers();
    if (handlers != null) {
        for (Handler handler : handlers) {
            if (handler.getLevel().intValue() > level.intValue()) {
                handler.setLevel(level);
            }
        }
    }
}

From source file:com.machinepublishers.jbrowserdriver.Settings.java

private Settings(Settings.Builder builder, Map properties) {
    Settings.Builder defaults = Settings.builder();

    Dimension screen = builder.screen == null ? defaults.screen : builder.screen;
    this.screenWidth = parse(properties, PropertyName.SCREEN_WIDTH, screen.getWidth());
    this.screenHeight = parse(properties, PropertyName.SCREEN_HEIGHT, screen.getHeight());
    this.cacheEntrySize = parse(properties, PropertyName.CACHE_ENTRY_SIZE, builder.cacheEntrySize);
    this.cacheEntries = parse(properties, PropertyName.CACHE_ENTRIES, builder.cacheEntries);
    this.cache = parse(properties, PropertyName.CACHE, builder.cache);
    this.ignoreDialogs = parse(properties, PropertyName.IGNORE_DIALOGS, builder.ignoreDialogs);
    this.saveAttachments = parse(properties, PropertyName.SAVE_ATTACHMENTS, builder.saveAttachments);
    this.saveMedia = parse(properties, PropertyName.SAVE_MEDIA, builder.saveMedia);
    this.ajaxWait = parse(properties, PropertyName.AJAX_WAIT, builder.ajaxWait);
    this.ajaxResourceTimeout = parse(properties, PropertyName.AJAX_RESOURCE_TIMEOUT,
            builder.ajaxResourceTimeout);
    this.blockAds = parse(properties, PropertyName.BLOCK_ADS, builder.blockAds);
    this.quickRender = parse(properties, PropertyName.QUICK_RENDER, builder.quickRender);
    this.maxRouteConnections = parse(properties, PropertyName.MAX_ROUTE_CONNECTIONS,
            builder.maxRouteConnections);
    this.maxConnections = parse(properties, PropertyName.MAX_CONNECTIONS, builder.maxConnections);
    this.logJavascript = parse(properties, PropertyName.LOG_JAVASCRIPT, builder.logJavascript);
    if (properties.get(PropertyName.JAVA_OPTIONS.propertyName) != null) {
        this.javaOptions = Collections.unmodifiableList(
                Arrays.asList(properties.get(PropertyName.JAVA_OPTIONS.propertyName).toString().split("\t")));
    } else if (builder.javaOptions == null) {
        this.javaOptions = Collections.unmodifiableList(new ArrayList<String>());
    } else {//from   w ww  . j av  a  2  s.co m
        this.javaOptions = Collections.unmodifiableList(Arrays.asList(builder.javaOptions));
    }
    this.customClasspath = this.javaOptions.contains("-classpath") || this.javaOptions.contains("-cp");
    this.javaBinary = parse(properties, PropertyName.JAVA_BINARY, builder.javaBinary);
    this.javaExportModules = parse(properties, PropertyName.JAVA_EXPORT_MODULES, builder.javaExportModules);
    if (properties.get(PropertyName.WIRE_CONSOLE.propertyName) != null) {
        System.err.println(
                "jBrowserDriver: The jbd.wireconsole setting is deprecated and will be removed in v2.0.0. Use jbd.logwire, jbd.logger, or jbd.logsmax instead.");
        this.logWire = parse(properties, PropertyName.WIRE_CONSOLE, builder.logWire);
    } else {
        this.logWire = parse(properties, PropertyName.LOG_WIRE, builder.logWire);
    }
    if (properties.get(PropertyName.TRACE_CONSOLE.propertyName) != null) {
        System.err.println(
                "jBrowserDriver: The jbd.traceconsole setting is deprecated and will be removed in v2.0.0. Use jbd.logtrace, jbd.logger, or jbd.logsmax instead.");
        this.logTrace = parse(properties, PropertyName.TRACE_CONSOLE, builder.logTrace);
    } else {
        this.logTrace = parse(properties, PropertyName.LOG_TRACE, builder.logTrace);
    }
    if (properties.get(PropertyName.WARN_CONSOLE.propertyName) != null) {
        System.err.println(
                "jBrowserDriver: The jbd.warnconsole setting is deprecated and will be removed in v2.0.0. Use jbd.logwarnings, jbd.logger, or jbd.logsmax instead.");
        this.logWarnings = parse(properties, PropertyName.WARN_CONSOLE, builder.logWarnings);
    } else {
        this.logWarnings = parse(properties, PropertyName.LOG_WARNINGS, builder.logWarnings);
    }
    if (properties.get(PropertyName.MAX_LOGS.propertyName) != null) {
        System.err.println(
                "jBrowserDriver: The jbd.maxlogs setting is deprecated and will be removed in v2.0.0. Use jbd.logsmax, jbd.logwire, jbd.logtrace, or jbd.logwarnings instead.");
        this.logsMax = parse(properties, PropertyName.MAX_LOGS, builder.logsMax);
    } else {
        this.logsMax = parse(properties, PropertyName.LOGS_MAX, builder.logsMax);
    }
    this.logger = parse(properties, PropertyName.LOGGER, builder.logger);
    if (this.logger == null) {
        this.loggerLevel = Level.OFF.intValue();
    } else {
        Level curLevel = logger.getLevel();
        this.loggerLevel = curLevel == null ? Level.INFO.intValue() : curLevel.intValue();
    }
    this.hostnameVerification = parse(properties, PropertyName.HOSTNAME_VERIFICATION,
            builder.hostnameVerification);
    this.javascript = parse(properties, PropertyName.JAVASCRIPT, builder.javascript);
    this.socketTimeout = parse(properties, PropertyName.SOCKET_TIMEOUT_MS, builder.socketTimeout);
    this.connectTimeout = parse(properties, PropertyName.CONNECT_TIMEOUT_MS, builder.connectTimeout);
    this.connectionReqTimeout = parse(properties, PropertyName.CONNECTION_REQ_TIMEOUT_MS,
            builder.connectionReqTimeout);
    this.cacheDir = parse(properties, PropertyName.CACHE_DIR, builder.cacheDir);
    this.userDataDirectory = parse(properties, PropertyName.USER_DATA_DIRECTORY, builder.userDataDirectory);
    this.csrfRequestToken = parse(properties, PropertyName.CSRF_REQUEST_TOKEN, builder.csrfRequestToken);
    this.csrfResponseToken = parse(properties, PropertyName.CSRF_RESPONSE_TOKEN, builder.csrfResponseToken);
    this.host = parse(properties, PropertyName.HOST, builder.host);
    String portRangesTmp = null;
    int processesTmp = -1;
    if (properties.get(PropertyName.PORTS.propertyName) == null
            && properties.get(PropertyName.PORT_RANGES.propertyName) == null
            && properties.get(PropertyName.PROCESSES.propertyName) == null) {
        if (builder.processes > -1) {
            processesTmp = builder.processes;
        } else {
            portRangesTmp = builder.portRanges;
        }
    } else if (properties.get(PropertyName.PORTS.propertyName) != null) {
        System.err.println(
                "jBrowserDriver: The jbd.ports property is deprecated and will be removed in v2.0.0. Refer to Settings.Builder.processes(..) API documentation.");
        String portString = properties.get(PropertyName.PORTS.propertyName).toString();
        Collection<Long> ports = new LinkedHashSet<Long>();
        String[] ranges = portString.split(",");
        for (String range : ranges) {
            String[] bounds = range.split("-");
            long low = Long.parseLong(bounds[0]);
            long high = bounds.length > 1 ? Long.parseLong(bounds[1]) : low;
            for (long j = low; j <= high; j++) {
                ports.add(j);
            }
        }
        processesTmp = ports.size();
    } else if (properties.get(PropertyName.PORT_RANGES.propertyName) != null) {
        portRangesTmp = properties.get(PropertyName.PORT_RANGES.propertyName).toString();
    } else {
        processesTmp = Integer.parseInt(properties.get(PropertyName.PROCESSES.propertyName).toString());
    }
    if (portRangesTmp == null) {
        this.portGroups = parsePorts(processesTmp);
    } else {
        this.portGroups = parsePorts(portRangesTmp);
    }

    //backwards compatible property name for versions <= 0.9.1
    boolean headlessTmp = parse(properties, PropertyName.HEADLESS, builder.headless);
    headlessTmp = System.getProperty(PropertyName.HEADLESS.propertyName) == null
            && System.getProperty("jbd.browsergui") != null
                    ? !Boolean.parseBoolean(System.getProperty("jbd.browsergui"))
                    : headlessTmp;
    this.headless = headlessTmp;
    if (System.getProperty("jbd.browsergui") != null) {
        System.err.println(
                "jBrowserDriver: The jbd.browsergui property is deprecated and will be removed in v2.0.0. Use jbd.headless property instead.");
    }

    //backwards compatible property name for versions <= 0.9.1
    String sslTmp = parse(properties, PropertyName.SSL, builder.ssl);
    sslTmp = System.getProperty(PropertyName.SSL.propertyName) == null
            && System.getProperty("jbd.pemfile") != null ? System.getProperty("jbd.pemfile") : sslTmp;
    this.ssl = sslTmp;
    if (System.getProperty("jbd.pemfile") != null) {
        System.err.println(
                "jBrowserDriver: The jbd.pemfile property is deprecated and will be removed in v2.0.0. Use jbd.ssl property instead.");
    }

    RequestHeaders requestHeadersTmp = builder.requestHeaders;
    UserAgent userAgentTmp = builder.userAgent;
    if (properties.get(PropertyName.USER_AGENT.propertyName) != null) {
        String value = properties.get(PropertyName.USER_AGENT.propertyName).toString();
        if ("tor".equalsIgnoreCase(value)) {
            requestHeadersTmp = RequestHeaders.TOR;
            userAgentTmp = UserAgent.TOR;
        } else if ("chrome".equalsIgnoreCase(value)) {
            requestHeadersTmp = RequestHeaders.CHROME;
            userAgentTmp = UserAgent.CHROME;
        }
    }
    requestHeadersTmp = requestHeadersTmp == null ? defaults.requestHeaders : requestHeadersTmp;
    userAgentTmp = userAgentTmp == null ? defaults.userAgent : userAgentTmp;
    this.requestHeaders = requestHeadersTmp;
    this.userAgentString = userAgentTmp.userAgentString();

    ProxyConfig proxyTmp = builder.proxy;
    if (properties.get(PropertyName.PROXY_TYPE.propertyName) != null
            && properties.get(PropertyName.PROXY_HOST.propertyName) != null
            && properties.get(PropertyName.PROXY_PORT.propertyName) != null) {
        ProxyConfig.Type type = ProxyConfig.Type
                .valueOf(properties.get(PropertyName.PROXY_TYPE.propertyName).toString());
        String host = properties.get(PropertyName.PROXY_HOST.propertyName).toString();
        int port = Integer.parseInt(properties.get(PropertyName.PROXY_PORT.propertyName).toString());
        String username = parse(properties, PropertyName.PROXY_USERNAME, (String) null);
        String password = parse(properties, PropertyName.PROXY_PASSWORD, (String) null);
        Object expectContinue = properties.get(PropertyName.PROXY_EXPECT_CONTINUE.propertyName);
        if (expectContinue == null) {
            proxyTmp = new ProxyConfig(type, host, port, username, password);
        } else {
            proxyTmp = new ProxyConfig(type, host, port, username, password,
                    Boolean.parseBoolean(expectContinue.toString()));
        }
    }
    this.proxy = proxyTmp;

    Timezone timezoneTmp = builder.timezone;
    if (properties.get(PropertyName.TIMEZONE.propertyName) != null) {
        timezoneTmp = Timezone.byName(properties.get(PropertyName.TIMEZONE.propertyName).toString());
    }
    timezoneTmp = timezoneTmp == null ? defaults.timezone : timezoneTmp;
    String scriptId = Util.randomPropertyName();
    String headScriptTmp = parse(properties, PropertyName.HEAD_SCRIPT, builder.headScript);
    StringBuilder scriptBuilder = new StringBuilder();
    StringBuilder scriptContentBuilder = new StringBuilder();
    scriptBuilder.append("<script id='").append(scriptId).append("' language='javascript'>");
    scriptContentBuilder.append("(function(){try{");
    scriptContentBuilder.append(userAgentTmp.script());
    scriptContentBuilder.append(timezoneTmp.script());
    if (headScriptTmp != null) {
        scriptContentBuilder.append(headScriptTmp);
    }
    scriptContentBuilder.append("}catch(e){}})();");
    this.scriptContent = scriptContentBuilder.toString();
    scriptBuilder.append(this.scriptContent);
    scriptBuilder.append(
            "(function(){document.getElementsByTagName('head')[0].removeChild(document.getElementById('");
    scriptBuilder.append(scriptId);
    scriptBuilder.append("'));})();");
    scriptBuilder.append("</script>");
    this.script = scriptBuilder.toString();
}

From source file:org.ebayopensource.turmeric.eclipse.core.logging.PluginLogDelegateHandler.java

private int level(final Level level) {
    if (level == null)
        return IStatus.INFO;
    if (level.intValue() >= Level.SEVERE.intValue())
        return IStatus.ERROR;
    if (level.intValue() > Level.WARNING.intValue())
        return IStatus.WARNING;
    return IStatus.INFO;
}

From source file:org.geoserver.config.util.XStreamPersister.java

void log(Level level, String msg) {
    if ((LOGGER.isLoggable(level) && forceLevel.intValue() <= level.intValue())) {
        LOGGER.log(level, msg);//from   w  ww  .j  av a 2s. c  om
    }
}

From source file:org.geotoolkit.util.logging.CommonsLogger.java

/**
 * Returns {@code true} if the specified level is loggable.
 *//*w w w. j  a va  2 s.  com*/
@Override
@SuppressWarnings("fallthrough")
public boolean isLoggable(final Level level) {
    final int n = level.intValue();
    switch (n / 100) {
    default: {
        switch (n) { // Special cases (should not occur often).
        case Integer.MIN_VALUE:
            return true; // ALL
        case Integer.MAX_VALUE:
            return false; // OFF
        default:
            return n >= 0 && logger.isFatalEnabled();
        }
    }
    case 10:
        return logger.isErrorEnabled(); // SEVERE
    case 9:
        return logger.isWarnEnabled(); // WARNING
    case 8: // INFO
    case 7:
        return logger.isInfoEnabled(); // CONFIG
    case 6: // (not allocated)
    case 5:
        return logger.isDebugEnabled(); // FINE
    case 4: // FINER
    case 3: // FINEST
    case 2: // (not allocated)
    case 1: // (not allocated)
    case 0:
        return logger.isTraceEnabled(); // ALL
    }
}

From source file:org.geotoolkit.util.logging.CommonsLogger.java

/**
 * Logs a record at the specified level.
 *///from  w  w w . j  a v a  2 s.c o m
@Override
@SuppressWarnings("fallthrough")
public void log(final Level level, final String message, final Throwable thrown) {
    final int n = level.intValue();
    switch (n / 100) {
    default: {
        // MAX_VALUE is a special value for Level.OFF. Otherwise and
        // if positive, log to fatal since we are greater than SEVERE.
        if (n != Integer.MAX_VALUE || n >= 0) {
            logger.fatal(message, thrown);
        }
        break;
    }
    case 10:
        logger.error(message, thrown);
        break; // SEVERE
    case 9:
        logger.warn(message, thrown);
        break; // WARNING
    case 8: // INFO
    case 7:
        logger.info(message, thrown);
        break; // CONFIG
    case 6: // (not allocated)
    case 5:
        logger.debug(message, thrown);
        break; // FINE
    case 4: // FINER
    case 3: // FINEST
    case 2: // (not allocated)
    case 1: // (not allocated)
    case 0:
        logger.trace(message, thrown);
        break; // ALL
    }
}

From source file:org.geotools.util.logging.CommonsLogger.java

/**
 * Returns {@code true} if the specified level is loggable.
 */// w w w.  j ava2 s .c om
@SuppressWarnings("fallthrough")
public boolean isLoggable(final Level level) {
    final int n = level.intValue();
    switch (n / 100) {
    default: {
        switch (n) { // Special cases (should not occur often).
        case Integer.MIN_VALUE:
            return true; // ALL
        case Integer.MAX_VALUE:
            return false; // OFF
        default:
            return n >= 0 && logger.isFatalEnabled();
        }
    }
    case 10:
        return logger.isErrorEnabled(); // SEVERE
    case 9:
        return logger.isWarnEnabled(); // WARNING
    case 8: // INFO
    case 7:
        return logger.isInfoEnabled(); // CONFIG
    case 6: // (not allocated)
    case 5:
        return logger.isDebugEnabled(); // FINE
    case 4: // FINER
    case 3: // FINEST
    case 2: // (not allocated)
    case 1: // (not allocated)
    case 0:
        return logger.isTraceEnabled(); // ALL
    }
}

From source file:org.mili.core.logging.java.JavaAdapter.java

boolean isFatal() {
    Level level = logger.getLevel();
    return isOn() && (isAll() || Level.SEVERE.intValue() >= level.intValue());
}