All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.nlp.util.logging.JavaUtilLoggingHandler Maven / Gradle / Ivy

Go to download

Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.

There is a newer version: 3.9.2
Show 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);
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy