Add a title to SaveLog

pull/6443/head
2dust 2025-01-03 15:02:31 +08:00
parent 5392766c5e
commit 3db1dd7bbb
27 changed files with 135 additions and 106 deletions

View File

@ -6,6 +6,8 @@ namespace ServiceLib.Common
{ {
public static class FileManager public static class FileManager
{ {
private static readonly string _tag = "FileManager";
public static bool ByteArrayToFile(string fileName, byte[] content) public static bool ByteArrayToFile(string fileName, byte[] content)
{ {
try try
@ -15,7 +17,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return false; return false;
} }
@ -30,7 +32,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -46,7 +48,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -60,7 +62,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -79,7 +81,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
throw; throw;
} }
} }
@ -105,13 +107,13 @@ namespace ServiceLib.Common
} }
catch (IOException ex) catch (IOException ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
return false; return false;
} }
return true; return true;
@ -130,7 +132,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
return null; return null;
} }
} }
@ -148,7 +150,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
return false; return false;
} }
return true; return true;

View File

@ -6,6 +6,8 @@ namespace ServiceLib.Common
{ {
public class JsonUtils public class JsonUtils
{ {
private static readonly string _tag = "JsonUtils";
/// <summary> /// <summary>
/// DeepCopy /// DeepCopy
/// </summary> /// </summary>
@ -90,7 +92,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return result; return result;
} }

View File

@ -15,6 +15,8 @@ namespace ServiceLib.Common
{ {
public class Utils public class Utils
{ {
private static readonly string _tag = "Utils";
#region 资源操作 #region 资源操作
/// <summary> /// <summary>
@ -36,7 +38,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return result; return result;
@ -57,7 +59,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return null; return null;
@ -92,7 +94,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return string.Empty; return string.Empty;
@ -117,7 +119,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return null; return null;
@ -139,7 +141,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return null; return null;
@ -159,7 +161,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("Base64Encode", ex); Logging.SaveLog(_tag, ex);
} }
return string.Empty; return string.Empty;
@ -193,7 +195,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("Base64Decode", ex); Logging.SaveLog(_tag, ex);
} }
return string.Empty; return string.Empty;
@ -483,7 +485,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return false; return false;
@ -535,7 +537,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return Global.AppName; return Global.AppName;
@ -549,7 +551,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
return "0.0"; return "0.0";
} }
} }
@ -578,7 +580,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return string.Empty; return string.Empty;
@ -605,7 +607,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -631,7 +633,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return systemHosts; return systemHosts;

View File

