Skip to content

Commit

Permalink
Added Logger class, with isDebug for classes implementing Api
Browse files Browse the repository at this point in the history
  • Loading branch information
Burchard36 committed Nov 15, 2021
1 parent 3c98926 commit b774a84
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/burchard36/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ public interface Api {
* @return running PluginDataManager instance
*/
PluginDataManager getPluginDataManager();

/**
* If the debug mode is true, when debug is called on the
* Logger#debug method a message gets logged, this also may effect other things
* however thats all it is originally meant for
*/
boolean isDebug();
}
27 changes: 27 additions & 0 deletions src/main/java/com/burchard36/Logger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.burchard36;

import static com.burchard36.ApiLib.convert;

public class Logger {

private static final String prefix = "&6Dragon&eSpigot&6Z ";

public static void debug(final String message,
final Api api) {
if (api.isDebug()) {
System.out.println(convert(prefix + "&b:: &2DEBUG &b:: &a" + message));
}
}

public static void log(final String message) {
System.out.println(convert(prefix + "&b:: &3INFO &b:: &b" + message));
}

public static void warn(final String message) {
System.out.println(convert(prefix + "&4:: &eWARN &4:: &c" + message));
}

public static void error(final String message) {
System.out.println(convert(prefix + "&4:: &cERROR &4:: &c" + message));
}
}

0 comments on commit b774a84

Please sign in to comment.