Java Code Examples for java.util.logging.Logger.warning()

The following are Jave code examples for showing how to use warning() of the java.util.logging.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: CallbackSystemActionTest.java   Source Code and License Vote up 6 votes
public static void waitInstancesZero(Logger l) throws InterruptedException {
    for (int i = 0; i < 10; i++) {
        synchronized (INSTANCES_LOCK) {
            if (INSTANCES == 0) return;
            
            l.warning("instances still there: " + INSTANCES);
        }
        
        ActionsInfraHid.doGC();
        
        synchronized (INSTANCES_LOCK) {
            l.warning("after GC, do wait");
            
            INSTANCES_LOCK.wait(1000);
            l.warning("after waiting");
        }
    }
    failInstances("Instances are not zero");
}
 
Example 2
Project: bibliome-java-utils   File: CompositeServiceFactory.java   Source Code and License Vote up 6 votes
/**
 * Adds a compound factory.
 * @param factory
 * @param logger
 */
public void addFactory(F factory, Logger logger) {
    if (factories.values().contains(factory)) {
        if (logger != null)
            logger.warning("compound service factory has already factory " + factory);
        return;
    }
    for (K key : factory.supportedServices()) {
        if (factories.containsKey(key)) {
            if (logger != null)
                logger.warning("compound service factory has already factory for " + key);
            continue;
        }
        factories.put(key, factory);
        for (String alias : autoAlias(key)) {
            // System.err.println("add alias = " + alias);
            addAlias(alias, key);
        }
    }
}
 
Example 3
Project: jdk8u-jdk   File: TestIsLoggable.java   Source Code and License Vote up 6 votes
public void loglevel(Level l, Logger logger, String message) {
    LogTest test = LogTest.valueOf("LEV_"+l.getName());
    switch(test) {
        case LEV_SEVERE:
            logger.severe(message);
            break;
        case LEV_WARNING:
            logger.warning(message);
            break;
        case LEV_INFO:
            logger.info(message);
            break;
        case LEV_CONFIG:
            logger.config(message);
            break;
        case LEV_FINE:
            logger.fine(message);
            break;
        case LEV_FINER:
            logger.finer(message);
            break;
        case LEV_FINEST:
            logger.finest(message);
            break;
    }
}
 
Example 4
Project: MCGameInfoPlugin   File: Util.java   Source Code and License Vote up 6 votes
public static void loadGamePatterns(List<Map> source, Set<GamePattern> gamePatterns, Logger logger) {
	gamePatterns.clear();
	for (Map map : source) {
		if (!map.containsKey("pattern")) {
			logger.warning("Missing 'pattern' key");
			continue;
		}
		if (!map.containsKey("game")) {
			logger.warning("Missing 'game' key");
			continue;
		}

		GamePattern pattern = new GamePattern((String) map.get("pattern"), (String) map.get("game"));
		gamePatterns.add(pattern);
		logger.info(pattern.getPattern().pattern() + " -> " + pattern.getGame());
	}
}
 
Example 5
Project: alvisnlp   File: TreeTaggerExternal.java   Source Code and License Vote up 6 votes
@Override
  public void processOutput(BufferedReader out, BufferedReader err) throws ModuleException {
      if (silent) {
	return;
}
      Logger logger = owner.getLogger(ctx);
      try {
          logger.fine("tree-tagger standard error:");
          for (String line = err.readLine(); line != null; line = err.readLine()) {
              logger.fine("    " + line);
          }
          logger.fine("end of tree-tagger standard error");
      }
      catch (IOException ioe) {
          logger.warning("could not read tree-tagger standard error: " + ioe.getMessage());
      }
  }
 
