Java Code Examples for java.util.logging.Level.parse()

The following are Jave code examples for showing how to use parse() of the java.util.logging.Level class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Pogamut3   File: AgentLogger.java   View Source Code Vote up 6 votes
@Inject
public AgentLogger(IAgentId agentId) {
    super(agentId);
    this.categories = new LogCategories();
    String level = Pogamut.getPlatform().getProperty(PogamutProperty.POGAMUT_LOGGER_LEVEL_DEFAULT.getKey());
    Level logLevel;
    if (level == null) {
    	System.err.println("No default level for AgentLogger is specified! Setting WARNING.");
    	logLevel = Level.WARNING;
    } else {
    	try {
    		logLevel = Level.parse(level);
    	} catch (Exception e) {
    		System.err.println("Default AgentLogger level is malformed, could not par log level from: " + level);
    		System.err.println("Setting log level to WARNING.");
    		logLevel = Level.WARNING;
    	}
    }
    if (logLevel != null) {
    	setLevel(logLevel);
    } else {
    	setLevel(Level.WARNING);
    }
}
 
Example 2
Project: spring-boot-data-source-decorator   File: ProxyDataSourceBuilderConfigurer.java   View Source Code Vote up 6 votes
private Level toJULLogLevel(String logLevel) {
    if (logLevel == null) {
        return null;
    }
    try {
        return Level.parse(logLevel);
    }
    catch (IllegalArgumentException e) {
        if (logLevel.equalsIgnoreCase("DEBUG")) {
            return Level.FINE;
        }
        if (logLevel.equalsIgnoreCase("WARN")) {
            return Level.WARNING;
        }
        throw new IllegalArgumentException("Unresolved log level " + logLevel + " for java.util.logging", e);
    }
}
 
Example 3
Project: OpenJSharp   File: LoggingOption.java   View Source Code Vote up 6 votes
/**
 * Initialization function that is called to instantiate the logging system. It takes
 * logger names (keys) and logging labels respectively
 *
 * @param map a map where the key is a logger name and the value a logging level
 * @throws IllegalArgumentException if level or names cannot be parsed
 */
private void initialize(final Map<String, String> logMap) throws IllegalArgumentException {
    try {
        for (final Entry<String, String> entry : logMap.entrySet()) {
            Level level;
            final String name        = lastPart(entry.getKey());
            final String levelString = entry.getValue().toUpperCase(Locale.ENGLISH);
            final boolean isQuiet;

            if ("".equals(levelString)) {
                level = Level.INFO;
                isQuiet = false;
            } else if ("QUIET".equals(levelString)) {
                level = Level.INFO;
                isQuiet = true;
            } else {
                level = Level.parse(levelString);
                isQuiet = false;
            }

            loggers.put(name, new LoggerInfo(level, isQuiet));
        }
    } catch (final IllegalArgumentException | SecurityException e) {
        throw e;
    }
}
 
Example 4
Project: OpenJSharp   File: MetroTubelineAssembler.java   View Source Code Vote up 6 votes
private Level getLevelValue(String propertyName) {
    Level retVal = null;

    String stringValue = System.getProperty(propertyName);
    if (stringValue != null) {
        // if value is not null => property is set, we will try to override the default logging level
        LOGGER.fine(TubelineassemblyMessages.MASM_0018_MSG_LOGGING_SYSTEM_PROPERTY_SET_TO_VALUE(propertyName, stringValue));
        try {
            retVal = Level.parse(stringValue);
        } catch (IllegalArgumentException ex) {
            LOGGER.warning(TubelineassemblyMessages.MASM_0019_MSG_LOGGING_SYSTEM_PROPERTY_ILLEGAL_VALUE(propertyName, stringValue), ex);
        }
    }

    return retVal;
}
 
Example 5
Project: monarch   File: GfshConfig.java   View Source Code Vote up 6 votes
private static Level getLogLevel(final String logLevelString) {
  try {
    String logLevelAsString = StringUtils.isBlank(logLevelString) ? "" : logLevelString.trim(); // trim
                                                                                                // spaces
                                                                                                // if
                                                                                                // any
    // To support level NONE, used by GemFire
    if ("NONE".equalsIgnoreCase(logLevelAsString)) {
      logLevelAsString = Level.OFF.getName();
    }
    // To support level ERROR, used by GemFire, fall to WARNING
    if ("ERROR".equalsIgnoreCase(logLevelAsString)) {
      logLevelAsString = Level.WARNING.getName();
    }
    return Level.parse(logLevelAsString.toUpperCase());
  } catch (IllegalArgumentException e) {
    System.out.println(e.getMessage());
    return DEFAULT_LOGLEVEL;
  }
}
 
Example 6
Project: openjdk-jdk10   File: LoggingOption.java   View Source Code Vote up 6 votes
/**
 * Initialization function that is called to instantiate the logging system. It takes
 * logger names (keys) and logging labels respectively
 *
 * @param map a map where the key is a logger name and the value a logging level
 * @throws IllegalArgumentException if level or names cannot be parsed
 */
