修改V8.cs中的Log方法,使其遵循DeviceManager.LogToFile控制标志,并修正DeviceManager.cs中LogToFile的默认值为true
This commit is contained in:
@@ -486,18 +486,22 @@ namespace JoyD.Windows.CS.Toprie
|
||||
{
|
||||
try
|
||||
{
|
||||
// 确保日志目录存在
|
||||
string logDirectory = Path.GetDirectoryName(LogFilePath);
|
||||
if (!Directory.Exists(logDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(logDirectory);
|
||||
}
|
||||
|
||||
// 写入日志,不添加额外时间戳(因为原始消息已包含时间戳)
|
||||
File.AppendAllText(LogFilePath, message + Environment.NewLine);
|
||||
|
||||
// 同时输出到控制台
|
||||
Console.WriteLine(message);
|
||||
|
||||
// 仅在DeviceManager.LogToFile为true时写入日志文件
|
||||
if (DeviceManager.LogToFile)
|
||||
{
|
||||
// 确保日志目录存在
|
||||
string logDirectory = Path.GetDirectoryName(LogFilePath);
|
||||
if (!Directory.Exists(logDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(logDirectory);
|
||||
}
|
||||
|
||||
// 写入日志,不添加额外时间戳(因为原始消息已包含时间戳)
|
||||
File.AppendAllText(LogFilePath, message + Environment.NewLine);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user