add XLog
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
projectGroup=ghast
|
projectGroup=ghast
|
||||||
projectName=ghast-tools
|
projectName=ghast-tools
|
||||||
projectVersion=1.3
|
projectVersion=1.4
|
||||||
76
src/main/java/ghast/XLog.java
Normal file
76
src/main/java/ghast/XLog.java
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package ghast;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class XLog {
|
||||||
|
|
||||||
|
//region Debug
|
||||||
|
public void debug(String pattern, Object... objects) {
|
||||||
|
if (objects.length > 1 && objects[objects.length - 1] instanceof Throwable) {
|
||||||
|
Throwable throwable = (Throwable) objects[objects.length - 1];
|
||||||
|
Object[] values = new Object[objects.length - 1];
|
||||||
|
System.arraycopy(objects, 0, values, 0, values.length);
|
||||||
|
|
||||||
|
debug(format(pattern, values), throwable);
|
||||||
|
} else {
|
||||||
|
debug(format(pattern, objects));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message, Throwable throwable) {
|
||||||
|
GhastTools.getPlugin().getLogger().log(Level.FINE, message, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message) {
|
||||||
|
GhastTools.getPlugin().getLogger().fine(message);
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Info
|
||||||
|
public void info(String pattern, Object... objects) {
|
||||||
|
info(format(pattern, objects));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String message) {
|
||||||
|
GhastTools.getPlugin().getLogger().info(message);
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Warning
|
||||||
|
public void warn(String pattern, Object... objects) {
|
||||||
|
warn(format(pattern, objects));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message) {
|
||||||
|
GhastTools.getPlugin().getLogger().warning(message);
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Error
|
||||||
|
public void error(String pattern, Object... objects) {
|
||||||
|
if (objects.length > 1 && objects[objects.length - 1] instanceof Throwable) {
|
||||||
|
Throwable throwable = (Throwable) objects[objects.length - 1];
|
||||||
|
Object[] values = new Object[objects.length - 1];
|
||||||
|
System.arraycopy(objects, 0, values, 0, values.length);
|
||||||
|
|
||||||
|
error(format(pattern, values), throwable);
|
||||||
|
} else {
|
||||||
|
error(format(pattern, objects));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message) {
|
||||||
|
GhastTools.getPlugin().getLogger().severe(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message, Throwable throwable) {
|
||||||
|
GhastTools.getPlugin().getLogger().log(Level.SEVERE, message, throwable);
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user