edu.stanford.nlp.util.logging.JavaUtilLoggingHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-parser Show documentation
Show all versions of stanford-parser Show documentation
Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.
The newest version!
package edu.stanford.nlp.util.logging;
import java.util.logging.Level;
import java.util.logging.Logger;
import edu.stanford.nlp.util.Pair;
/**
* An outputter that writes to Java Util Logging logs.
*
* @author Gabor Angeli
*/
public class JavaUtilLoggingHandler extends OutputHandler {
@Override
public void print(Object[] channel, String line) {
// Parse the channels
Pair pair = getSourceStringAndLevel(channel);
// Get the logger
Logger impl = Logger.getLogger(pair.first());
// Route the signal
switch (pair.second()) {
case ERROR:
impl.log(Level.SEVERE, line);
break;
case WARN:
impl.log(Level.WARNING, line);
break;
case DEBUG:
impl.log(Level.FINE, line);
break;
case STDOUT:
case STDERR:
impl.info(line);
break;
case FORCE:
throw new IllegalStateException("Should not reach this switch case");
// Not possible as now enum
// default:
// throw new IllegalStateException("Unknown Redwood flag for j.u.l integration: " + flag);
}
}
}