private void initialize(final Map<String, String> logMap) throws IllegalArgumentException {
    try {
        for (final Entry<String, String> entry : logMap.entrySet()) {
            Level level;
            final String name        = lastPart(entry.getKey());
            final String levelString = entry.getValue().toUpperCase(Locale.ENGLISH);
            final boolean isQuiet;

            if ("".equals(levelString)) {
                level = Level.INFO;
                isQuiet = false;
            } else if ("QUIET".equals(levelString)) {
                level = Level.INFO;
                isQuiet = true;
            } else {
                level = Level.parse(levelString);
                isQuiet = false;
            }

            loggers.put(name, new LoggerInfo(level, isQuiet));
        }
    } catch (final IllegalArgumentException | SecurityException e) {
        throw e;
    }
}
 
Example 7
Project: openjdk-jdk10   File: MetroTubelineAssembler.java   View Source Code Vote up 6 votes
private Level getLevelValue(String propertyName) {
    Level retVal = null;

    String stringValue = System.getProperty(propertyName);
    if (stringValue != null) {
        // if value is not null => property is set, we will try to override the default logging level
        LOGGER.fine(TubelineassemblyMessages.MASM_0018_MSG_LOGGING_SYSTEM_PROPERTY_SET_TO_VALUE(propertyName, stringValue));
        try {
            retVal = Level.parse(stringValue);
        } catch (IllegalArgumentException ex) {
            LOGGER.warning(TubelineassemblyMessages.MASM_0019_MSG_LOGGING_SYSTEM_PROPERTY_ILLEGAL_VALUE(propertyName, stringValue), ex);
        }
    }

    return retVal;
}
 
Example 8
Project: Pogamut3   File: NavigationEvaluationTask.java   View Source Code Vote up 5 votes
/**
 * Creates task from command line arguments.
 *
 * @param args Command line arguments.
 * @return Task built from command line arguments.
 */
@Deprecated
public static NavigationEvaluationTask buildFromArgs(String[] args) {
    //TODO: Check validity of args?
    if (args.length == 8) {
        return new NavigationEvaluationTask(args[0], args[1], args[2], Boolean.parseBoolean(args[3]), Integer.parseInt(args[4]), args[5], RecordType.valueOf(args[6]), Level.parse(args[7]));
    }
    return new NavigationEvaluationTask();
}
 
Example 9
Project: marathonv5   File: JavaServer.java   View Source Code Vote up 5 votes
private Level getLogLevel(JSONObject query) {
    JSONObject prefs;
    if (query.has("requiredCapabilities") && query.getJSONObject("requiredCapabilities").has("loggingPrefs")) {
        prefs = query.getJSONObject("requiredCapabilities").getJSONObject("loggingPrefs");
    } else if (query.has("desiredCapabilities") && query.getJSONObject("desiredCapabilities").has("loggingPrefs")) {
        prefs = query.getJSONObject("desiredCapabilities").getJSONObject("loggingPrefs");
    } else {
        return Level.ALL;
    }
    if (prefs.has("driver")) {
        return Level.parse(prefs.getString("driver"));
    }
    return Level.ALL;
}
 
Example 10
Project: marathonv5   File: JavaServer.java   View Source Code Vote up 5 votes
private Level getLogLevel(JSONObject query) {
    JSONObject prefs;
    if (query.has("requiredCapabilities") && query.getJSONObject("requiredCapabilities").has("loggingPrefs")) {
        prefs = query.getJSONObject("requiredCapabilities").getJSONObject("loggingPrefs");
    } else if (query.has("desiredCapabilities") && query.getJSONObject("desiredCapabilities").has("loggingPrefs")) {
        prefs = query.getJSONObject("desiredCapabilities").getJSONObject("loggingPrefs");
    } else {
        return Level.ALL;
    }
    if (prefs.has("driver")) {
        return Level.parse(prefs.getString("driver"));
    }
    return Level.ALL;
}
 
Example 11
Project: domino   File: SerializableLogRecordMapper.java   View Source Code Vote up 5 votes
public static LogRecord asLogRecord(SerializableLogRecord serializableLogRecord) {
    LogRecord logRecord = new LogRecord(Level.parse(serializableLogRecord.level), serializableLogRecord.message);
    logRecord.setLoggerName(serializableLogRecord.loggerName);
    logRecord.setMillis(serializableLogRecord.millis);
    logRecord.setThrown(JsonLogRecordThrowable.fromJsonString(serializableLogRecord.thrown));
    return logRecord;
}
 
