Skip to content

Commit

Permalink
添加调试模式以避免无用日志输出
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamVoid committed Aug 1, 2024
1 parent 34a4d8b commit 2473f2c
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public static boolean findClass(String className){
private static Logger logger;
private static ClassLoader classLoader;

public static boolean isDebugMode(){
return Boolean.getBoolean("MiraiMC.debug");
}

public static void setLogger(Logger logger){
Utils.logger = logger;
}
Expand All @@ -87,10 +91,16 @@ public static Logger getLogger(){

public static void setClassLoader(ClassLoader classLoader) {
Utils.classLoader = classLoader;
for(URL u : ((URLClassLoader) classLoader).getURLs()){
logger.info(u.getPath());
if(isDebugMode()){
logger.info("ClassLoader type: " + classLoader.getParent().getClass().getPackage().getName());
logger.info("Is an instance of URLClassLoader: " + (classLoader instanceof URLClassLoader));
if (classLoader instanceof URLClassLoader) {
logger.info("Paths: ");
for(URL u : ((URLClassLoader) classLoader).getURLs()){
logger.info("- " + u.getPath());
}
}
}
logger.info(classLoader.getParent().getClass().getPackage().getName());
}

public static ClassLoader getClassLoader(){
Expand Down

0 comments on commit 2473f2c

Please sign in to comment.