chore: delete old logs every launch on Release

This commit is contained in:
goat 2023-05-24 22:10:52 +02:00
parent 77fc349c58
commit 276a80067c
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -97,7 +97,8 @@ public sealed class EntryPoint
var oldPathOld = Path.Combine(baseDirectory, "..", "..", "..", $"{logFileName}.log.old");
#endif
Log.CloseAndFlush();
#if DEBUG
var oldFileOld = new FileInfo(oldPathOld);
if (oldFileOld.Exists)
{
@ -109,6 +110,23 @@ public sealed class EntryPoint
}
CullLogFile(logPath, 1 * 1024 * 1024, oldPath, 10 * 1024 * 1024);
#else
try
{
if (File.Exists(logPath))
File.Delete(logPath);
if (File.Exists(oldPath))
File.Delete(oldPath);
if (File.Exists(oldPathOld))
File.Delete(oldPathOld);
}
catch
{
// ignored
}
#endif
var config = new LoggerConfiguration()
.WriteTo.Sink(SerilogEventSink.Instance)