Serilog
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Phares.Shared;
|
||||
using Serilog;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Reflection;
|
||||
@ -24,7 +23,6 @@ public partial class DragDropSetPropertyItem : Form
|
||||
short? PropertyItemType,
|
||||
string? Value);
|
||||
|
||||
private readonly ILogger _Logger;
|
||||
private readonly TextBox _PathTextBox;
|
||||
private readonly TextBox _JsonTextBox;
|
||||
private readonly TextBox _FirstTextBox;
|
||||
@ -37,12 +35,10 @@ public partial class DragDropSetPropertyItem : Form
|
||||
public DragDropSetPropertyItem()
|
||||
{
|
||||
InitializeComponent();
|
||||
ILogger logger;
|
||||
AppSettings appSettings;
|
||||
string workingDirectory;
|
||||
IsEnvironment isEnvironment;
|
||||
IConfigurationRoot configurationRoot;
|
||||
LoggerConfiguration loggerConfiguration = new();
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
|
||||
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
||||
@ -55,14 +51,9 @@ public partial class DragDropSetPropertyItem : Form
|
||||
throw new Exception("Working path name must have parentDirectory setTo!");
|
||||
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
|
||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
|
||||
Log.Logger = loggerConfiguration.CreateLogger();
|
||||
logger = Log.ForContext<DragDropSetPropertyItem>();
|
||||
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
logger.Information("Complete");
|
||||
_Logger = logger;
|
||||
_AppSettings = appSettings;
|
||||
_IsEnvironment = isEnvironment;
|
||||
_WorkingDirectory = workingDirectory;
|
||||
@ -107,11 +98,8 @@ public partial class DragDropSetPropertyItem : Form
|
||||
}
|
||||
}
|
||||
|
||||
private void SetMessage(string message)
|
||||
{
|
||||
_Logger.Information(message);
|
||||
private void SetMessage(string message) =>
|
||||
_JsonTextBox.Text = message;
|
||||
}
|
||||
|
||||
private List<Record> GetRecords(ASCIIEncoding asciiEncoding, int tagId, List<string> files)
|
||||
{
|
||||
|
Reference in New Issue
Block a user