Skip to content

Commit

Permalink
#698 configdir and logsdir
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-chu committed Nov 7, 2024
1 parent 9ee3145 commit f031d77
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/com/ghostchu/peerbanhelper/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@ public static void setupLogback() {
appender.start(); // 启动 appender
}

try{
try {
var targetLevel = System.getProperty("pbh.log.level");
if(targetLevel != null) {
if (targetLevel != null) {
var rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) rootLogger;
logbackLogger.setLevel(Level.toLevel(targetLevel));
}
}catch (Throwable ignored){}
} catch (Throwable ignored) {
}
}

public static ReloadResult reloadModule() {
Expand Down Expand Up @@ -221,8 +222,14 @@ private static void setupConfDirectory(String[] args) {
logsDirectory = new File(dataDirectory, "logs");
configDirectory = new File(dataDirectory, "config");
pluginDirectory = new File(dataDirectory, "plugins");
libraryDirectory = new File(dataDirectory, "libraries");
debugDirectory = new File(dataDirectory, "debug");
if (System.getProperty("pbh.configdir") != null) {
configDirectory = new File(System.getProperty("pbh.configdir"));
}
if (System.getProperty("pbh.logsdir") != null) {
logsDirectory = new File(System.getProperty("pbh.logsdir"));
}
// other directories aren't allowed to change by user to keep necessary structure
}

private static YamlConfiguration loadConfiguration(File file) {
Expand Down

0 comments on commit f031d77

Please sign in to comment.