Example 6
Project: openjdk-jdk10   File: TestIsLoggable.java   Source Code and License Vote up 6 votes
public void loglevel(Level l, Logger logger, String message) {
    LogTest test = LogTest.valueOf("LEV_"+l.getName());
    switch(test) {
        case LEV_SEVERE:
            logger.severe(message);
            break;
        case LEV_WARNING:
            logger.warning(message);
            break;
        case LEV_INFO:
            logger.info(message);
            break;
        case LEV_CONFIG:
            logger.config(message);
            break;
        case LEV_FINE:
            logger.fine(message);
            break;
        case LEV_FINER:
            logger.finer(message);
            break;
        case LEV_FINEST:
            logger.finest(message);
            break;
    }
}
 
Example 7
Project: incubator-netbeans   File: LoggingTest.java   Source Code and License Vote up 5 votes
/** Used in testIOExceptionIsWrappedWithLogMsg. */
public void throwIOThrowable() throws Throwable {
    Logger log = Logger.getLogger(getName());
    if (toMsg != null) {
        log.log(Level.WARNING, "Msg", toMsg);
    }
    log.warning("Going to throw: " + toThrow);
    throw toThrow;
}
 
Example 8
Project: Pogamut3   File: FloydWarshall.java   Source Code and License Vote up 5 votes
/**
 * FloydWarshall configured with "map" and agent-specific view on the map, if "view" is null, {@link DefaultView} is going to be used.
 * <p><p>
 * {@link FloydWarshall#compute()} method is immediately called from within this constructor.
 *  
 * @param map
 * @param view may be null
 * @param log may be null
 */
public FloydWarshall(IPFKnownMap<NODE> map, IPFKnownMapView<NODE> view, Logger log) {
	this.map = map;
	this.view = view;
	NullCheck.check(this.map, "map");
	this.log = log;
	if (this.view == null) {
		if (log != null && log.isLoggable(Level.WARNING)) log.warning("No view specified! IPFKnownMapView.DefaultView is going to be used.");
		this.view = new IPFKnownMapView.DefaultView();
	}		
	compute();
}
 
Example 9
Project: alvisnlp   File: Assert.java   Source Code and License Vote up 5 votes
@Override
public void process(ProcessingContext<Corpus> ctx, Corpus corpus) throws ModuleException {
	AssertResolvedObjects resObj = getResolvedObjects();
	Logger logger = getLogger(ctx);
	EvaluationContext evalCtx = new EvaluationContext(logger);
	try (PrintStream out = openStream()) {
		int failures = 0;
		int checked = 0;
		for (Element elt : Iterators.loop(resObj.target.evaluateElements(evalCtx, corpus))) {
			checked++;
			resObj.targetVariable.set(elt);
			if (!resObj.assertion.evaluateBoolean(evalCtx, elt)) {
				failures++;
				String message = resObj.getMessage(evalCtx, elt);
				logger.warning(message);
				if (out != null) {
					out.println(message);
				}
				if (stopAt != null && failures == stopAt.intValue())
					break;
			}
		}
		String msg = "assertion failures: " + failures;
		if (severe && failures > 0) {
			if (out != null) {
				out.println(msg);
			}
			processingException(msg);
		}
		else {
			logger.info("elements checked: " + checked);
			logger.info(msg);
		}
	}
	catch (IOException e) {
		rethrow(e);
	}
}
 
Example 10
Project: FreeCol   File: FreeColDebugger.java   Source Code and License Vote up 5 votes
/**
 * Log a warning with a stack trace.
 *
 * @param logger The {@code Logger} to log to.
 * @param warn The warning message.
 */
public static void trace(Logger logger, String warn) {
    LogBuilder lb = new LogBuilder(512);
    lb.add(warn, "\n");
    addStackTrace(lb);
    logger.warning(lb.toString());
}
 
