Java 8 Level - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Level class.

This code example shows how to use the following methods: intValue
     * @param level The {@link java.util.logging.Logger} logging level. 
     * 
     * @return The resulting Android logging level. 
     */ 
    static int getAndroidLevel(Level level) {
        int value = level.intValue();
        if (value >= 1000) { // SEVERE
            return Log.ERROR;
        } else if (value >= 900) { // WARNING
            return Log.WARN;
        } else if (value >= 800) { // INFO
            return Log.INFO;
        } else { 
            return Log.DEBUG;
        } 
    } 
} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getLocalizedName, intValue
    return buffer.toString();
  } 
 
 
  private String levelNumberToCommonsLevelName(Level level) {
    switch (level.intValue()) {
      case FINE:
        return "DEBUG"; 
      case INFO:
        return "INFO"; 
      case WARNING:
        return "WARN"; 
      case SEVERE:
        return "ERROR"; 
      default: 
        return level.getLocalizedName();
    } 
  } 
 
} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getLocalizedName, getName
StringBuilder msg = new StringBuilder();
        msg.append(this.dateFormat.format(Long.valueOf(record.getMillis())));
        Level lvl = record.getLevel();
 
        String name = lvl.getLocalizedName();
        if ( name == null )
        { 
            name = lvl.getName();        	
        } 
 
        if ( ( name != null ) && ( name.length() > 0 ) )
        { 
            msg.append(" [" + name + "] ");
        } 
        else 
        { 
            msg.append(" ");
        } 
 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: intValue
 
        @Override 
        public int compare(final Level o1, final Level o2) {
            int result = EQUAL;
            final int left = o1.intValue();
            final int right = o2.intValue();
            if (left < right) {
                result = LESS;
            } else if (left > right) {
                result = GREATER;
            } 
            return result;
        } 
    } 
} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getName
    private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyMMdd HH:mm:ss.SSS");
 
    private static Map<Level, String> LEVEL_TO_STRING_CACHE = Maps.newHashMap();
 
    private static final String levelToString(Level level) {
        String levelName = LEVEL_TO_STRING_CACHE.get(level);
        if (levelName == null) {
            levelName = level.getName().substring(0, 1);
            LEVEL_TO_STRING_CACHE.put(level, levelName);
        } 
        return levelName;
    } 
 
    private static String getHeader(LogRecord record) {
        StringBuilder sb = new StringBuilder();
 
        sb.append(FORMAT.format(new Date(record.getMillis()))).append(":");
        sb.append(levelToString(record.getLevel())).append(" ");
 
        sb.append("[").append(Thread.currentThread().getName()).append("] ");
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: intValue
     * @param level The {@link java.util.logging.Logger} logging level. 
     * 
     * @return The resulting Android logging level. 
     */ 
    static int getAndroidLevel(Level level) {
        int value = level.intValue();
        if (value >= 1000) { // SEVERE
            return Log.ERROR;
        } else if (value >= 900) { // WARNING
            return Log.WARN;
        } else if (value >= 800) { // INFO
            return Log.INFO;
        } else { 
            return Log.DEBUG;
        } 
    } 
} 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: intValue
     * {@link #finest(String) finest} methods according the supplied level. 
     */ 
    @Override 
    @SuppressWarnings("fallthrough") 
    public void log(final Level level, final String message) {
        final int n = level.intValue();
        switch (n / 100) {
            default: { 
                if (n < 0 || n == Integer.MAX_VALUE) break;
                // MAX_VALUE is a special value for Level.OFF. Otherwise and 
                // if positive, fallthrough since we are greater than SEVERE. 
            } 
            case 10: severe (message); break;
            case  9: warning(message); break;
            case  8: info   (message); break;
            case  7: config (message); break;
            case  6: 
            case  5: fine   (message); break;
            case  4: finer  (message); break;
            case  3: finest (message); break;

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: equals
        } 
        final ExtendedLogger other = (ExtendedLogger) obj;
        if (this.logger != other.logger && (this.logger == null || !this.logger.equals(other.logger))) {
            return false; 
        } 
        if (this.debugLevel != other.debugLevel && (this.debugLevel == null || !this.debugLevel.equals(other.debugLevel))) {
            return false; 
        } 
        return true; 
    } 
 
    @Override 
    public int hashCode() { 
        int hash = 3;
        hash = 17 * hash + (this.logger != null ? this.logger.hashCode() : 0);
        hash = 17 * hash + (this.debugLevel != null ? this.debugLevel.hashCode() : 0);
        return hash;
    } 
 
    public void warning(String msg) {
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: equals
 
	@Override 
	public void publish(LogRecord logRecord) {
		Level level = logRecord.getLevel();
 
		if (level.equals(Level.SEVERE)) {
			StringBundler sb = new StringBundler(6);
 
			sb.append("{level=");
			sb.append(logRecord.getLevel());
			sb.append(", loggerName=");
			sb.append(logRecord.getLoggerName());
			sb.append(", message=");
			sb.append(logRecord.getMessage());
 
			LogAssertionTestRule.caughtFailure( 
				new AssertionError(sb.toString(), logRecord.getThrown()));
		} 
	} 
 
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: intValue
      level = Level.OFF;
   } 
    
   @Override 
   public boolean isTraceEnabled() { 
      return level.intValue() <= Level.FINER.intValue();
   } 
   @Override 
   public boolean isDebugEnabled() { 
      return level.intValue() <= Level.FINE.intValue();
   } 
 
   @Override 
   public boolean isInfoEnabled() { 
      return level.intValue() <= Level.INFO.intValue();
   } 
 
   @Override 
   public boolean isWarnEnabled() { 
      return level.intValue() <= Level.WARNING.intValue();
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 Level Questions & Answers:

See Code Examples for Java 8 Level Methods: