27 lines
883 B
C#
27 lines
883 B
C#
using SzLib;
|
|
|
|
namespace SzCli;
|
|
|
|
public class Logger(ISzFileManager fileManager) : ISzLogger
|
|
{
|
|
public bool LogToFile { get; set; } = true;
|
|
public string LogFilePath { get; set; } = Path.Combine(fileManager.DataPath, "log.txt");
|
|
|
|
public void Log(string text)
|
|
{
|
|
Console.WriteLine($"{DateTime.UtcNow} : [SZ LOG] {text}");
|
|
if (LogToFile) File.AppendAllText(LogFilePath, $"{DateTime.UtcNow} : [SZ LOG] {text}\n");
|
|
}
|
|
|
|
public void LogError(string text)
|
|
{
|
|
Console.WriteLine($"{DateTime.UtcNow} : [SZ ERR] {text}");
|
|
if (LogToFile) File.AppendAllText(LogFilePath, $"{DateTime.UtcNow} : [SZ ERR] {text}\n");
|
|
}
|
|
|
|
public void LogWarning(string text)
|
|
{
|
|
Console.WriteLine($"{DateTime.UtcNow} : [SZ WARN] {text}");
|
|
if (LogToFile) File.AppendAllText(LogFilePath, $"{DateTime.UtcNow} : [SZ WARN] {text}\n");
|
|
}
|
|
} |