Compare commits
No commits in common. "master" and "release1.0" have entirely different histories.
master
...
release1.0
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
Binary file not shown.
Binary file not shown.
|
@ -3,11 +3,8 @@ package org.dhaverdLogs;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.Period;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DhaverdLogs {
|
public class DhaverdLogs {
|
||||||
public static final String osSeparator = System.getProperty("file.separator");
|
public static final String osSeparator = System.getProperty("file.separator");
|
||||||
|
@ -15,38 +12,6 @@ public class DhaverdLogs {
|
||||||
public static String fileName = "log.log";
|
public static String fileName = "log.log";
|
||||||
public static String logDir = "";
|
public static String logDir = "";
|
||||||
|
|
||||||
public static void logCleaner(boolean deleteBySevenDays) throws IOException {
|
|
||||||
File dir = new File(logDir);
|
|
||||||
if (!dir.isDirectory()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
File[] fileList = dir.listFiles();
|
|
||||||
assert fileList != null;
|
|
||||||
for (File file : fileList){
|
|
||||||
String fileName = file.getName();
|
|
||||||
if (!fileName.contains("gitignore") && file.getName() != getLogFile().getName()){
|
|
||||||
if (deleteBySevenDays){
|
|
||||||
String[] params = fileName.split("_");
|
|
||||||
String date = params[0];
|
|
||||||
date = date.replace('.', '-');
|
|
||||||
String time = params[1];
|
|
||||||
time = time.replace('-', ':');
|
|
||||||
String dateTime = date + "T" + time;
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
|
||||||
LocalDateTime logDateTime = LocalDateTime.parse(dateTime);
|
|
||||||
Duration duration = Duration.between(logDateTime, now);
|
|
||||||
long diff = Math.abs(duration.toDays());
|
|
||||||
if (diff > 7){
|
|
||||||
setLog("Log cleaner", "File " + file.getName() + " is deleted: " + file.delete(), true, false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setLog("Log cleaner", "File " + file.getName() + " is deleted: " + file.delete(), true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void setLogName(String name){
|
public static void setLogName(String name){
|
||||||
String time = getCurrentTime();
|
String time = getCurrentTime();
|
||||||
|
|
Loading…
Reference in New Issue