默认udp日志端口
This commit is contained in:
parent
22fdf2ac8e
commit
3123c29c4d
@ -1,9 +0,0 @@
|
||||
<Application x:Class="FastGithub.UI.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:FastGithub.UI"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@ -11,6 +11,7 @@
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<AutoGenerateBindingRedirects>False</AutoGenerateBindingRedirects>
|
||||
<StartupObject></StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -18,6 +19,14 @@
|
||||
<Resource Include="Resource\*.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="App.xaml.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Remove="App.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -8,18 +8,24 @@ using System.Windows;
|
||||
|
||||
namespace FastGithub.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// App.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
class Program
|
||||
{
|
||||
private readonly Mutex globalMutex;
|
||||
private readonly bool isFirstInstance;
|
||||
|
||||
public App()
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
this.globalMutex = new Mutex(true, "Global\\FastGithub.UI", out this.isFirstInstance);
|
||||
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
|
||||
using var mutex = new Mutex(true, "Global\\FastGithub.UI", out var isFirstInstance);
|
||||
if (isFirstInstance == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StartFastGithub();
|
||||
SetWebBrowserVersion(9000);
|
||||
|
||||
var app = new Application();
|
||||
app.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
|
||||
app.Run();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -36,33 +42,12 @@ namespace FastGithub.UI
|
||||
return default;
|
||||
}
|
||||
|
||||
var stream = GetResourceStream(new Uri($"Resource/{name}.dll", UriKind.Relative)).Stream;
|
||||
var stream = Application.GetResourceStream(new Uri($"Resource/{name}.dll", UriKind.Relative)).Stream;
|
||||
var buffer = new byte[stream.Length];
|
||||
stream.Read(buffer, 0, buffer.Length);
|
||||
return Assembly.Load(buffer);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 程序启动
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
if (this.isFirstInstance == false)
|
||||
{
|
||||
this.Shutdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
StartFastGithub();
|
||||
SetWebBrowserVersion(9000);
|
||||
}
|
||||
|
||||
base.OnStartup(e);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置浏览器版本
|
||||
/// </summary>
|
||||
@ -95,15 +80,5 @@ namespace FastGithub.UI
|
||||
};
|
||||
Process.Start(startInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 程序退出
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
{
|
||||
this.globalMutex.Dispose();
|
||||
base.OnExit(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.1.2" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.2.0" />
|
||||
|
||||
@ -46,6 +46,18 @@ namespace FastGithub
|
||||
}
|
||||
}
|
||||
})
|
||||
.UseSerilog((hosting, logger) =>
|
||||
{
|
||||
var template = "{Timestamp:O} [{Level:u3}]{NewLine}{SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}";
|
||||
logger
|
||||
.ReadFrom.Configuration(hosting.Configuration)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console(outputTemplate: template)
|
||||
.WriteTo.File(Path.Combine("logs", @"log.txt"), rollingInterval: RollingInterval.Day, outputTemplate: template);
|
||||
|
||||
var udpLoggerPort = hosting.Configuration.GetValue(nameof(AppOptions.UdpLoggerPort), 38457);
|
||||
logger.WriteTo.UDPSink(IPAddress.Loopback, udpLoggerPort);
|
||||
})
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
@ -65,21 +77,6 @@ namespace FastGithub
|
||||
kestrel.ListenHttpProxy();
|
||||
}
|
||||
});
|
||||
webBuilder.UseSerilog((hosting, logger) =>
|
||||
{
|
||||
var template = "{Timestamp:O} [{Level:u3}]{NewLine}{SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}";
|
||||
logger
|
||||
.ReadFrom.Configuration(hosting.Configuration)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console(outputTemplate: template)
|
||||
.WriteTo.File(Path.Combine("logs", @"log.txt"), rollingInterval: RollingInterval.Day, outputTemplate: template);
|
||||
|
||||
var udpLoggerPort = hosting.Configuration.GetValue(nameof(AppOptions.UdpLoggerPort), 0);
|
||||
if (udpLoggerPort > 0)
|
||||
{
|
||||
logger.WriteTo.UDPSink(IPAddress.Loopback, udpLoggerPort);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user