Added LogsFolder Consts

This commit is contained in:
erri120 2020-02-20 11:45:38 +01:00
parent 6f80a40dc9
commit 78ba02f277
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
2 changed files with 7 additions and 4 deletions

View File

@ -103,5 +103,8 @@ namespace Wabbajack.Common
public static string PatchCacheFolder => Path.Combine(LocalAppDataPath, "patch_cache");
public static int MaxConnectionsPerServer = 4;
public static string LogsFolder = "logs";
public static int MaxOldLogs = 50;
}
}

View File

@ -53,17 +53,17 @@ namespace Wabbajack.Common
if (!Directory.Exists(Consts.LocalAppDataPath))
Directory.CreateDirectory(Consts.LocalAppDataPath);
if (!Directory.Exists("logs"))
Directory.CreateDirectory("logs");
if (!Directory.Exists(Consts.LogsFolder))
Directory.CreateDirectory(Consts.LogsFolder);
var programName = Assembly.GetEntryAssembly()?.Location ?? "Wabbajack";
LogFile = Path.Combine("logs", Path.GetFileNameWithoutExtension(programName) + ".current.log");
LogFile = Path.Combine(Consts.LogsFolder, Path.GetFileNameWithoutExtension(programName) + ".current.log");
_startTime = DateTime.Now;
if (LogFile.FileExists())
{
var newPath = Path.Combine("logs", Path.GetFileNameWithoutExtension(programName) + (new FileInfo(LogFile)).LastWriteTime.ToString(" yyyy-MM-dd HH_mm_ss") + ".log");
var newPath = Path.Combine(Consts.LogsFolder, Path.GetFileNameWithoutExtension(programName) + (new FileInfo(LogFile)).LastWriteTime.ToString(" yyyy-MM-dd HH_mm_ss") + ".log");
File.Move(LogFile, newPath, MoveOptions.ReplaceExisting);
}