Java Code Examples for org.apache.uima.util.Level#toInteger()

The following examples show how to use org.apache.uima.util.Level#toInteger() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UIMASlf4jWrapperLogger.java    From termsuite-core with Apache License 2.0 6 votes vote down vote up
@Override
public void log(Level level, String msg) {
	switch (level.toInteger()) {
	case org.apache.uima.util.Level.OFF_INT:
		return;
	case org.apache.uima.util.Level.SEVERE_INT:
		this.slf4jLogger.error(msg);
	case org.apache.uima.util.Level.WARNING_INT:
		this.slf4jLogger.warn(msg);
	case org.apache.uima.util.Level.INFO_INT:
		this.slf4jLogger.info(msg);
	case org.apache.uima.util.Level.CONFIG_INT:
		this.slf4jLogger.debug(msg);
	case org.apache.uima.util.Level.FINE_INT:
		this.slf4jLogger.debug(msg);
	case org.apache.uima.util.Level.FINER_INT:
		this.slf4jLogger.trace(msg);
	case org.apache.uima.util.Level.FINEST_INT:
		this.slf4jLogger.trace(msg);
	default: // for all other cases return Level.ALL
		this.slf4jLogger.trace(msg);
	}
}
 
Example 2
Source File: UIMASlf4jWrapperLogger.java    From termsuite-core with Apache License 2.0 6 votes vote down vote up
@Override
public void log(Level level, String msg, Object param1) {
	switch (level.toInteger()) {
	case org.apache.uima.util.Level.OFF_INT:
		return;
	case org.apache.uima.util.Level.SEVERE_INT:
		this.slf4jLogger.error(msg, param1);
	case org.apache.uima.util.Level.WARNING_INT:
		this.slf4jLogger.warn(msg, param1);
	case org.apache.uima.util.Level.INFO_INT:
		this.slf4jLogger.info(msg, param1);
	case org.apache.uima.util.Level.CONFIG_INT:
		this.slf4jLogger.debug(msg, param1);
	case org.apache.uima.util.Level.FINE_INT:
		this.slf4jLogger.debug(msg, param1);
	case org.apache.uima.util.Level.FINER_INT:
		this.slf4jLogger.trace(msg, param1);
	case org.apache.uima.util.Level.FINEST_INT:
		this.slf4jLogger.trace(msg, param1);
	default: // for all other cases return Level.ALL
		this.slf4jLogger.trace(msg, param1);
	}
}
 
Example 3
Source File: UIMASlf4jWrapperLogger.java    From termsuite-core with Apache License 2.0 6 votes vote down vote up
@Override
public void log(Level level, String msg, Object[] params) {
	switch (level.toInteger()) {
	case org.apache.uima.util.Level.OFF_INT:
		return;
	case org.apache.uima.util.Level.SEVERE_INT:
		this.slf4jLogger.error(msg, params);
	case org.apache.uima.util.Level.WARNING_INT:
		this.slf4jLogger.warn(msg, params);
	case org.apache.uima.util.Level.INFO_INT:
		this.slf4jLogger.info(msg, params);
	case org.apache.uima.util.Level.CONFIG_INT:
		this.slf4jLogger.debug(msg, params);
	case org.apache.uima.util.Level.FINE_INT:
		this.slf4jLogger.debug(msg, params);
	case org.apache.uima.util.Level.FINER_INT:
		this.slf4jLogger.trace(msg, params);
	case org.apache.uima.util.Level.FINEST_INT:
		this.slf4jLogger.trace(msg, params);
	default: // for all other cases return Level.ALL
		this.slf4jLogger.trace(msg, params);
	}
}
 