Example 11
Project: alvisnlp   File: TrieProjector.java   Source Code and License Vote up 5 votes
@Override
public void process(ProcessingContext<Corpus> ctx, Corpus corpus) throws ModuleException {
	Logger logger = getLogger(ctx);
	EvaluationContext evalCtx = new EvaluationContext(logger);
	try (Trie<T> trie = getTrie(ctx, logger, corpus)) {
		StandardMatchControl control = getControl();
		subject.correctControl(control);
		Matcher<T> matcher = new Matcher<T>(trie, control);
		logger.info("searching...");
		int nMatches = 0;
		for (Section sec : Iterators.loop(sectionIterator(evalCtx, corpus))) {
			matcher.init();
			List<Match<T>> matches = subject.search(matcher, sec);
			nMatches += matches.size();
			Layer targetLayer = sec.ensureLayer(targetLayerName);
			for (Match<T> match : matches)
				multipleEntryBehaviour.handle(this, targetLayer, match);
		}
		
		if (nMatches == 0) {
			logger.warning("found no matches");
		}
		else {
			logger.info("found " + nMatches + " matches");
		}
		finish();

		if (trieSink != null && trieSource == null) {
			Encoder<T> encoder = getEncoder();
			logger.info("saving trie into " + trieSink);
			trie.save(trieSink, encoder);
		}
	}
	catch (IOException e) {
		rethrow(e);
	}
}
 
Example 12
Project: alvisnlp   File: TabularProjector.java   Source Code and License Vote up 5 votes
@Override
protected void fillTrie(Logger logger, Trie<List<String>> trie, Corpus corpus) throws IOException, ModuleException {
	logger.info("reading dictionary from: " + dictFile);
	TabularFormat format = new TabularFormat();
	format.setNumColumns(valueFeatures.length);
	logger.info("we expect lines with " + valueFeatures.length + " columns");
	format.setSeparator(separator);
	if (!strictColumnNumber)
		logger.warning("you deliberately choose to ignore malformed dictionary lines");
	format.setStrictColumnNumber(strictColumnNumber);
	if (skipEmpty)
		logger.warning("skipping empty lines");
	format.setSkipEmpty(skipEmpty);
	if (skipBlank)
		logger.warning("skipping lines with only whitespace");
	format.setSkipBlank(skipBlank);
	if (trimColumns)
		logger.warning("columns will be trimmed from leading and trailing whitespace");
	format.setTrimColumns(trimColumns);
	FileLines<Trie<List<String>>> fl = new EntryFileLines(format, keyIndex);
	try {
		fl.process(dictFile, trie);
	}
	catch (InvalidFileLineEntry e) {
		rethrow(e);
	}
}
 
Example 13
Project: alvisnlp   File: RemoveContents.java   Source Code and License Vote up 5 votes
private Layer getStripLayer(Logger logger, Section sec) {
	Layer stripLayer = sec.getLayer(stripLayerName);
	if (stripLayer.hasOverlaps()) {
		logger.warning("overlapping annotations, merging");
		return mergeOverlapping(stripLayer);
	}
	return stripLayer;
}
 
Example 14
Project: BUILD_file_generator   File: JavaSourceFileParserCli.java   Source Code and License Vote up 4 votes
private void run(String[] args) throws Exception {
  // TODO(bazel-team) how will I receive the source files from the user.
  try {
    CmdLineParser cmdLineParser = new CmdLineParser(this);
    cmdLineParser.parseArgument(args);
  } catch (CmdLineException e) {
    if (sourceFiles.isEmpty()) {
      System.err.println("Must provide file names to parse.");
    } else {
      System.err.println(e.getMessage());
    }
    e.getParser().printUsage(System.err);
    System.exit(1);
  }

  ImmutableList<Path> contentRoots =
      stream(Splitter.on(',').split(contentRootPaths))
          .map(root -> Paths.get(root))
          .collect(toImmutableList());

  ImmutableList<Path> sourceFilePaths =
      sourceFiles.stream().map(p -> Paths.get(p)).collect(toImmutableList());

  ImmutableSet<Path> oneRulePerPackagePaths =
      stream(Splitter.on(',').split(oneRulePerPackageRoots))
          .map(root -> Paths.get(root))
          .collect(toImmutableSet());

  JavaSourceFileParser parser =
      new JavaSourceFileParser(sourceFilePaths, contentRoots, oneRulePerPackagePaths);

  Set<String> unresolvedClassNames = parser.getUnresolvedClassNames();
  if (!unresolvedClassNames.isEmpty()) {
    Logger logger = Logger.getLogger(JavaSourceFileParserCli.class.getName());
    logger.warning(
        String.format("Class Names not found %s", Joiner.on("\n\t").join(unresolvedClassNames)));
  }

  // Write results to stdout.
  serializeResults(parser).writeTo(System.out);
}
 
Example 15
Project: alvisnlp   File: WhatsWrongExport.java   Source Code and License Vote up 4 votes
private void processSentence(PrintStream out, Logger logger, Collection<Tuple> dependencies, Section sec, Annotation sent) {
	out.println(">>");
	out.println(">Word");
	IndexHashMap<Annotation> wordIndex = new IndexHashMap<Annotation>();
	Layer wordLayer = sec.getLayer(words);
	StringBuilder sb = new StringBuilder();
	for (Annotation w : wordLayer.between(sent)) {
		sb.setLength(0);
		Strings.escapeWhitespaces(sb, w.getLastFeature(wordForm));
		out.format("%d\t\"%s\"\n", wordIndex.safeGet(w), sb);
	}
	if (entities != null) {
		for (String name : entities) {
			Layer entityLayer = sec.ensureLayer(name);
			out.println(">Entities");
			for (Annotation e : entityLayer.between(sent)) {
				Layer includedWords = wordLayer.overlapping(e);
				if (includedWords.isEmpty()) {
					logger.warning("entity " + e + " dos not include any word");
					continue;
				}
				if (includedWords.size() == 1) {
					out.format("%d\t\"%s\"\n", wordIndex.safeGet(includedWords.first()), e.getLastFeature(entityType));
				}
				else {
					out.format("%d\t%d\t\"%s\"\n", wordIndex.safeGet(includedWords.first()), wordIndex.safeGet(includedWords.last()), e.getLastFeature(entityType));
				}
			}
		}
	}
	out.println(">Relations");
	for (Tuple t : dependencies) {
		if (!t.hasArgument(head)) {
			logger.warning("dependency without head");
			continue;
		}
		if (!t.hasArgument(dependent)) {
			logger.warning("dependency without dependent");
			continue;
		}
		Annotation headWord = DownCastElement.toAnnotation(t.getArgument(head));
		Annotation dependentWord = DownCastElement.toAnnotation(t.getArgument(dependent));
		if (!wordLayer.contains(headWord)) {
			logger.warning("head not in the word layer");
			continue;
		}
		if (!wordLayer.contains(dependentWord)) {
			logger.warning("dependent not in the word layer");
			continue;
		}
		if (!wordIndex.containsKey(headWord)) {
			logger.warning("head outisde sentence");
			continue;
		}
		if (!wordIndex.containsKey(dependentWord)) {
			logger.warning("dependent outisde sentence");
			continue;
		}
		int h = wordIndex.get(headWord);
		int d = wordIndex.get(dependentWord);
		out.format("%d\t%d\t\"%s\"\n", h, d, t.getLastFeature(label));
	}
}
 
Example 16
Project: alvisnlp   File: ModuleLibrary.java   Source Code and License Vote up 4 votes
@Function
public Iterator<Element> warn(String msg) {
	Logger logger = module.getLogger(ctx);
	logger.warning(msg);
	return Iterators.emptyIterator();
}
 
