Update Log

This commit is contained in:
ChsBuffer
2021-07-15 14:29:56 +08:00
parent d5e1ef1a56
commit ee206f3df0
8 changed files with 37 additions and 15 deletions

View File

@@ -35,10 +35,11 @@ namespace Netch.Controllers
if (Log.IsEnabled(LogEventLevel.Debug))
Task.Run(() =>
{
// TODO log level setting
Log.Debug("Running Processes: \n{Processes}", string.Join("\n", SystemInfo.Processes(false)));
}).Forget();
{
// TODO log level setting
Log.Debug("Running Processes: \n{Processes}", string.Join("\n", SystemInfo.Processes(false)));
})
.Forget();
try
{
@@ -73,7 +74,7 @@ namespace Netch.Controllers
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", ServerController.Name));
Log.Debug($"{server.Type} {server.MaskedData()}");
Log.Debug("Server Information: {Data}", $"{server.Type} {server.MaskedData()}");
var socks5 = ServerController.Start(server);
StatusPortInfoText.Socks5Port = socks5.Port;
@@ -134,7 +135,8 @@ namespace Netch.Controllers
}
catch (PortReservedException)
{
throw new MessageException(i18N.TranslateFormat("The {0} port is reserved by system.", $"{portName} ({port})"));
throw new MessageException(i18N.TranslateFormat("The {0} port is reserved by system.",
$"{portName} ({port})"));
}
}
@@ -153,7 +155,8 @@ namespace Netch.Controllers
}
else
{
throw new MessageException(i18N.TranslateFormat("The {0} port is used by {1}.", $"{portName} ({port})", $"({p.Id}){fileName}"));
throw new MessageException(i18N.TranslateFormat("The {0} port is used by {1}.",
$"{portName} ({port})", $"({p.Id}){fileName}"));
}
}

View File

@@ -147,7 +147,6 @@ namespace Netch.Controllers
private void SetupRouteTable()
{
Global.MainForm.StatusText(i18N.Translate("Setup Route Table Rule"));
Log.Information("设置路由规则");
// Server Address
if (_serverRemoteAddress != null)

View File

@@ -10,7 +10,7 @@ namespace Netch.Interops
public static bool Dial(NameList name, string value)
{
Log.Debug($"[aiodns] Dial {name}: {value}");
Log.Verbose($"[aiodns] Dial {name}: {value}");
return aiodns_dial(name, Encoding.UTF8.GetBytes(value));
}

View File

@@ -43,7 +43,7 @@ namespace Netch.Interops
public static bool Dial(NameList name, string value)
{
Log.Debug($"[Redirector] Dial {name}: {value}");
Log.Verbose($"[Redirector] Dial {name}: {value}");
return aio_dial(name, value);
}

View File

@@ -36,13 +36,13 @@ namespace Netch.Interops
public static bool Dial(NameList name, string value)
{
Log.Debug( $"[tun2socks] Dial {name}: {value}");
Log.Verbose( $"[tun2socks] Dial {name}: {value}");
return tun_dial(name, Encoding.UTF8.GetBytes(value));
}
public static bool Init()
{
Log.Debug("[tun2socks] init");
Log.Verbose("[tun2socks] init");
return tun_init();
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
@@ -99,6 +100,7 @@ namespace Netch
Log.Information("Netch Version: {Version}", $"{UpdateChecker.Owner}/{UpdateChecker.Repo}@{UpdateChecker.Version}");
Log.Information("Environment: {OSVersion}", Environment.OSVersion);
Log.Information("SHA256: {Hash}", $"{Utils.Utils.SHA256CheckSum(Global.NetchExecutable)}");
Log.Information("System Language: {Language}", CultureInfo.CurrentCulture.Name);
if (Log.IsEnabled(LogEventLevel.Debug))
Log.Debug("Third-party Drivers:\n{Drivers}", string.Join("\n", SystemInfo.SystemDrivers(false)));
}

View File

@@ -135,7 +135,8 @@ namespace Netch.Utils
break;
default:
throw new ArgumentOutOfRangeException(nameof(type), type, null);
Trace.Assert(false);
return;
}
}
@@ -161,7 +162,8 @@ namespace Netch.Utils
break;
default:
throw new ArgumentOutOfRangeException(nameof(type), type, null);
Trace.Assert(false);
return;
}
}

View File

@@ -28,6 +28,14 @@ namespace Netch.Utils
public static bool CreateRoute(NetRoute o)
{
Log.Verbose("CreateRoute {InterNetwork} {Address} {Cidr} {Gateway} {Interface} {Metric}",
AddressFamily.InterNetwork,
o.Network,
o.Cidr,
o.Gateway,
(ulong)o.InterfaceIndex,
o.Metric);
return RouteHelper.CreateRoute(AddressFamily.InterNetwork, o.Network, o.Cidr, o.Gateway, (ulong)o.InterfaceIndex, o.Metric);
}
@@ -41,7 +49,7 @@ namespace Netch.Utils
{
if (!TryParseIPNetwork(rule, out var network, out var cidr))
{
Log.Warning("invalid rule {Rule}",rule);
Log.Warning("invalid rule {Rule}", rule);
return false;
}
@@ -50,6 +58,14 @@ namespace Netch.Utils
public static bool DeleteRoute(NetRoute o)
{
Log.Verbose("DeleteRoute {InterNetwork} {Address} {Cidr} {Gateway} {Interface} {Metric}",
AddressFamily.InterNetwork,
o.Network,
o.Cidr,
o.Gateway,
(ulong)o.InterfaceIndex,
o.Metric);
return RouteHelper.DeleteRoute(AddressFamily.InterNetwork, o.Network, o.Cidr, o.Gateway, (ulong)o.InterfaceIndex, o.Metric);
}