mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 20:15:39 +02:00
Added settings option for log rotation
This commit is contained in:
@@ -78,7 +78,8 @@ internal class Globals
|
||||
public static string VersionDatabase = ""; // Version - Database
|
||||
public static string VersionPerun = "DEBUG"; // Version - Perun
|
||||
|
||||
public static string LastLogLocation = ""; // Last used log location
|
||||
public static string LastLogLocation = ""; // Last used log location
|
||||
public static bool RotateLogs = false; // Rotate logs true/false
|
||||
|
||||
public static CurrentMissionClass CurrentMission = new CurrentMissionClass(); // Actual mission information single ton
|
||||
|
||||
|
||||
@@ -59,14 +59,17 @@ class LogController
|
||||
}
|
||||
|
||||
// Delete old files - log rotation
|
||||
DirectoryInfo di = new DirectoryInfo(LogFileDir);
|
||||
FileInfo[] files = di.GetFiles("*.log");
|
||||
|
||||
foreach (FileInfo fi in files)
|
||||
if (Globals.RotateLogs)
|
||||
{
|
||||
if (fi.LastAccessTime < DateTime.Now.AddDays(-7))
|
||||
DirectoryInfo di = new DirectoryInfo(LogFileDir);
|
||||
FileInfo[] files = di.GetFiles("*.log");
|
||||
|
||||
foreach (FileInfo fi in files)
|
||||
{
|
||||
fi.Delete();
|
||||
if (fi.LastAccessTime < DateTime.Now.AddDays(-7))
|
||||
{
|
||||
fi.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user