@ -4,6 +4,7 @@ namespace ServiceLib.Common
{ {
internal static class WindowsUtils internal static class WindowsUtils
{ {
private static readonly string _tag = "WindowsUtils";
public static string? RegReadValue(string path, string name, string def) public static string? RegReadValue(string path, string name, string def)
{ {
RegistryKey? regKey = null; RegistryKey? regKey = null;
@ -15,7 +16,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
finally finally
{ {
@ -41,7 +42,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
finally finally
{ {

View File

@ -6,6 +6,8 @@ namespace ServiceLib.Common
{ {
public class YamlUtils public class YamlUtils
{ {
private static readonly string _tag = "YamlUtils";
#region YAML #region YAML
/// <summary> /// <summary>
@ -26,7 +28,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("FromYaml", ex); Logging.SaveLog(_tag, ex);
return deserializer.Deserialize<T>(""); return deserializer.Deserialize<T>("");
} }
} }
@ -53,7 +55,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return result; return result;
} }
@ -71,7 +73,7 @@ namespace ServiceLib.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("PreprocessYaml", ex); Logging.SaveLog(_tag, ex);
return null; return null;
} }
} }

View File

@ -5,6 +5,8 @@ namespace ServiceLib.Handler
{ {
public static class AutoStartupHandler public static class AutoStartupHandler
{ {
private static readonly string _tag = "AutoStartupHandler";
public static async Task<bool> UpdateTask(Config config) public static async Task<bool> UpdateTask(Config config)
{ {
if (Utils.IsWindows()) if (Utils.IsWindows())
@ -62,7 +64,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -123,7 +125,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -143,7 +145,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }

View File

@ -9,6 +9,7 @@ namespace ServiceLib.Handler
private Dictionary<string, ProxiesItem>? _proxies; private Dictionary<string, ProxiesItem>? _proxies;
public Dictionary<string, object> ProfileContent { get; set; } public Dictionary<string, object> ProfileContent { get; set; }
private static readonly string _tag = "ClashApiHandler";
public async Task<Tuple<ClashProxies, ClashProviders>?> GetClashProxiesAsync(Config config) public async Task<Tuple<ClashProxies, ClashProviders>?> GetClashProxiesAsync(Config config)
{ {
@ -109,7 +110,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("GetClashProxyGroups", ex); Logging.SaveLog(_tag, ex);
return null; return null;
} }
} }
@ -125,7 +126,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -153,7 +154,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -169,7 +170,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return null; return null;
@ -184,7 +185,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }

View File

@ -9,6 +9,7 @@ namespace ServiceLib.Handler
public class ConfigHandler public class ConfigHandler
{ {
private static readonly string _configRes = Global.ConfigFileName; private static readonly string _configRes = Global.ConfigFileName;
private static readonly string _tag = "ConfigHandler";
#region ConfigHandler #region ConfigHandler
@ -194,7 +195,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("ToJsonFile", ex); Logging.SaveLog(_tag, ex);
return -1; return -1;
} }
@ -500,7 +501,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
return -1; return -1;
} }
@ -987,7 +988,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("Remove Item", ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;

View File

@ -1,10 +1,14 @@
namespace ServiceLib.Handler using YamlDotNet.Core.Tokens;
namespace ServiceLib.Handler
{ {
/// <summary> /// <summary>
/// Core configuration file processing class /// Core configuration file processing class
/// </summary> /// </summary>
public class CoreConfigHandler public class CoreConfigHandler
{ {
private static readonly string _tag = "CoreConfigHandler";
public static async Task<RetResult> GenerateClientConfig(ProfileItem node, string? fileName) public static async Task<RetResult> GenerateClientConfig(ProfileItem node, string? fileName)
{ {
var config = AppHandler.Instance.Config; var config = AppHandler.Instance.Config;
@ -82,7 +86,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("GenerateClientCustomConfig", ex); Logging.SaveLog(_tag, ex);
ret.Msg = ResUI.FailedGenDefaultConfiguration; ret.Msg = ResUI.FailedGenDefaultConfiguration;
return ret; return ret;
} }

View File

@ -2,6 +2,8 @@
{ {
public class FmtHandler public class FmtHandler
{ {
private static readonly string _tag = "FmtHandler";
public static string? GetShareUri(ProfileItem item) public static string? GetShareUri(ProfileItem item)
{ {
try try
@ -23,7 +25,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
return ""; return "";
} }
} }
@ -81,7 +83,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
msg = ResUI.Incorrectconfiguration; msg = ResUI.Incorrectconfiguration;
return null; return null;
} }

View File

@ -10,6 +10,7 @@ namespace ServiceLib.Handler
private ConcurrentBag<ProfileExItem> _lstProfileEx = []; private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
private Queue<string> _queIndexIds = new(); private Queue<string> _queIndexIds = new();
public static ProfileExHandler Instance => _instance.Value; public static ProfileExHandler Instance => _instance.Value;
private static readonly string _tag = "ProfileExHandler";
public ProfileExHandler() public ProfileExHandler()
{ {
@ -87,7 +88,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("ProfileExHandler", ex); Logging.SaveLog(_tag, ex);
} }
} }
} }
@ -119,7 +120,7 @@ namespace ServiceLib.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }

View File

@ -12,7 +12,7 @@
private StatisticsXrayService? _statisticsXray; private StatisticsXrayService? _statisticsXray;
private StatisticsSingboxService? _statisticsSingbox; private StatisticsSingboxService? _statisticsSingbox;
private static readonly string _tag = "StatisticsHandler";
public List<ServerStatItem> ServerStat => _lstServerStat; public List<ServerStatItem> ServerStat => _lstServerStat;
public async Task Init(Config config, Action<ServerSpeedItem> updateFunc) public async Task Init(Config config, Action<ServerSpeedItem> updateFunc)
@ -39,7 +39,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -61,7 +61,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }

View File

@ -72,7 +72,6 @@ namespace ServiceLib.Handler.SysProxy
catch (Exception ex) catch (Exception ex)
{ {
SetProxyFallback(strProxy, exceptions, type); SetProxyFallback(strProxy, exceptions, type);
//Logging.SaveLog(ex.Message, ex);
return false; return false;
} }
} }

View File

@ -2,6 +2,7 @@
{ {
public static class SysProxyHandler public static class SysProxyHandler
{ {
private static readonly string _tag = "SysProxyHandler";
public static async Task<bool> UpdateSysProxy(Config config, bool forceDisable) public static async Task<bool> UpdateSysProxy(Config config, bool forceDisable)
{ {
var type = config.SystemProxyItem.SysProxyType; var type = config.SystemProxyItem.SysProxyType;
@ -59,7 +60,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return true; return true;
} }

View File

@ -13,7 +13,8 @@ namespace ServiceLib.Handler
private string? _lastDescription; private string? _lastDescription;
private string _webDir = Global.AppName + "_backup"; private string _webDir = Global.AppName + "_backup";
private readonly string _webFileName = "backup.zip"; private readonly string _webFileName = "backup.zip";
private string _logTitle = "WebDav--"; private readonly string _tag = "WebDav--";
public WebDavHandler() public WebDavHandler()
{ {
@ -81,13 +82,13 @@ namespace ServiceLib.Handler
private void SaveLog(string desc) private void SaveLog(string desc)
{ {
_lastDescription = desc; _lastDescription = desc;
Logging.SaveLog(_logTitle + desc); Logging.SaveLog(_tag + desc);
} }
private void SaveLog(Exception ex) private void SaveLog(Exception ex)
{ {
_lastDescription = ex.Message; _lastDescription = ex.Message;
Logging.SaveLog(_logTitle, ex); Logging.SaveLog(_tag, ex);
} }
public async Task<bool> CheckConnection() public async Task<bool> CheckConnection()

View File

@ -6,6 +6,7 @@ namespace ServiceLib.Services.CoreConfig
public class CoreConfigClashService public class CoreConfigClashService
{ {
private Config _config; private Config _config;
private static readonly string _tag = "CoreConfigClashService";
public CoreConfigClashService(Config config) public CoreConfigClashService(Config config)
{ {
@ -131,7 +132,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("GenerateClientConfigClash-Mixin", ex); Logging.SaveLog($"{_tag}-Mixin", ex);
} }
var txtFileNew = YamlUtils.ToYaml(fileContent).Replace(tagYamlStr2, tagYamlStr3); var txtFileNew = YamlUtils.ToYaml(fileContent).Replace(tagYamlStr2, tagYamlStr3);
@ -151,7 +152,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("GenerateClientConfigClash", ex); Logging.SaveLog(_tag, ex);
ret.Msg = ResUI.FailedGenDefaultConfiguration; ret.Msg = ResUI.FailedGenDefaultConfiguration;
return ret; return ret;
} }

View File

@ -7,6 +7,7 @@ namespace ServiceLib.Services.CoreConfig
public class CoreConfigSingboxService public class CoreConfigSingboxService
{ {
private Config _config; private Config _config;
private static readonly string _tag = "CoreConfigSingboxService";
public CoreConfigSingboxService(Config config) public CoreConfigSingboxService(Config config)
{ {
@ -71,7 +72,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("GenerateClientConfig4Singbox", ex); Logging.SaveLog(_tag, ex);
ret.Msg = ResUI.FailedGenDefaultConfiguration; ret.Msg = ResUI.FailedGenDefaultConfiguration;
return ret; return ret;
} }
@ -114,7 +115,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
await GenLog(singboxConfig); await GenLog(singboxConfig);
@ -235,7 +236,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
ret.Msg = ResUI.FailedGenDefaultConfiguration; ret.Msg = ResUI.FailedGenDefaultConfiguration;
return ret; return ret;
} }
@ -351,7 +352,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
ret.Msg = ResUI.FailedGenDefaultConfiguration; ret.Msg = ResUI.FailedGenDefaultConfiguration;
return ret; return ret;
} }
@ -432,7 +433,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
ret.Msg = ResUI.FailedGenDefaultConfiguration; ret.Msg = ResUI.FailedGenDefaultConfiguration;
return ret; return ret;
} }
@ -473,7 +474,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -562,7 +563,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -695,7 +696,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -718,7 +719,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -768,7 +769,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -845,7 +846,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -897,7 +898,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
@ -969,7 +970,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -1085,7 +1086,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -1184,7 +1185,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }

View File

@ -7,6 +7,7 @@ namespace ServiceLib.Services.CoreConfig
public class CoreConfigV2rayService public class CoreConfigV2rayService
{ {
private Config _config; private Config _config;
private static readonly string _tag = "CoreConfigV2rayService";
public CoreConfigV2rayService(Config config) public CoreConfigV2rayService(Config config)
{ {
@ -70,7 +71,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("GenerateClientConfig4V2ray", ex); Logging.SaveLog(_tag, ex);
ret.Msg = ResUI.FailedGenDefaultConfiguration; ret.Msg = ResUI.FailedGenDefaultConfiguration;
return ret; return ret;
} }
@ -197,7 +198,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
ret.Msg = ResUI.FailedGenDefaultConfiguration; ret.Msg = ResUI.FailedGenDefaultConfiguration;
return ret; return ret;
} }
@ -240,7 +241,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
await GenLog(v2rayConfig); await GenLog(v2rayConfig);
@ -349,7 +350,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
ret.Msg = ResUI.FailedGenDefaultConfiguration; ret.Msg = ResUI.FailedGenDefaultConfiguration;
return ret; return ret;
} }
@ -379,7 +380,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -423,7 +424,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -482,7 +483,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -560,7 +561,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -754,7 +755,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -778,7 +779,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -1020,7 +1021,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -1083,7 +1084,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;
} }
@ -1241,7 +1242,7 @@ namespace ServiceLib.Services.CoreConfig
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return 0; return 0;

View File

@ -13,6 +13,7 @@ namespace ServiceLib.Services
public event EventHandler<RetResult>? UpdateCompleted; public event EventHandler<RetResult>? UpdateCompleted;
public event ErrorEventHandler? Error; public event ErrorEventHandler? Error;
private static readonly string _tag = "DownloadService";
public async Task<int> DownloadDataAsync(string url, WebProxy webProxy, int downloadTimeout, Action<bool, string> updateFunc) public async Task<int> DownloadDataAsync(string url, WebProxy webProxy, int downloadTimeout, Action<bool, string> updateFunc)
{ {
@ -68,7 +69,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
Error?.Invoke(this, new ErrorEventArgs(ex)); Error?.Invoke(this, new ErrorEventArgs(ex));
if (ex.InnerException != null) if (ex.InnerException != null)
@ -113,7 +114,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
Error?.Invoke(this, new ErrorEventArgs(ex)); Error?.Invoke(this, new ErrorEventArgs(ex));
if (ex.InnerException != null) if (ex.InnerException != null)
{ {
@ -131,7 +132,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
Error?.Invoke(this, new ErrorEventArgs(ex)); Error?.Invoke(this, new ErrorEventArgs(ex));
if (ex.InnerException != null) if (ex.InnerException != null)
{ {
@ -177,7 +178,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
Error?.Invoke(this, new ErrorEventArgs(ex)); Error?.Invoke(this, new ErrorEventArgs(ex));
if (ex.InnerException != null) if (ex.InnerException != null)
{ {
@ -208,7 +209,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
Error?.Invoke(this, new ErrorEventArgs(ex)); Error?.Invoke(this, new ErrorEventArgs(ex));
if (ex.InnerException != null) if (ex.InnerException != null)
{ {
@ -232,13 +233,13 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
return -1; return -1;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
return -1; return -1;
} }
} }

View File

@ -11,6 +11,7 @@ namespace ServiceLib.Services
private Action<SpeedTestResult>? _updateFunc; private Action<SpeedTestResult>? _updateFunc;
private bool _exitLoop = false; private bool _exitLoop = false;
private static readonly string _tag = "SpeedtestService";
public SpeedtestService(Config config, List<ProfileItem> selecteds, ESpeedActionType actionType, Action<SpeedTestResult> updateFunc) public SpeedtestService(Config config, List<ProfileItem> selecteds, ESpeedActionType actionType, Action<SpeedTestResult> updateFunc)
{ {
@ -146,7 +147,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
})); }));
} }
@ -154,7 +155,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
finally finally
{ {
@ -201,7 +202,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
})); }));
} }
@ -209,7 +210,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
finally finally
{ {
@ -389,7 +390,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return responseTime; return responseTime;
} }

View File

@ -10,6 +10,7 @@ namespace ServiceLib.Services.Statistics
private ClientWebSocket? webSocket; private ClientWebSocket? webSocket;
private Action<ServerSpeedItem>? _updateFunc; private Action<ServerSpeedItem>? _updateFunc;
private string Url => $"ws://{Global.Loopback}:{AppHandler.Instance.StatePort2}/traffic"; private string Url => $"ws://{Global.Loopback}:{AppHandler.Instance.StatePort2}/traffic";
private static readonly string _tag = "StatisticsSingboxService";
public StatisticsSingboxService(Config config, Action<ServerSpeedItem> updateFunc) public StatisticsSingboxService(Config config, Action<ServerSpeedItem> updateFunc)
{ {
@ -48,7 +49,7 @@ namespace ServiceLib.Services.Statistics
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
} }

View File

@ -7,6 +7,7 @@ namespace ServiceLib.Services
{ {
private Action<bool, string>? _updateFunc; private Action<bool, string>? _updateFunc;
private int _timeout = 30; private int _timeout = 30;
private static readonly string _tag = "UpdateService";
public async Task CheckUpdateGuiN(Config config, Action<bool, string> updateFunc, bool preRelease) public async Task CheckUpdateGuiN(Config config, Action<bool, string> updateFunc, bool preRelease)
{ {
@ -272,7 +273,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
_updateFunc?.Invoke(false, ex.Message); _updateFunc?.Invoke(false, ex.Message);
return new RetResult(false, ex.Message); return new RetResult(false, ex.Message);
} }
@ -356,7 +357,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
_updateFunc?.Invoke(false, ex.Message); _updateFunc?.Invoke(false, ex.Message);
return new SemanticVersion(""); return new SemanticVersion("");
} }
@ -415,7 +416,7 @@ namespace ServiceLib.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
_updateFunc?.Invoke(false, ex.Message); _updateFunc?.Invoke(false, ex.Message);
return new RetResult(false, ex.Message); return new RetResult(false, ex.Message);
} }

