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

panda.log.LogLevel Maven / Gradle / Ivy

Go to download

Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.

There is a newer version: 1.8.0
Show newest version
package panda.log;

import panda.lang.Strings;

/**
 */
public enum LogLevel {
	TRACE, 
	DEBUG,
	INFO,
	WARN,
	ERROR,
	FATAL;

	public boolean isLess(LogLevel level) {
		return ordinal() < level.ordinal();
	}

	public boolean isLessOrEqual(LogLevel level) {
		return ordinal() <= level.ordinal();
	}

	public boolean isGreater(LogLevel level) {
		return ordinal() > level.ordinal();
	}

	public boolean isGreaterOrEqual(LogLevel level) {
		return ordinal() >= level.ordinal();
	}
	
	public static LogLevel parse(String level) {
		if (Strings.isEmpty(level)) {
			return TRACE;
		}
		
		switch (level.charAt(0)) {
		case 'd':
		case 'D':
			return DEBUG;
		case 'i':
		case 'I':
			return INFO;
		case 'w':
		case 'W':
			return WARN;
		case 'e':
		case 'E':
			return ERROR;
		case 'f':
		case 'F':
			return FATAL;
		case 't':
		case 'T':
		default:
			return TRACE;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy