Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Oct 28, 2024
1 parent 019869e commit 7df90a6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
41 changes: 21 additions & 20 deletions v2rayN/ServiceLib/Common/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,41 @@ public static void ClearLogs()
foreach (var filePath in files)
{
var file = new FileInfo(filePath);
if (file.CreationTime < now)
if (file.CreationTime >= now) continue;
try
{
try
{
file.Delete();
}
catch { }
file.Delete();
}
catch
{
// ignored
}
}
}
catch { }
catch
{
// ignored
}
});
}

public static void SaveLog(string strContent)
{
if (LogManager.IsLoggingEnabled())
{
var logger = LogManager.GetLogger("Log1");
logger.Info(strContent);
}
if (!LogManager.IsLoggingEnabled()) return;

LogManager.GetLogger("Log1").Info(strContent);
}

public static void SaveLog(string strTitle, Exception ex)
{
if (LogManager.IsLoggingEnabled())
if (!LogManager.IsLoggingEnabled()) return;

var logger = LogManager.GetLogger("Log2");
logger.Debug($"{strTitle},{ex.Message}");
logger.Debug(ex.StackTrace);
if (ex?.InnerException != null)
{
var logger = LogManager.GetLogger("Log2");
logger.Debug($"{strTitle},{ex.Message}");
logger.Debug(ex.StackTrace);
if (ex?.InnerException != null)
{
logger.Error(ex.InnerException);
}
logger.Error(ex.InnerException);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/Handler/AppHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public bool InitApp()
public bool InitComponents()
{
Logging.Setup();
Logging.LoggingEnabled(true);
Logging.LoggingEnabled(_config.GuiItem.EnableLog);
Logging.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
Logging.SaveLog($"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
Logging.ClearLogs();
Expand Down
2 changes: 2 additions & 0 deletions v2rayN/ServiceLib/Models/ConfigItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public class GUIItem
public int TrayMenuServersLimit { get; set; } = 20;

public bool EnableHWA { get; set; } = false;

public bool EnableLog { get; set; } = true;
}

[Serializable]
Expand Down

0 comments on commit 7df90a6

Please sign in to comment.