Example 4
Source File: UIMASlf4jWrapperLogger.java    From termsuite-core with Apache License 2.0 6 votes vote down vote up
@Override
public void log(Level level, String msg, Throwable throwable) {
	switch (level.toInteger()) {
	case org.apache.uima.util.Level.OFF_INT:
		return;
	case org.apache.uima.util.Level.SEVERE_INT:
		this.slf4jLogger.error(msg, throwable);
	case org.apache.uima.util.Level.WARNING_INT:
		this.slf4jLogger.warn(msg, throwable);
	case org.apache.uima.util.Level.INFO_INT:
		this.slf4jLogger.info(msg, throwable);
	case org.apache.uima.util.Level.CONFIG_INT:
		this.slf4jLogger.debug(msg, throwable);
	case org.apache.uima.util.Level.FINE_INT:
		this.slf4jLogger.debug(msg, throwable);
	case org.apache.uima.util.Level.FINER_INT:
		this.slf4jLogger.trace(msg, throwable);
	case org.apache.uima.util.Level.FINEST_INT:
		this.slf4jLogger.trace(msg, throwable);
	default: // for all other cases return Level.ALL
		this.slf4jLogger.trace(msg, throwable);
	}
}
 
Example 5
Source File: Slf4jLogger_impl.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
public boolean isLoggable(Level level) {
  switch (level.toInteger()) {
  case org.apache.uima.util.Level.OFF_INT:
    return false;
  case org.apache.uima.util.Level.SEVERE_INT:
    return logger.isErrorEnabled();
  case org.apache.uima.util.Level.WARNING_INT:
    return logger.isWarnEnabled();
  case org.apache.uima.util.Level.INFO_INT:
    return logger.isInfoEnabled();
  case org.apache.uima.util.Level.CONFIG_INT:
    return logger.isInfoEnabled(UIMA_MARKER_CONFIG);
  case org.apache.uima.util.Level.FINE_INT:
    return logger.isDebugEnabled();
  case org.apache.uima.util.Level.FINER_INT:
    return logger.isTraceEnabled();
  case org.apache.uima.util.Level.FINEST_INT:
    return logger.isTraceEnabled(UIMA_MARKER_FINEST);
  default: // for Level.ALL return false, that's what jul logger does
    return false;
  }
}
 
Example 6
Source File: Slf4jLogger_impl.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
public boolean isLoggable(Level level, Marker marker) {
  switch (level.toInteger()) {
  case org.apache.uima.util.Level.OFF_INT:
    return false;
  case org.apache.uima.util.Level.SEVERE_INT:
    return logger.isErrorEnabled(marker);
  case org.apache.uima.util.Level.WARNING_INT:
    return logger.isWarnEnabled(marker);
  case org.apache.uima.util.Level.INFO_INT:
    return logger.isInfoEnabled(marker);
  case org.apache.uima.util.Level.CONFIG_INT:
    return logger.isInfoEnabled(marker);
  case org.apache.uima.util.Level.FINE_INT:
    return logger.isDebugEnabled(marker);
  case org.apache.uima.util.Level.FINER_INT:
    return logger.isTraceEnabled(marker);
  case org.apache.uima.util.Level.FINEST_INT:
    return logger.isTraceEnabled(marker);
  default: // for Level.ALL return false, that's what jul logger does
    return false;
  }
}
 
Example 7
Source File: Log4jLogger_impl.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * log4j level mapping to UIMA level mapping. <br>
 * SEVERE (highest value) -&gt; SEVERE <br> 
 * WARNING -&gt; WARNING <br> 
 * INFO -&gt; INFO <br> 
 * CONFIG -&gt; INFO <br> 
 * FINE -&gt; DEBUG <br> 
 * FINER -&gt; TRACE <br> 
 * FINEST (lowest value) -&gt; TRACE <br> 
 * OFF -&gt; OFF <br> 
 * ALL -&gt; ALL <br>
 * 
 * @param level uima level
 * @return Level - corresponding log4j 2 level
 */
static org.apache.logging.log4j.Level getLog4jLevel(Level level) {
   switch (level.toInteger()) {
   case org.apache.uima.util.Level.OFF_INT:
      return org.apache.logging.log4j.Level.OFF;
   case org.apache.uima.util.Level.SEVERE_INT:
      return org.apache.logging.log4j.Level.ERROR;
   case org.apache.uima.util.Level.WARNING_INT:
      return org.apache.logging.log4j.Level.WARN;
   case org.apache.uima.util.Level.INFO_INT:
      return org.apache.logging.log4j.Level.INFO;
   case org.apache.uima.util.Level.CONFIG_INT:
      return org.apache.logging.log4j.Level.INFO;
   case org.apache.uima.util.Level.FINE_INT:
      return org.apache.logging.log4j.Level.DEBUG;
   case org.apache.uima.util.Level.FINER_INT:
     return org.apache.logging.log4j.Level.TRACE;
   case org.apache.uima.util.Level.FINEST_INT:
     return org.apache.logging.log4j.Level.TRACE;
   default: // for all other cases return Level.ALL
      return org.apache.logging.log4j.Level.ALL;
   }
}
 
Example 8
Source File: Logger_common_impl.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param level -
 * @return true if not limited
 */
private boolean isNotLimited(Level level) {
  if (!isLimited) {
    return true;
  }
  switch(level.toInteger()) {
  case Level.SEVERE_INT: if (SEVERE_COUNT >= limit_common) return false; SEVERE_COUNT++; return true; 
  case Level.WARNING_INT: if (WARNING_COUNT >= limit_common) return false; WARNING_COUNT++; return true; 
  case Level.INFO_INT: if (INFO_COUNT >= limit_common) return false; INFO_COUNT++; return true; 
  case Level.CONFIG_INT: if (CONFIG_COUNT >= limit_common) return false; CONFIG_COUNT++; return true; 
  case Level.FINE_INT: if (FINE_COUNT >= limit_common) return false; FINE_COUNT++; return true; 
  case Level.FINER_INT: if (FINER_COUNT >= limit_common) return false; FINER_COUNT++; return true; 
  case Level.FINEST_INT: if (FINEST_COUNT >= limit_common) return false; FINEST_COUNT++; return true; 
  }
  Misc.internalError();
  return false;
}
 
Example 9
Source File: Slf4jLogger_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public static int getSlf4jLevel(Level level) {
  switch(level.toInteger()) {
  case Level.SEVERE_INT: return LocationAwareLogger.ERROR_INT;
  case Level.WARNING_INT: return LocationAwareLogger.WARN_INT;
  case Level.INFO_INT: return LocationAwareLogger.INFO_INT;
  case Level.CONFIG_INT: return LocationAwareLogger.INFO_INT;
  case Level.FINE_INT: return LocationAwareLogger.DEBUG_INT;
  case Level.FINER_INT: return LocationAwareLogger.TRACE_INT;
  case Level.FINEST_INT: return LocationAwareLogger.TRACE_INT;
  }
  Misc.internalError();
  return LocationAwareLogger.ERROR_INT; //ignored, just here for compile error avoidance
}
 
Example 10
Source File: Slf4jLogger_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void log(Marker m, String aFqcn, Level level, String msg_with_params, Throwable thrown) {
  m = (m == null) 
      ? getMarkerForLevel(level) 
      : m;
      
if (isLocationCapable) {  // slf4j simple logger is not
  ((org.slf4j.spi.LocationAwareLogger)logger).log(m, aFqcn, getSlf4jLevel(level), msg_with_params, null, thrown);
} else {
  switch(level.toInteger()) {
  case Level.SEVERE_INT: 
    // all of these calls to MessageFormat are to the java.text.MessageFormat
    // to do {n} style format substitution
    logger.error(m, msg_with_params, thrown); 
    break;
  case Level.WARNING_INT: 
    logger.warn(m, msg_with_params, thrown); 
    break;
  case Level.INFO_INT: 
    logger.info(m, msg_with_params, thrown); 
    break;
  case Level.CONFIG_INT: 
    logger.info(m, msg_with_params, thrown); 
    break;
  case Level.FINE_INT: 
    logger.debug(m, msg_with_params, thrown); 
    break;
  case Level.FINER_INT: 
    logger.trace(m, msg_with_params, thrown); 
    break;
  case Level.FINEST_INT: 
    logger.trace(m, msg_with_params, thrown); 
    break;
  default: Misc.internalError();
  }
}
  
}
 