Example 17
Project: fdt   File: MacHostPropertiesMonitor.java   Source Code and License Vote up 4 votes
public MacHostPropertiesMonitor(final Logger logger) {

        this.logger = logger;

        execute = cmdExec.getInstance();
        sep = System.getProperty("file.separator");
        // get the network interfaces up
        command = sep + "sbin" + sep + "ifconfig -l -u";
        CommandResult cmdRes = execute.executeCommand(command, "lo0", 3 * 1000L);
        String result = cmdRes.getOutput();
        // System.out.println(command + " = "+ result);
        if (result == null || result.equals("")) {
            logger.warning(command + ": No result???");
        } else {
            int where = result.indexOf("lo0");
            networkInterfaces = result.substring(where + 3, result.length()).replaceAll("  ", " ").trim().split(" ");

            // get the currently used Mac Address
            for (int i = 0; i < networkInterfaces.length; i++) {
                String current = networkInterfaces[i];
                command = sep + "sbin" + sep + "ifconfig " + current;
                cmdRes = execute.executeCommand(command, current, 3 * 1000L);
                result = cmdRes.getOutput();
                // System.out.println(command + " = " + result);
                if (result == null || result.equals("")) {
                    logger.warning(command + ": No result???");
                } else {
                    if (result.indexOf("inet ") != -1) {
                        int pointI = result.indexOf("ether");
                        int pointJ = result.indexOf("media", pointI);
                        macAddress = result.substring(pointI + 5, pointJ).trim();
                        // System.out.println("Mac Address:" + macAddress);
                        activeInterface = current;
                    }
                }
            }
        }

        // get the disk information
        command = sep + "bin" + sep + "df -k -h " + sep;
        cmdRes = execute.executeCommand(command, "/dev", 3 * 1000L);
        result = cmdRes.getOutput();
        // System.out.println(command + " = "+ result);
        if (result == null || result.equals("")) {
            logger.warning(command + ": No result???");
        } else {
            parseDf(result);
        }

        update();
    }
 
Example 18
Project: Pogamut3   File: JavaDocStripper.java   Source Code and License Vote up 4 votes
public static void main( String[] args ) {

if (args.length == 0) {
	printHelp();
	System.exit(1);
}

SimpleLogging.initLogging();
Logger log = Logger.getAnonymousLogger();

log.info("=====================");
log.info("JavaDoc Stripper Tool");
log.info("=====================");
log.info("");
log.info("Reading configuration...");

Substitution multiLineCommentSubst = new Substitution();
multiLineCommentSubst.setCaseSensitive(false);
multiLineCommentSubst.setMultiLine(true);
multiLineCommentSubst.setReMatch(multiLineCommentPattern);
multiLineCommentSubst.setReSubst("");

Substitution singleLineCommentSubst = new Substitution();
singleLineCommentSubst.setCaseSensitive(false);
singleLineCommentSubst.setMultiLine(false);
singleLineCommentSubst.setReMatch(singleLineCommentPattern);
singleLineCommentSubst.setReSubst("");

boolean recursive = "-r".equals(args[0]);

if (recursive) {
	log.info("'-r' paramter detected, will be recursively descending to subdirs.");
} else {
	log.info("'-r' parameter not specified, won't recursively descend to subdirs.");
}

RewriteFilesConfig config = new RewriteFilesConfig();

int i = recursive ? 1 : 0;
for (; i < args.length; ++i) {
	File file = new File(args[i]);
	if (!file.exists()) {
		log.warning("File/Dir (" + (i+1) + ". param) does not exist, ommiting: " + args[i] + " -> " + file.getAbsolutePath());
		continue;
	}
	
	IncludeDirForSubstitutions dir = new IncludeDirForSubstitutions();			
	if (file.isDirectory()) {
		log.info("Adding configuration for directory (" + (i+1) + ". param): " + args[i] + " -> " + file.getAbsolutePath());
		dir.setSubdirs(recursive);
		dir.setDir(file);
		dir.getIncludeFiles().add("*.java");
		dir.getSubstitutions().add(singleLineCommentSubst);
		dir.getSubstitutions().add(multiLineCommentSubst);								
	} else {
		log.info("Adding configuration for file      (" + (i+1) + ". param): " + args[i] + " -> " + file.getAbsolutePath());
		dir.setSubdirs(false);
		dir.setDir(file.getParentFile());
		dir.getIncludeFiles().add(file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(fileSeparator)+1));
		dir.getSubstitutions().add(singleLineCommentSubst);
		dir.getSubstitutions().add(multiLineCommentSubst);
	}		
	
	config.getDirs().add(dir);
}

RewriteFiles rewriter = new RewriteFiles(config);
rewriter.setLog(log);
log.info("STRIPPING!");
rewriter.rewrite();

