diff --git a/SzCli/Logger.cs b/SzCli/Logger.cs index c4de83b..5a483e9 100644 --- a/SzCli/Logger.cs +++ b/SzCli/Logger.cs @@ -6,22 +6,29 @@ public class Logger(ISzFileManager fileManager) : ISzLogger { public bool LogToFile { get; set; } = true; public string LogFilePath { get; set; } = Path.Combine(fileManager.DataPath, "log.txt"); + public int LogFileMaxLines { get; set; } = 100; public void Log(string text) { Console.WriteLine($"{DateTime.UtcNow} : [SZ LOG] {text}"); - if (LogToFile) File.AppendAllText(LogFilePath, $"{DateTime.UtcNow} : [SZ LOG] {text}\n"); + if (LogToFile) AppendLogFile($"{DateTime.UtcNow} : [SZ LOG] {text}"); } public void LogError(string text) { Console.WriteLine($"{DateTime.UtcNow} : [SZ ERR] {text}"); - if (LogToFile) File.AppendAllText(LogFilePath, $"{DateTime.UtcNow} : [SZ ERR] {text}\n"); + if (LogToFile) AppendLogFile($"{DateTime.UtcNow} : [SZ ERR] {text}"); } public void LogWarning(string text) { Console.WriteLine($"{DateTime.UtcNow} : [SZ WARN] {text}"); - if (LogToFile) File.AppendAllText(LogFilePath, $"{DateTime.UtcNow} : [SZ WARN] {text}\n"); + if (LogToFile) AppendLogFile($"{DateTime.UtcNow} : [SZ WARN] {text}"); + } + + private void AppendLogFile(string text) + { + // TODO: Make sure log file adheres to LogFileMaxLines + File.AppendAllText(LogFilePath, text + "\n"); } } \ No newline at end of file diff --git a/SzCore/ISzLogger.cs b/SzCore/ISzLogger.cs index c1d5c21..59c4ec8 100644 --- a/SzCore/ISzLogger.cs +++ b/SzCore/ISzLogger.cs @@ -4,6 +4,7 @@ public interface ISzLogger { public bool LogToFile { get; set; } public string LogFilePath { get; set; } + public int LogFileMaxLines { get; set; } public void Log(string text); public void LogError(string text); public void LogWarning(string text);