From a4a89b5f215da3b3b8c3806a48c5bb12a909e45e Mon Sep 17 00:00:00 2001 From: 1yuee Date: Wed, 30 Nov 2022 10:24:06 +0400 Subject: [PATCH] =?UTF-8?q?7=20=D0=BB=D0=B0=D0=B1=D1=83=20=D1=81=D0=B4?= =?UTF-8?q?=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AirBomber.csproj | 9 ++++++--- AirBomber/AirBomber/FormAirBomberConfig.cs | 4 +++- AirBomber/AirBomber/FormMapWithSetAirBomber.cs | 2 +- AirBomber/AirBomber/MapsCollection.cs | 3 +-- AirBomber/AirBomber/Program.cs | 13 +++++++++---- AirBomber/AirBomber/nlog.config | 13 ------------- AirBomber/AirBomber/serilog.json | 17 +++++++++++++++++ 7 files changed, 37 insertions(+), 24 deletions(-) delete mode 100644 AirBomber/AirBomber/nlog.config create mode 100644 AirBomber/AirBomber/serilog.json diff --git a/AirBomber/AirBomber/AirBomber.csproj b/AirBomber/AirBomber/AirBomber.csproj index d5ebab9..9f633c8 100644 --- a/AirBomber/AirBomber/AirBomber.csproj +++ b/AirBomber/AirBomber/AirBomber.csproj @@ -17,22 +17,25 @@ - + - + Always + + + - + diff --git a/AirBomber/AirBomber/FormAirBomberConfig.cs b/AirBomber/AirBomber/FormAirBomberConfig.cs index 51e0803..af7293e 100644 --- a/AirBomber/AirBomber/FormAirBomberConfig.cs +++ b/AirBomber/AirBomber/FormAirBomberConfig.cs @@ -12,9 +12,10 @@ namespace AirBomber { public partial class FormAirBomberConfig : Form { - DrawningBomber _airBomber = null; + static DrawningBomber _airBomber = null; private Action EventAddAirBomber; + public FormAirBomberConfig() { InitializeComponent(); @@ -51,6 +52,7 @@ namespace AirBomber } } + private void LabelObject_MouseDown(object sender, MouseEventArgs e) { (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); diff --git a/AirBomber/AirBomber/FormMapWithSetAirBomber.cs b/AirBomber/AirBomber/FormMapWithSetAirBomber.cs index 61ec157..d014f00 100644 --- a/AirBomber/AirBomber/FormMapWithSetAirBomber.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirBomber.cs @@ -45,7 +45,7 @@ namespace AirBomber for (int i = 0; i < _mapsCollection.Keys.Count; i++) { listBoxMaps.Items.Add(_mapsCollection.Keys[i]); - } + } if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count)) { diff --git a/AirBomber/AirBomber/MapsCollection.cs b/AirBomber/AirBomber/MapsCollection.cs index 7110879..d092ec0 100644 --- a/AirBomber/AirBomber/MapsCollection.cs +++ b/AirBomber/AirBomber/MapsCollection.cs @@ -56,8 +56,7 @@ namespace AirBomber sw.Write($"MapsCollection{Environment.NewLine}"); foreach (var storage in _mapStorages) { - sw.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, - separatorData)}{Environment.NewLine}"); + sw.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}"); } } } diff --git a/AirBomber/AirBomber/Program.cs b/AirBomber/AirBomber/Program.cs index 6c5fd32..d44e7a1 100644 --- a/AirBomber/AirBomber/Program.cs +++ b/AirBomber/AirBomber/Program.cs @@ -1,6 +1,6 @@ +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using NLog.Extensions.Logging; using Serilog; using System.ServiceProcess; @@ -27,13 +27,18 @@ namespace AirBomber private static void ConfigureServices(ServiceCollection services) { - var serilogLogger = new LoggerConfiguration().WriteTo.File("seriallog.txt").CreateLogger(); - services.AddSingleton() .AddLogging(option => { + var config = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("serilog.json") + .Build(); + + Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(config).CreateLogger(); + option.SetMinimumLevel(LogLevel.Information); - option.AddSerilog(logger: serilogLogger, dispose: true); + option.AddSerilog(); }); } } diff --git a/AirBomber/AirBomber/nlog.config b/AirBomber/AirBomber/nlog.config deleted file mode 100644 index 16c12e3..0000000 --- a/AirBomber/AirBomber/nlog.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/AirBomber/AirBomber/serilog.json b/AirBomber/AirBomber/serilog.json new file mode 100644 index 0000000..7727326 --- /dev/null +++ b/AirBomber/AirBomber/serilog.json @@ -0,0 +1,17 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Information", + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "Logs/log_.log", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:HH:mm:ss.fff} [{Level:u4}] {Message:lj} {NewLine}" + } + } + ], + "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ] + } +}