log.info("");
log.info("DONE!");

System.exit(0);
  }
 
Example 19
Project: Pogamut3   File: RewriteFiles.java   Source Code and License Vote up 4 votes
public static void main(String[] args) {
	//String definition = "RewriteFiles.xml";
	String definition = "config.xml";
	if (args.length > 0) {
		definition = args[0];
		if (definition == null) definition = "RewriteFiles.xml";
	}
	
	SimpleLogging.initLogging();
	Logger log = Logger.getAnonymousLogger();
	log.info("---[[ REWRITE FILES ]]---");
	log.info("Loading definition from xml file: " + definition + " --> " + new File(definition).getAbsoluteFile());
	File file = new File(definition);
	if (!file.exists() || !file.isFile()) {
		log.severe("FAILED! Definition file not found at: " + file.getAbsolutePath());
		log.severe("Usage: java -jar RewriteFiles.jar [path-to-definition-xml-file]");
		example(log);
		log.info("---[[ END ]]---");
		System.exit(1);
		return;
	}
	RewriteFiles rewrite;
	try {
		rewrite = new RewriteFiles(file);
	} catch (Exception e) {
		e.printStackTrace();
		log.severe("Usage: java -jar RewriteFiles.jar [path-to-definition-xml-file]");
		example(log);
		log.info("---[[ END ]]---");
		return;
	}
	rewrite.setLog(log);
	log.info("Definition file loaded.");
	boolean result = rewrite.rewrite();
	
	
	if (result) {
		log.info("System.exit(0)");
	}
	else {
		log.warning("Failure! System.exit(1)!");
		System.exit(1);
	}
	
	log.info("---[[ END ]]---");
	
	if (result) {
		System.exit(0);
	} else {
		System.exit(1);
	}
	
}
 
Example 20
Project: Pogamut3   File: ProcessExecution.java   Source Code and License Vote up 4 votes
/**
 * Searches for $XXX or ${XXX} and substitute them with {@link System#getenv()} (prioritized) or {@link System#getProperty(String)}.
 * @param command
 * @return
 */
public static String substituteParams(String command, Logger log) {
	List<Tuple3<Integer, Integer, String>> params = new ArrayList<Tuple3<Integer, Integer, String>>();
	Matcher m;
	
	for (int i = 0; i < 2; ++i) {
		m = (i == 0 ? SIMPLE_PARAM.matcher(command) : FORMAL_PARAM.matcher(command));
		while (m.find()) {
			params.add(
					new Tuple3<Integer, Integer, String>(
						m.start(),          // where does the parameter start
						m.group().length(), // how long the param is
						m.group(1)          // name of the parameter matched
					)
			);
		}
	}
	
	if (params.size() == 0) return command;
	
	Collections.sort(
		params, 
		new Comparator<Tuple3<Integer, Integer, String>>() {
@Override
public int compare(Tuple3<Integer, Integer, String> o1,	Tuple3<Integer, Integer, String> o2) {
	return o2.getFirst() - o1.getFirst(); // descending order!
}
		}
	);
	
	String result = command;
	
	if (log != null && log.isLoggable(Level.INFO)) log.info("Substituing parameters for: " + command);
	
	for (Tuple3<Integer, Integer, String> param : params) {
		String paramValue = System.getenv(param.getThird());
		if (paramValue == null) {
			paramValue = System.getProperty(param.getThird());
		}
		if (paramValue == null) {
			if (log != null && log.isLoggable(Level.WARNING)) log.warning("Parameter '" + param.getThird() + "' not found! Both System.getenv(\"" + param.getThird() + "\") and System.getProperty(\"" + param.getThird() + "\") evaluates to null!");
			return null;
		}
		result = result.substring(0, param.getFirst()) + paramValue + result.substring(param.getFirst() + param.getSecond());
	}
	
	if (log != null && log.isLoggable(Level.INFO)) log.info("Substitution result: " + result);
	
	return result;
}