Example 11
Source File: JSR47Logger_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * JSR-47 level mapping to UIMA level mapping.
 * 
 * Maps via marker values for UIMA_MARKER_CONFIG and UIMA_MARKER_FINEST
 * 
 * SEVERE (highest value) -%gt; SEVERE<br> 
 * WARNING -%gt; WARNING<br> 
 * INFO -%gt; INFO <br>
 * CONFIG -%gt; CONFIG <br>
 * FINE -%gt; FINE<br>
 * FINER -%gt; FINER <br>
 * FINEST (lowest value) -%gt; FINEST<br> 
 * OFF -%gt; OFF <br>
 * ALL -%gt; ALL<br>
 * 
 * @param level
 *          uima level
 * @param m the marker
 * 
 * @return Level - corresponding JSR47 level
 */
public static java.util.logging.Level getJSR47Level(Level level, Marker m) {
  if (null == level) {
    return null;
  }
  switch (level.toInteger()) {
    case org.apache.uima.util.Level.OFF_INT:
      return java.util.logging.Level.OFF;
    case org.apache.uima.util.Level.SEVERE_INT:
      return java.util.logging.Level.SEVERE;
    case org.apache.uima.util.Level.WARNING_INT:
      return java.util.logging.Level.WARNING;
    case org.apache.uima.util.Level.INFO_INT:
      return (m == UIMA_MARKER_CONFIG) 
               ? java.util.logging.Level.CONFIG
               : java.util.logging.Level.INFO;
    case org.apache.uima.util.Level.CONFIG_INT:
      return java.util.logging.Level.CONFIG;
    case org.apache.uima.util.Level.FINE_INT:
      return java.util.logging.Level.FINE;
    case org.apache.uima.util.Level.FINER_INT:
      // could be DEBUG with marker FINEST, DEBUG_INT == FINER_INT
      return (m == UIMA_MARKER_FINEST)
               ? java.util.logging.Level.FINEST
               : java.util.logging.Level.FINER;
    case org.apache.uima.util.Level.FINEST_INT:
      return java.util.logging.Level.FINEST;
        
    default: // for all other cases return Level.ALL
      return java.util.logging.Level.ALL;
  }
}
 
Example 12
Source File: Logger_common_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * @param level the Uima Level
 * @return the Marker to use
 */
public static Marker getMarkerForLevel(Level level) {
  switch(level.toInteger()) {
  case Level.CONFIG_INT: return UIMA_MARKER_CONFIG;
  case Level.FINEST_INT: return UIMA_MARKER_FINEST;
  default: return null;
  }
}
 
Example 13
Source File: Slf4jLogger_impl.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
public void log2(Marker m, String aFqcn, Level level, String message, Object[] args, Throwable thrown) {
  m = (m == null) 
      ? getMarkerForLevel(level) 
      : m;
      
  if (isLocationCapable) {  // slf4j simple logger is not
    ((org.slf4j.spi.LocationAwareLogger)logger).log(m, aFqcn, getSlf4jLevel(level), message, args, thrown);
  } else {
    if (thrown != null) {
      Object[] args1 = (args == null) ? new Object[1] : new Object[args.length + 1];
      if (args != null) {
        System.arraycopy(args, 0, args1, 0, args.length);
      }
      args1[args1.length - 1] = thrown;
      args = args1;
    }  
    switch(level.toInteger()) {
    case Level.SEVERE_INT: 
      logger.error(m, message, args); 
      break;
    case Level.WARNING_INT: 
      logger.warn(m, message, args); 
      break;
    case Level.INFO_INT: 
      logger.info(m, message, args); 
      break;
    case Level.CONFIG_INT: 
      logger.info(m, message, args); 
      break;
    case Level.FINE_INT: 
      logger.debug(m, message, args); 
      break;
    case Level.FINER_INT: 
      logger.trace(m, message, args); 
      break;
    case Level.FINEST_INT: 
      logger.trace(m, message, args); 
      break;
    default: Misc.internalError();
    }
  }
}