Added Config Getter, added Logger from PositionViewMod.

This commit is contained in:
0xSeb
2015-10-25 14:19:32 +01:00
parent 43056a8152
commit 265d94a662
3 changed files with 148 additions and 19 deletions
@@ -0,0 +1,91 @@
package de.skate702.craftingkeys.util;
import de.skate702.craftingkeys.CraftingKeys;
/**
* Simple Logger Class for debug output. Thank you, compiler!
*/
public class Logger {
/**
* Static Final Level. Compiler optimizing will kill all other calls!
*/
private static final LevelOfDetail MODE = LevelOfDetail.INFO;
/**
* Standard Output in front of every logger action.
*/
private static final String StdOutput = "[" + CraftingKeys.NAME + "/";
private static void print(String method, String message, LevelOfDetail in) {
System.out.println(StdOutput + in.toString() + "] " + method + ": " + message);
/**
* Prints a INFO-Message if allowed.
*
* @param method The calling method / method info
* @param message The message to print
*/
}
public static void info(String method, String message) {
if (MODE.getLevel() <= 0) {
print(method, message, LevelOfDetail.INFO);
}
}
/**
* Prints a DEBUG-Message if allowed.
*
* @param method The calling method / method info
* @param message The message to print
*/
public static void debug(String method, String message) {
if (MODE.getLevel() <= 1) {
print(method, message, LevelOfDetail.DEBUG);
}
}
/**
* Prints a WARN-Message if allowed.
*
* @param method The calling method / method info
* @param message The message to print
*/
public static void warn(String method, String message) {
if (MODE.getLevel() <= 2) {
print(method, message, LevelOfDetail.WARN);
}
}
/**
* Prints a ERROR-Message if allowed.
*
* @param method The calling method / method info
* @param message The message to print
*/
public static void error(String method, String message) {
if (MODE.getLevel() <= 3) {
print(method, message, LevelOfDetail.ERROR);
}
}
/**
* Define Level Of Detail with fixed numbers.
*/
private enum LevelOfDetail {
INFO(0), DEBUG(1), WARN(2), ERROR(3), NONE(4);
private final int level;
LevelOfDetail(int level) {
this.level = level;
}
public int getLevel() {
return level;
}
}
}