Adjusted GC.KeepAlive
This commit is contained in:
parent
f0bcebbd10
commit
5550909851
1 changed files with 13 additions and 13 deletions
14
Logger.cs
14
Logger.cs
|
|
@ -25,8 +25,6 @@ public class Logger
|
||||||
/// <returns>A bool stating if the logger was started</returns>
|
/// <returns>A bool stating if the logger was started</returns>
|
||||||
public static void StartLogger(string filePath = "", LoggerObjects.LogLevel level = LoggerObjects.LogLevel.DEBUG, DateTime cleanUpBefore = new DateTime(), bool ThrowOnFailedDeletion = false)
|
public static void StartLogger(string filePath = "", LoggerObjects.LogLevel level = LoggerObjects.LogLevel.DEBUG, DateTime cleanUpBefore = new DateTime(), bool ThrowOnFailedDeletion = false)
|
||||||
{
|
{
|
||||||
GC.KeepAlive(_loggerObjects.LogsToPost);
|
|
||||||
|
|
||||||
if (loggerStarted)
|
if (loggerStarted)
|
||||||
throw new Exception($"The logger is already started");
|
throw new Exception($"The logger is already started");
|
||||||
|
|
||||||
|
|
@ -83,11 +81,6 @@ public class Logger
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GC.KeepAlive(b);
|
|
||||||
GC.KeepAlive(b.LogLevel);
|
|
||||||
GC.KeepAlive(b.Message);
|
|
||||||
GC.KeepAlive(b.TimeOfEvent);
|
|
||||||
|
|
||||||
string LogLevelText = b.LogLevel.ToString();
|
string LogLevelText = b.LogLevel.ToString();
|
||||||
|
|
||||||
if (LogLevelText.Length != 5)
|
if (LogLevelText.Length != 5)
|
||||||
|
|
@ -173,6 +166,11 @@ public class Logger
|
||||||
{
|
{
|
||||||
LogFatal($"Couldn't write log to file: {ex}");
|
LogFatal($"Couldn't write log to file: {ex}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GC.KeepAlive(b);
|
||||||
|
GC.KeepAlive(b.LogLevel);
|
||||||
|
GC.KeepAlive(b.Message);
|
||||||
|
GC.KeepAlive(b.TimeOfEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -185,6 +183,8 @@ public class Logger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
GC.KeepAlive(_loggerObjects.LogsToPost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue