cn.nukkit.utils.LogLevel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
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();
}
}