Skip to content

Commit

Permalink
Avoid deeply nesting log file when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet authored and poldinik committed Apr 29, 2024
1 parent e28180c commit b935637
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,17 @@ public static void setLogFileProperty(String logFileName) {
}

public static String getLogFileLocation() {
return getLogFileLocation(getLogFinalName());
}
String logFilePath = System.getProperty(LOG_FILE_PATH_PROPERTY);

if (logFilePath != null) {
return logFilePath;
}

private static String getLogFinalName() {
return System.getProperty(LOG_FILE_PATH_PROPERTY, FileConfig.DEFAULT_LOG_FILE_NAME);
return getLogFileLocation(FileConfig.DEFAULT_LOG_FILE_NAME);
}

public static Path getLogFilePath() {
List<String> logFileLocationParts = getLogFileLocationParts(getLogFinalName());
if (logFileLocationParts.isEmpty()) {
throw new IllegalStateException("Unable to determine log file path");
} else if (logFileLocationParts.size() == 1) {
return Paths.get(logFileLocationParts.get(0));
} else {
return Paths.get(logFileLocationParts.get(0),
logFileLocationParts.subList(1, logFileLocationParts.size()).toArray(new String[0]));
}
return Paths.get(getLogFileLocation());
}

private static String getLogFileLocation(String logFileName) {
Expand Down

0 comments on commit b935637

Please sign in to comment.