27 lines
926 B
C#
27 lines
926 B
C#
namespace BSO.Launcher;
|
|
|
|
/// <summary>Protokoll des Launchers: %LocalAppData%\BSO Launcher\launcher.log (wird beim Start ab 1 MB neu begonnen).</summary>
|
|
public static class LauncherLog
|
|
{
|
|
static readonly object Gate = new();
|
|
public static string FilePath => Path.Combine(Settings.Folder, "launcher.log");
|
|
|
|
public static void Info(string line) => Write("INFO ", line);
|
|
public static void Error(string line) => Write("ERROR", line);
|
|
|
|
static void Write(string level, string line)
|
|
{
|
|
lock (Gate)
|
|
{
|
|
try
|
|
{
|
|
Directory.CreateDirectory(Settings.Folder);
|
|
var info = new FileInfo(FilePath);
|
|
if (info.Exists && info.Length > 1024 * 1024) info.Delete();
|
|
File.AppendAllText(FilePath, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} {level} {line}{Environment.NewLine}");
|
|
}
|
|
catch { }
|
|
}
|
|
}
|
|
}
|