cn.nukkit.utils.LogLevel Maven / Gradle / Ivy
package cn.nukkit.utils;
import org.apache.logging.log4j.util.TriConsumer;
import java.util.function.BiConsumer;
/**
* @author MagicDroidX (Nukkit Project)
*/
public enum LogLevel implements Comparable {
NONE((logger, message) -> {
}, (mainLogger, s, throwable) -> {
}),
EMERGENCY(MainLogger::emergency, MainLogger::emergency),
ALERT(MainLogger::alert, MainLogger::alert),
CRITICAL(MainLogger::critical, MainLogger::critical),
ERROR(MainLogger::error, MainLogger::error),
WARNING(MainLogger::warning, MainLogger::warning),
NOTICE(MainLogger::notice, MainLogger::notice),
INFO(MainLogger::info, MainLogger::info),
DEBUG(MainLogger::debug, MainLogger::debug);
public static final LogLevel DEFAULT_LEVEL = INFO;
private final BiConsumer logTo;
private final TriConsumer logThrowableTo;
LogLevel(BiConsumer logTo, TriConsumer logThrowableTo) {
this.logTo = logTo;
this.logThrowableTo = logThrowableTo;
}
public void log(MainLogger logger, String message) {
logTo.accept(logger, message);
}
public void log(MainLogger logger, String message, Throwable throwable) {
logThrowableTo.accept(logger, message, throwable);
}
public int getLevel() {
return ordinal();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy