Small changes

This commit is contained in:
EntenKoeniq
2022-03-30 16:14:25 +02:00
parent 7d2e3705ea
commit 0051504684
2 changed files with 21 additions and 11 deletions

View File

@ -13,7 +13,7 @@ namespace CoopClient
Custom
}
public static void Write(string message, LogLevel level = LogLevel.Normal, string filepath = null)
private static string GetFilePath(LogLevel level, string filepath)
{
string newFilePath = null;
@ -35,6 +35,13 @@ namespace CoopClient
break;
}
return newFilePath;
}
public static void Write(string message, LogLevel level = LogLevel.Normal, string filepath = null)
{
string newFilePath = GetFilePath(level, filepath);
try
{
if (File.Exists(newFilePath))
@ -53,7 +60,7 @@ namespace CoopClient
using (StreamWriter sw = new StreamWriter(newFilePath, true))
{
Log(message, sw);
sw.WriteLine($"[{DateTime.Now.ToLongTimeString()} {DateTime.Now.ToLongDateString()}] : {message}");
sw.Flush();
sw.Close();
@ -62,10 +69,5 @@ namespace CoopClient
catch
{ }
}
private static void Log(string message, TextWriter writer)
{
writer.WriteLine($"[{DateTime.Now.ToLongTimeString()} {DateTime.Now.ToLongDateString()}] : {message}");
}
}
}