Skip to content

Commit

Permalink
fix:#299
Browse files Browse the repository at this point in the history
  • Loading branch information
nacatcode committed Dec 26, 2023
1 parent 5d7964a commit c0f2bda
Showing 1 changed file with 41 additions and 27 deletions.
68 changes: 41 additions & 27 deletions Core/Librarys/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,37 +87,51 @@ public static void Save(bool isNow = false)
return;
}

string loggerName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
"Log", DateTime.Now.ToString("yyyy-MM-dd") + ".log");
lock (writeLock)
try
{
string dir = Path.GetDirectoryName(loggerName);
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
Write(string.Join(string.Empty, loggers));
loggers.Clear();
}
catch (Exception ec)
{
Error(ec.ToString());
}
}

if (!File.Exists(loggerName))
private static void Write(string log_)
{
try
{
lock (writeLock)
{
List<string> clientInfo = new List<string>(5);

// 记录客户端信息


// tai版本号
clientInfo.Add(FromatItem("Core Version", Assembly.GetExecutingAssembly().GetName().Version.ToString()));
clientInfo.Add(FromatItem("OS Name", SystemCommon.GetWindowsVersionName()));
clientInfo.Add(FromatItem("Computer Type", GetComputerType()));
clientInfo.Add(FromatItem("Screen", GetScreenSize()));
clientInfo.Add("\r\n++++++++++++++++++++++++++++++++++++++++++++++++++\r\n\r\n");

File.WriteAllText(loggerName, string.Join("\r\n", clientInfo));
string loggerName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
"Log", DateTime.Now.ToString("yyyy-MM-dd") + ".log");
string dir = Path.GetDirectoryName(loggerName);
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}

if (!File.Exists(loggerName))
{
List<string> clientInfo = new List<string>(5);

// 记录客户端信息
clientInfo.Add(FromatItem("Core Version", Assembly.GetExecutingAssembly().GetName().Version.ToString()));
clientInfo.Add(FromatItem("OS Name", SystemCommon.GetWindowsVersionName()));
clientInfo.Add(FromatItem("Computer Type", GetComputerType()));
clientInfo.Add(FromatItem("Screen", GetScreenSize()));
clientInfo.Add("\r\n++++++++++++++++++++++++++++++++++++++++++++++++++\r\n\r\n");

File.WriteAllText(loggerName, string.Join("\r\n", clientInfo), Encoding.UTF8);
}
File.AppendAllText(loggerName, log_, Encoding.UTF8);
}


File.AppendAllText(loggerName, string.Join(string.Empty, loggers));

loggers.Clear();
}
catch (Exception ec)
{
loggers.Add(log_);
Error(ec.ToString());
}
}

Expand Down

0 comments on commit c0f2bda

Please sign in to comment.