Serilog
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Phares.Shared;
|
||||
using Serilog;
|
||||
using View_by_Distance.Delete.By.Relative.Models;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Shared.Models.Methods;
|
||||
@ -10,7 +10,7 @@ namespace View_by_Distance.Delete.By.Relative;
|
||||
public class DeleteByRelative
|
||||
{
|
||||
|
||||
public DeleteByRelative(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||
public DeleteByRelative(List<string> args, ILogger<Program> logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||
{
|
||||
if (isSilent)
|
||||
{ }
|
||||
@ -20,9 +20,8 @@ public class DeleteByRelative
|
||||
string checkFileName;
|
||||
string searchPattern = "*";
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
ILogger? log = Log.ForContext<DeleteByRelative>();
|
||||
Configuration configuration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||
log.Information(configuration.RootDirectory);
|
||||
logger?.LogInformation(configuration.RootDirectory);
|
||||
int length = configuration.RootDirectory.Length;
|
||||
if (string.IsNullOrEmpty(appSettings.CompareRootDirectory) || Path.GetFullPath(appSettings.CompareRootDirectory) == Path.GetFullPath(configuration.RootDirectory))
|
||||
throw new Exception("Check AppSettings file!");
|
||||
@ -60,14 +59,14 @@ public class DeleteByRelative
|
||||
File.WriteAllLines(deleteLog, deleteFiles);
|
||||
if (deleteFiles.Count > 0)
|
||||
{
|
||||
log.Information($"Ready to delete {deleteFiles.Count} file(s)? See <{deleteLog}>");
|
||||
logger?.LogInformation($"Ready to delete {deleteFiles.Count} file(s)? See <{deleteLog}>");
|
||||
for (int y = 0; y < int.MaxValue; y++)
|
||||
{
|
||||
log.Information("Press \"Y\" key to delete file(s) or close console to not delete files");
|
||||
logger?.LogInformation("Press \"Y\" key to delete file(s) or close console to not delete files");
|
||||
if (Console.ReadKey().Key == ConsoleKey.Y)
|
||||
break;
|
||||
}
|
||||
log.Information(". . .");
|
||||
logger?.LogInformation(". . .");
|
||||
foreach (string deleteFile in deleteFiles)
|
||||
{
|
||||
File.Delete(deleteFile);
|
||||
|
Reference in New Issue
Block a user