Gui's log can be turned off

pull/3530/head
2dust 2 years ago
parent b1a82d95c2
commit 6ee8f03ec0

@ -42,10 +42,11 @@ namespace v2rayN
Global.processJob = new Job(); Global.processJob = new Job();
Logging.Setup(); Logging.Setup();
Init();
Logging.LoggingEnabled(_config.guiItem.enableLog);
Utils.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}"); Utils.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
Logging.ClearLogs(); Logging.ClearLogs();
Init();
Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage); Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage);

@ -103,8 +103,10 @@ namespace v2rayN.Mode
public bool enableSecurityProtocolTls13 { get; set; } public bool enableSecurityProtocolTls13 { get; set; }
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]

@ -17,6 +17,13 @@ namespace v2rayN.Tool
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, fileTarget)); config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, fileTarget));
LogManager.Configuration = config; LogManager.Configuration = config;
} }
public static void LoggingEnabled(bool enable)
{
if (!enable)
{
LogManager.SuspendLogging();
}
}
public static void ClearLogs() public static void ClearLogs()
{ {

@ -780,7 +780,7 @@ namespace v2rayN
task.Settings.RunOnlyIfIdle = false; task.Settings.RunOnlyIfIdle = false;
task.Settings.IdleSettings.StopOnIdleEnd = false; task.Settings.IdleSettings.StopOnIdleEnd = false;
task.Settings.ExecutionTimeLimit = TimeSpan.Zero; task.Settings.ExecutionTimeLimit = TimeSpan.Zero;
task.Triggers.Add(new LogonTrigger { UserId = logonUser, Delay = TimeSpan.FromMinutes(1) }); task.Triggers.Add(new LogonTrigger { UserId = logonUser, Delay = TimeSpan.FromSeconds(10) });
task.Principal.RunLevel = TaskRunLevel.Highest; task.Principal.RunLevel = TaskRunLevel.Highest;
task.Actions.Add(new ExecAction(deamonFileName)); task.Actions.Add(new ExecAction(deamonFileName));
@ -1152,17 +1152,23 @@ namespace v2rayN
public static void SaveLog(string strContent) public static void SaveLog(string strContent)
{ {
var logger = LogManager.GetLogger("Log1"); if (LogManager.IsLoggingEnabled())
logger.Info(strContent); {
var logger = LogManager.GetLogger("Log1");
logger.Info(strContent);
}
} }
public static void SaveLog(string strTitle, Exception ex) public static void SaveLog(string strTitle, Exception ex)
{ {
var logger = LogManager.GetLogger("Log2"); if (LogManager.IsLoggingEnabled())
logger.Debug($"{strTitle},{ex.Message}");
logger.Debug(ex.StackTrace);
if (ex?.InnerException != null)
{ {
logger.Error(ex.InnerException); var logger = LogManager.GetLogger("Log2");
logger.Debug($"{strTitle},{ex.Message}");
logger.Debug(ex.StackTrace);
if (ex?.InnerException != null)
{
logger.Error(ex.InnerException);
}
} }
} }

Loading…
Cancel
Save