Compare commits

...

No commits in common. "main" and "1.0" have entirely different histories.
main ... 1.0

2 changed files with 7 additions and 23 deletions

View File

@ -1,5 +1,6 @@
package net.limework.automaticlogdeleter;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
@ -37,27 +38,16 @@ public class AutomaticLogDeleter extends JavaPlugin {
//maximum file age allowed
long maxOldMillis = config.getLong("delete-logs-older-than-seconds") * 1000;
String fileName;
for (File file : files) {
if (file.isFile()) {
fileName = file.getName();
if ((System.currentTimeMillis() - file.lastModified()) > maxOldMillis) {
//if file is not a log file
//using contains to make it more likely to catch different types of logging systems
if (!fileName.contains(".log") && !fileName.contains("log.")) {
continue;
}
//if file is older than configured time
if ((System.currentTimeMillis() - file.lastModified()) < maxOldMillis) {
continue;
}
if (!file.delete()) {
getLogger().log(Level.WARNING, "[AutomaticLogDeleter] Failed to delete server log file! Are you sure the file permissions are correct?");
} else {
getLogger().log(Level.INFO, "[AutomaticLogDeleter] Deleted log file " + fileName);
if (!file.delete()) {
Bukkit.getLogger().log(Level.WARNING, "[AutomaticLogDeleter] Failed to delete server log file! Are you sure the file permissions are correct?");
} else {
Bukkit.getLogger().log(Level.INFO, "[AutomaticLogDeleter] Deleted log file " + file.getName());
}
}
}
}

View File

@ -11,9 +11,3 @@ delete-logs-older-than-seconds: 86400
#default value: false
also-delete-logs-on-shutdown: false
#list of directories to check for logs
#note it will only delete files that contain ".log" in their name for safety reasons
#not yet implemented
check-directories-for-logs:
- "logs"