Example 12
Project: OpenJSharp   File: MessageDumpingFeature.java   View Source Code Vote up 5 votes
@FeatureConstructor({"enabled", "messageLoggingRoot", "messageLoggingLevel", "storeMessages"})
public MessageDumpingFeature(boolean enabled, String msgLogRoot, String msgLogLevel, boolean storeMessages) {
    // this constructor is here just to satisfy JAX-WS specification requirements
    this(msgLogRoot, Level.parse(msgLogLevel), storeMessages);

    super.enabled = enabled;
}
 
Example 13
Project: openjdk-jdk10   File: MessageDumpingFeature.java   View Source Code Vote up 5 votes
@FeatureConstructor({"enabled", "messageLoggingRoot", "messageLoggingLevel", "storeMessages"})
public MessageDumpingFeature(boolean enabled, String msgLogRoot, String msgLogLevel, boolean storeMessages) {
    // this constructor is here just to satisfy JAX-WS specification requirements
    this(msgLogRoot, Level.parse(msgLogLevel), storeMessages);

    super.enabled = enabled;
}
 
Example 14
Project: incubator-netbeans   File: LogRecords.java   View Source Code Vote up 4 votes
static Level parseLevel(String lev) {
    return "USER".equals(lev) ? Level.SEVERE : Level.parse(lev);
}
 
Example 15
Project: KSP-AGuS-Automatic-Guidance-System   File: DATA_SETTINGS.java   View Source Code Vote up 4 votes
public Level getLogLevel() {
	Level level = Level.parse(properties.getProperty("log.level"));
	return level;
}
 
Example 16
Project: incubator-netbeans   File: RepositoryUpdater.java   View Source Code Vote up 4 votes
private void checkRootCollection(Collection<? extends URL> roots) {
    if (!shouldDoNothing || roots.isEmpty() || getCancelRequest().isRaised()) {
        return;
    }
    int stubCount = 0;
    // ignore all files, which reside in IDE installation (in various clusters)
    // the ignored files must be located 1 subdirectory beneath the cluster 
    // directory
    for (URL u : roots) {
        String path = u.getPath();
        if (path == null || !path.endsWith("stubs.zip!/")) { // NOI18N
            break;
        }
        FileObject f = URLMapper.findFileObject(u);
        if (f == null) {
            break;
        }
        // !/ is a root inside archive, get the archive which encapsulates it -> normal FS
        FileObject archive = FileUtil.getArchiveFile(f);
        // quick check - if the archive is not on OS FS, bail out.
        if (archive == null) {
            break;
        }
        final File archiveFile = FileUtil.toFile(archive);
        if (archiveFile == null) {
            break;
        }
        // 1 level up = dir-in-cluster. 2 levels up = cluster dir
        FileObject parent = archive.getParent();
        if (parent == null) {
            break;
        }
        parent = parent.getParent();
        if (parent == null) {
            break;
        }
        String clusterPath = FileUtil.getRelativePath(parent, archive);
        File file = InstalledFileLocator.getDefault().locate(clusterPath, null, false);
        if (file == null || !file.equals(archiveFile)) {
            break;
        }
        stubCount++;
    }
    if (stubCount == roots.size()) {
        return;
    }
    if (previousLevel == null) {
        previousLevel = LOGGER.getLevel() == null ? Level.ALL : LOGGER.getLevel();
        Level toSet;

        try {
            toSet = Level.parse(System.getProperty("RepositoryUpdate.increasedLogLevel", "FINE"));
        } catch (IllegalArgumentException ex) {
            toSet = Level.FINE;
        }

        LOGGER.setLevel(toSet);
        LOGGER.warning("Non-empty roots encountered while no projects are opened; loglevel increased");

        Collection<? extends PathRecognizer> recogs = Lookup.getDefault().lookupAll(PathRecognizer.class);
        PathRecognizerRegistry reg = PathRecognizerRegistry.getDefault();

        dumpGlobalRegistry("Binary Libraries", reg.getBinaryLibraryIds());
        dumpGlobalRegistry("Libraries", reg.getLibraryIds());
        dumpGlobalRegistry("Sources", reg.getSourceIds());
    }
}
 
Example 17
Project: Pogamut3   File: NavigationEvaluationTask.java   View Source Code Vote up 4 votes
public Level getLogLevel() {
    return Level.parse(stringLevel);
}
 
Example 18
Project: Pogamut3   File: MapPathsEvaluationTask.java   View Source Code Vote up 4 votes
public Level getLogLevel() {
    return Level.parse(level);
}
 
Example 19
Project: Pogamut3   File: NetworkLogEnvelope.java   View Source Code Vote up 4 votes
public NetworkLogEnvelope(String category, String level, String time, String message) {
	this.category = category;
	this.level = Level.parse(level);
	this.millis = Long.valueOf(time).longValue();
	this.message = message;
}
 
Example 20
Project: adobe-air-db-connector   File: PropertiesManager.java   View Source Code Vote up 4 votes
public Level getLogLevel(){
	String levelStr =  getString("airdb.log.level");
	Level level = Level.parse(levelStr);
	return level;
}