View File

@ -279,9 +279,8 @@ namespace ServiceLib.ViewModels
Locator.Current.GetService<ProfilesViewModel>()?.UpdateStatistics(update); Locator.Current.GetService<ProfilesViewModel>()?.UpdateStatistics(update);
} }
} }
catch (Exception ex) catch
{ {
Logging.SaveLog(ex.Message, ex);
} }
} }

View File

@ -235,7 +235,7 @@ namespace v2rayN.Desktop.Views
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("fill fonts error", ex); Logging.SaveLog("GetFonts", ex);
} }
return lstFonts; return lstFonts;
} }

View File

@ -13,6 +13,7 @@ namespace v2rayN
{ {
internal static class WindowsUtils internal static class WindowsUtils
{ {
private static readonly string _tag = "WindowsUtils";
/// <summary> /// <summary>
/// 获取剪贴板数 /// 获取剪贴板数
/// </summary> /// </summary>
@ -31,7 +32,7 @@ namespace v2rayN
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
} }
return strData; return strData;
} }

View File

@ -8,6 +8,7 @@ namespace v2rayN.Handler
{ {
private static readonly Lazy<WindowsHandler> instance = new(() => new()); private static readonly Lazy<WindowsHandler> instance = new(() => new());
public static WindowsHandler Instance => instance.Value; public static WindowsHandler Instance => instance.Value;
private static readonly string _tag = "WindowsHandler";
public async Task<Icon> GetNotifyIcon(Config config) public async Task<Icon> GetNotifyIcon(Config config)
{ {
@ -39,7 +40,7 @@ namespace v2rayN.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
return Properties.Resources.NotifyIcon1; return Properties.Resources.NotifyIcon1;
} }
} }
@ -89,7 +90,7 @@ namespace v2rayN.Handler
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(_tag, ex);
return null; return null;
} }
} }

View File

@ -246,7 +246,7 @@ namespace v2rayN.Views
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("fill fonts error", ex); Logging.SaveLog("GetFonts", ex);
} }
return lstFonts.OrderBy(t => t).ToList(); return lstFonts.OrderBy(t => t).ToList();
} }