2
0

"Fixed" Issue with Filelogger, where program would crash if file could not be written

This commit is contained in:
glax 2023-05-20 22:56:05 +02:00
parent d6af014cb7
commit b8bf7bdf30
2 changed files with 9 additions and 2 deletions

View File

@ -14,6 +14,13 @@ public class FileLogger : LoggerBase
protected override void Write(LogMessage logMessage)
{
File.AppendAllText(logFilePath, logMessage.ToString());
try
{
File.AppendAllText(logFilePath, logMessage.ToString());
}
catch (Exception e)
{
stdOut?.WriteLine(e);
}
}
}

View File

@ -5,7 +5,7 @@ namespace Logging;
public abstract class LoggerBase : TextWriter
{
public override Encoding Encoding { get; }
private TextWriter? stdOut { get; }
protected TextWriter? stdOut { get; }
public LoggerBase(TextWriter? stdOut, Encoding? encoding = null)
{