Skip to content

Commit

Permalink
shorten log prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Mar 21, 2024
1 parent 97ce424 commit 4b5e1ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,29 @@ static void reloadModules() {
}

default void trace(String message, Throwable throwable) {
AnarchyExploitFixes.getPrefixedLogger().trace("<" + configPath() + "> " + message, throwable);
AnarchyExploitFixes.getPrefixedLogger().trace(prefix() + message, throwable);
}

default void error(String message) {
AnarchyExploitFixes.getPrefixedLogger().error("<" + configPath() + "> " + message);
AnarchyExploitFixes.getPrefixedLogger().error(prefix() + message);
}

default void warn(String message) {
AnarchyExploitFixes.getPrefixedLogger().warn("<" + configPath() + "> " + message);
AnarchyExploitFixes.getPrefixedLogger().warn(prefix() + message);
}

default void info(String message) {
AnarchyExploitFixes.getPrefixedLogger().info("<" + configPath() + "> " + message);
AnarchyExploitFixes.getPrefixedLogger().info(prefix() + message);
}

default void notRecognized(Class<?> clazz, String unrecognized) {
warn("Unable to parse " + clazz.getName().substring(clazz.getName().lastIndexOf(".")) +
" at '" + unrecognized + "'. Please check your configuration.");
}

default String prefix() {
if (!configPath().contains(".")) return "<" + configPath() + "> ";
String[] split = configPath().split("\\.");
return "<" + String.join(".", split[split.length - 2], split[split.length - 1]) + "> ";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,29 @@ static void reloadModules() {
}

default void trace(String message, Throwable throwable) {
AnarchyExploitFixes.getPrefixedLogger().trace("<" + configPath() + "> " + message, throwable);
AnarchyExploitFixes.getPrefixedLogger().trace(prefix() + message, throwable);
}

default void error(String message) {
AnarchyExploitFixes.getPrefixedLogger().error("<" + configPath() + "> " + message);
AnarchyExploitFixes.getPrefixedLogger().error(prefix() + message);
}

default void warn(String message) {
AnarchyExploitFixes.getPrefixedLogger().warn("<" + configPath() + "> " + message);
AnarchyExploitFixes.getPrefixedLogger().warn(prefix() + message);
}

default void info(String message) {
AnarchyExploitFixes.getPrefixedLogger().info("<" + configPath() + "> " + message);
AnarchyExploitFixes.getPrefixedLogger().info(prefix() + message);
}

default void notRecognized(Class<?> clazz, String unrecognized) {
warn("Unable to parse " + clazz.getName().substring(clazz.getName().lastIndexOf(".")) +
" at '" + unrecognized + "'. Please check your configuration.");
}

default String prefix() {
if (!configPath().contains(".")) return "<" + configPath() + "> ";
String[] split = configPath().split("\\.");
return "<" + String.join(".", split[split.length - 2], split[split.length - 1]) + "> ";
}
}

0 comments on commit 4b5e1ff

Please sign in to comment.