From 0c5b77d9fa8580be759e8ed430f005cee06a8dcf Mon Sep 17 00:00:00 2001 From: PierreOlivierBrillant Date: Thu, 17 Oct 2024 12:50:22 -0400 Subject: [PATCH] Fix log --- scriptsharp/ScriptSharp/LogSingleton.cs | 5 +---- scriptsharp/ScriptSharp/Program.cs | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scriptsharp/ScriptSharp/LogSingleton.cs b/scriptsharp/ScriptSharp/LogSingleton.cs index b98579d..2483ea5 100644 --- a/scriptsharp/ScriptSharp/LogSingleton.cs +++ b/scriptsharp/ScriptSharp/LogSingleton.cs @@ -8,8 +8,6 @@ public sealed class LogSingleton private static LogSingleton _instance; private static readonly object Padlock = new object(); - private StreamWriter writer; - private LogSingleton() { Initialize(); @@ -19,8 +17,6 @@ private void Initialize() { Directory.CreateDirectory(Config.LogPath); File.WriteAllText(Config.LogFilePath, string.Empty); - writer = new(Config.LogFilePath, true); - AppDomain.CurrentDomain.ProcessExit += (s, e) => writer.Close(); } public static LogSingleton Get @@ -39,6 +35,7 @@ public static LogSingleton Get public void LogAndWriteLine(string message) { + using StreamWriter writer = new(Config.LogFilePath, true); Console.WriteLine(message); writer.WriteLine($"{DateTime.Now}: {message}"); } diff --git a/scriptsharp/ScriptSharp/Program.cs b/scriptsharp/ScriptSharp/Program.cs index 8849b15..ee76894 100644 --- a/scriptsharp/ScriptSharp/Program.cs +++ b/scriptsharp/ScriptSharp/Program.cs @@ -49,6 +49,7 @@ static class Program private static async Task Main() { + UtilsFirebase.InstallFlutterFire(); //LogSingleton.Get.LogAndWriteLine("yo"); //TestDebug(); Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));