https://github.com/2dust/v2rayN/issues/5928
This commit is contained in:
2dust 2024-10-28 09:16:24 +08:00
parent 019869ec28
commit 7df90a6034
3 changed files with 24 additions and 21 deletions

View file

@ -37,40 +37,41 @@ namespace ServiceLib.Common
foreach (var filePath in files) foreach (var filePath in files)
{ {
var file = new FileInfo(filePath); var file = new FileInfo(filePath);
if (file.CreationTime < now) if (file.CreationTime >= now) continue;
try
{ {
try file.Delete();
{ }
file.Delete(); catch
} {
catch { } // ignored
} }
} }
} }
catch { } catch
{
// ignored
}
}); });
} }
public static void SaveLog(string strContent) public static void SaveLog(string strContent)
{ {
if (LogManager.IsLoggingEnabled()) if (!LogManager.IsLoggingEnabled()) return;
{
var logger = LogManager.GetLogger("Log1"); LogManager.GetLogger("Log1").Info(strContent);
logger.Info(strContent);
}
} }
public static void SaveLog(string strTitle, Exception ex) 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.Error(ex.InnerException);
logger.Debug($"{strTitle},{ex.Message}");
logger.Debug(ex.StackTrace);
if (ex?.InnerException != null)
{
logger.Error(ex.InnerException);
}
} }
} }
} }

View file

@ -71,7 +71,7 @@
public bool InitComponents() public bool InitComponents()
{ {
Logging.Setup(); Logging.Setup();
Logging.LoggingEnabled(true); Logging.LoggingEnabled(_config.GuiItem.EnableLog);
Logging.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}"); Logging.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
Logging.SaveLog($"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}"); Logging.SaveLog($"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
Logging.ClearLogs(); Logging.ClearLogs();

View file

@ -88,6 +88,8 @@
public int TrayMenuServersLimit { get; set; } = 20; public int TrayMenuServersLimit { get; set; } = 20;
public bool EnableHWA { get; set; } = false; public bool EnableHWA { get; set; } = false;
public bool EnableLog { get; set; } = true;
} }
[Serializable] [Serializable]