diff --git a/AircraftCarrier/AircraftCarrier/AircraftCarrier.csproj b/AircraftCarrier/AircraftCarrier/AircraftCarrier.csproj index 15ef337..24d34c4 100644 --- a/AircraftCarrier/AircraftCarrier/AircraftCarrier.csproj +++ b/AircraftCarrier/AircraftCarrier/AircraftCarrier.csproj @@ -8,12 +8,26 @@ enable + + + + + + + Always + + + + + + + diff --git a/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs b/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs index d9f89c0..7585546 100644 --- a/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs +++ b/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace AircraftCarrier { - internal class EntityAircraftCarrier : EntityWarship + public class EntityAircraftCarrier : EntityWarship { /// /// Дополнительный цвет diff --git a/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.cs b/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.cs index b2a3453..9b0dcc5 100644 --- a/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.cs +++ b/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.cs @@ -145,8 +145,8 @@ namespace AircraftCarrier DrawingObjectWarship warship = new(drawningWarship); if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship >= 0) { + _logger.LogInformation($"Добавлен объект {warship}"); MessageBox.Show("Объект добавлен"); - _logger.LogInformation("Добавлен объект {@Airplane}", warship); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else @@ -180,8 +180,8 @@ namespace AircraftCarrier var deletedWarship = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos; if (deletedWarship != null) { + _logger.LogInformation($"Объект {deletedWarship} удалён"); MessageBox.Show("Объект удален"); - _logger.LogInformation("Из текущей карты удален объект {@ship}", deletedWarship); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else diff --git a/AircraftCarrier/AircraftCarrier/Program.cs b/AircraftCarrier/AircraftCarrier/Program.cs index 1e55526..93e06e7 100644 --- a/AircraftCarrier/AircraftCarrier/Program.cs +++ b/AircraftCarrier/AircraftCarrier/Program.cs @@ -1,9 +1,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using NLog.Extensions.Logging; using Serilog; -using System.ServiceProcess; namespace AircraftCarrier { @@ -31,9 +29,15 @@ namespace AircraftCarrier services.AddSingleton() .AddLogging(option => { + var configuration = new ConfigurationBuilder() + + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile(path: "jsconfig.json", optional: false, reloadOnChange: true) + .Build(); + var logger = new LoggerConfiguration() - .WriteTo.File("Log.txt") - .CreateLogger(); + .ReadFrom.Configuration(configuration) + .CreateLogger(); option.SetMinimumLevel(LogLevel.Information); option.AddSerilog(logger); diff --git a/AircraftCarrier/AircraftCarrier/jsconfig.json b/AircraftCarrier/AircraftCarrier/jsconfig.json new file mode 100644 index 0000000..34cb0da --- /dev/null +++ b/AircraftCarrier/AircraftCarrier/jsconfig.json @@ -0,0 +1,48 @@ +{ + "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}{Exception}" + } + } + ], + "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], + "Destructure": [ + { + "Name": "ByTransforming", + "Args": { + "returnType": "AircraftCarrier.EntityWarship", + "transformation": "r => new { BodyColor = r.BodyColor.Name, r.Speed, r.Weight }" + } + }, + { + "Name": "ByTransforming", + "Args": { + "returnType": "AircraftCarrier.EntityAircraftCarrier", + "transformation": "r => new { BodyColor = r.BodyColor.Name, DopColor = r.DopColor, r.BodyKit, r.Сabin, r.SuperEngine, r.Speed, r.Weight }" + } + }, + { + "Name": "ToMaximumDepth", + "Args": { "maximumDestructuringDepth": 4 } + }, + { + "Name": "ToMaximumStringLength", + "Args": { "maximumStringLength": 100 } + }, + { + "Name": "ToMaximumCollectionCount", + "Args": { "maximumCollectionCount": 10 } + } + ], + "Properties": { + "Application": "AircraftCarrier" + } + } +} \ No newline at end of file