aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/cowtipper
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/cowtipper')
-rw-r--r--src/main/java/de/cowtipper/cowlection/config/MooConfig.java13
-rw-r--r--src/main/java/de/cowtipper/cowlection/search/GuiSearch.java2
-rw-r--r--src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java9
3 files changed, 19 insertions, 5 deletions
diff --git a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java
index b26c19f..d6e93cd 100644
--- a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java
+++ b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java
@@ -61,6 +61,7 @@ public class MooConfig {
public static String[] logsDirs;
private static String defaultStartDate;
private static int maxLogFileSize;
+ private static int maxLatestLogFileSize;
// Category: Notifications
public static boolean doUpdateCheck;
public static boolean showBestFriendNotifications;
@@ -318,10 +319,13 @@ public class MooConfig {
.setValidationPattern(Pattern.compile("^[1-9][0-9]{0,2}|(2[0-9]{3}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]))$"));
Property propMaxLogFileSize = subCat.addConfigEntry(cfg.get(CATEGORY_LOGS_SEARCH,
"maxLogFileSize", 2048, "Max log file size (in KB)?", 50, 10000));
+ Property propMaxLatestLogFileSize = subCat.addConfigEntry(cfg.get(CATEGORY_LOGS_SEARCH,
+ "maxLatestLogFileSize", 50000, "Max latest.log file size (in KB)?", 50, 200000));
logSearchProperties = new ArrayList<>();
logSearchProperties.add(propLogsDirs);
logSearchProperties.add(propDefaultStartDate);
logSearchProperties.add(propMaxLogFileSize);
+ logSearchProperties.add(propMaxLatestLogFileSize);
// Category: Notifications
configCat = new MooConfigCategory("Notifications", "notifications");
@@ -667,6 +671,7 @@ public class MooConfig {
logsDirs = propLogsDirs.getStringList();
defaultStartDate = propDefaultStartDate.getString().trim();
maxLogFileSize = propMaxLogFileSize.getInt();
+ maxLatestLogFileSize = propMaxLatestLogFileSize.getInt();
// Category: Notifications
doUpdateCheck = propDoUpdateCheck.getBoolean();
showBestFriendNotifications = propShowBestFriendNotifications.getBoolean();
@@ -756,6 +761,7 @@ public class MooConfig {
propLogsDirs.set(logsDirs);
propDefaultStartDate.set(defaultStartDate);
propMaxLogFileSize.set(maxLogFileSize);
+ propMaxLatestLogFileSize.set(maxLatestLogFileSize);
// Category: Notifications
propDoUpdateCheck.set(doUpdateCheck);
propShowBestFriendNotifications.set(showBestFriendNotifications);
@@ -913,6 +919,13 @@ public class MooConfig {
return maxLogFileSize * 1024L;
}
+ /**
+ * @return max latest.log file size in Bytes
+ */
+ public static long getMaxLatestLogFileSize() {
+ return maxLatestLogFileSize * 1024L;
+ }
+
// Category: General
public static Setting getConfigGuiExplanationsDisplay() {
return Setting.get(configGuiExplanations);
diff --git a/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java b/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java
index 7e721a9..2970c24 100644
--- a/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java
+++ b/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java
@@ -291,7 +291,7 @@ public class GuiSearch extends GuiScreen {
this.searchResults = searchResultsData.getSortedSearchResults();
this.analyzedFiles = "Analyzed files: " + EnumChatFormatting.WHITE + searchResultsData.getAnalyzedFiles();
this.analyzedFilesWithHits = "Files with hits: " + EnumChatFormatting.WHITE + searchResultsData.getAnalyzedFilesWithHits();
- this.skippedFiles = "Skipped files: " + EnumChatFormatting.WHITE + searchResultsData.getSkippedFiles();
+ this.skippedFiles = "Skipped large files: " + (searchResultsData.getSkippedFiles() > 0 ? EnumChatFormatting.RED : EnumChatFormatting.WHITE) + searchResultsData.getSkippedFiles();
if (this.searchResults.isEmpty()) {
this.searchResults.add(new LogEntry(EnumChatFormatting.ITALIC + "No results"));
areEntriesSearchResults = false;
diff --git a/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java b/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java
index bbfd0fb..c005852 100644
--- a/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java
+++ b/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java
@@ -32,6 +32,7 @@ class LogFilesSearcher {
LogSearchResults searchFor(String searchQuery, boolean chatOnly, boolean matchCase, boolean removeFormatting, LocalDate dateStart, LocalDate dateEnd) throws IOException {
LogSearchResults logSearchResults = new LogSearchResults();
long fileSizeLimit = MooConfig.getMaxLogFileSize();
+ long latestLogSizeLimit = MooConfig.getMaxLatestLogFileSize();
for (String logsDirPath : MooConfig.logsDirs) {
File logsDir = new File(logsDirPath);
if (!logsDir.exists() || !logsDir.isDirectory()) {
@@ -53,7 +54,7 @@ class LogFilesSearcher {
Integer.parseInt(fileNameMatcher.group(2)), Integer.parseInt(fileNameMatcher.group(3)));
if (!fileLocalDate.isBefore(dateStart) && !fileLocalDate.isAfter(dateEnd)) {
if (path.toFile().length() > fileSizeLimit) {
- // file too large
+ // .log.gz file too large
logSearchResults.addSkippedFile();
} else {
logSearchResults.addAnalyzedFile();
@@ -64,8 +65,8 @@ class LogFilesSearcher {
} else if (fileName.equals("latest.log")) {
LocalDate lastModified = Instant.ofEpochMilli(path.toFile().lastModified()).atZone(ZoneId.systemDefault()).toLocalDate();
if (!lastModified.isBefore(dateStart) && !lastModified.isAfter(dateEnd)) {
- if (path.toFile().length() > fileSizeLimit) {
- // file too large
+ if (path.toFile().length() > latestLogSizeLimit) {
+ // latest.log too large
logSearchResults.addSkippedFile();
} else {
logSearchResults.addAnalyzedFile();
@@ -85,7 +86,7 @@ class LogFilesSearcher {
int skippedFileCounter = logSearchResults.getSkippedFiles();
if (skippedFileCounter > 0) {
throw new FileNotFoundException(EnumChatFormatting.DARK_RED + "ERROR: No Minecraft log files could be found for the selected date range.\n"
- + EnumChatFormatting.RED + skippedFileCounter + EnumChatFormatting.DARK_RED + " log files were skipped because they are too large ( >" + FileUtils.byteCountToDisplaySize(MooConfig.getMaxLogFileSize()) + ").\n"
+ + EnumChatFormatting.RED + skippedFileCounter + EnumChatFormatting.DARK_RED + " log files were skipped because they are too large (" + EnumChatFormatting.RED + ".log.gz" + EnumChatFormatting.DARK_RED + " files >" + FileUtils.byteCountToDisplaySize(MooConfig.getMaxLogFileSize()) + "; " + EnumChatFormatting.RED + "latest.log" + EnumChatFormatting.DARK_RED + " >" + FileUtils.byteCountToDisplaySize(MooConfig.getMaxLatestLogFileSize()) + ").\n"
+ EnumChatFormatting.RED + "Please check if the dates as well as the directories of the log files are set correctly (Log Search ➡ Settings [top right corner]).\n"
+ EnumChatFormatting.DARK_RED + "You could also increase the maximum allowed log file size to be searched (Log Search ➡ Settings), but note that each file must be unzipped before it can be analyzed, which can make the log file search take significantly longer for large files.");
} else {