diff --git a/BlurHash/BlurHash.csproj b/BlurHash/BlurHash.csproj
index 59309ef..c46e5a4 100644
--- a/BlurHash/BlurHash.csproj
+++ b/BlurHash/BlurHash.csproj
@@ -33,7 +33,6 @@
-
diff --git a/Compare/Compare.cs b/Compare/Compare.cs
index 9fe82cd..43ad3e9 100644
--- a/Compare/Compare.cs
+++ b/Compare/Compare.cs
@@ -12,7 +12,6 @@ namespace View_by_Distance.Compare;
public class Compare
{
- private readonly Serilog.ILogger? _Log;
private readonly AppSettings _AppSettings;
private readonly IsEnvironment _IsEnvironment;
private readonly Models.Configuration _Configuration;
@@ -38,7 +37,6 @@ public class Compare
_RenameCFindReplace = new();
_SpellingFindReplace = new();
_IsEnvironment = isEnvironment;
- _Log = Serilog.Log.ForContext();
_FileKeyValuePairs = new List>();
_FilePropertiesKeyValuePairs = new Dictionary>>();
string searchPattern = "*";
@@ -107,7 +105,7 @@ public class Compare
(_, groupCollection) = Property.Models.Stateless.Container.GetGroupCollection(propertyConfiguration.RootDirectory, searchPattern, topDirectories);
if (appSettings.MaxDegreeOfParallelism < 2)
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.Container.GetGroupCollection));
- _Log.Information($"{nameof(Property.Models.Stateless.Container.GetGroupCollection)} has finished");
+ _Logger?.LogInformation($"{nameof(Property.Models.Stateless.Container.GetGroupCollection)} has finished");
_Configuration = configuration;
List missingVerifyToSeasonCollection = GetMissingVerifyToSeasonCollection(topDirectories, groupCollection);
if (missingVerifyToSeasonCollection.Any())
@@ -120,7 +118,7 @@ public class Compare
if (appSettings.MaxDegreeOfParallelism < 2)
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.Container.GetGroupCollection));
}
- _Log.Information($"{nameof(PossiblyRename)} has finished");
+ _Logger?.LogInformation($"{nameof(PossiblyRename)} has finished");
if (PossiblyRenameB(topDirectories, groupCollection))
{
topDirectories.Clear();
@@ -129,7 +127,7 @@ public class Compare
if (appSettings.MaxDegreeOfParallelism < 2)
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.Container.GetGroupCollection));
}
- _Log.Information($"{nameof(PossiblyRenameB)} has finished");
+ _Logger?.LogInformation($"{nameof(PossiblyRenameB)} has finished");
if (PossiblyRenameC(topDirectories, groupCollection))
{
topDirectories.Clear();
@@ -138,7 +136,7 @@ public class Compare
if (appSettings.MaxDegreeOfParallelism < 2)
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.Container.GetGroupCollection));
}
- _Log.Information($"{nameof(PossiblyRenameC)} has finished");
+ _Logger?.LogInformation($"{nameof(PossiblyRenameC)} has finished");
if (PossiblyCorrect(topDirectories, groupCollection))
{
topDirectories.Clear();
@@ -147,11 +145,11 @@ public class Compare
if (appSettings.MaxDegreeOfParallelism < 2)
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.Container.GetGroupCollection));
}
- _Log.Information($"{nameof(PossiblyCorrect)} has finished");
+ _Logger?.LogInformation($"{nameof(PossiblyCorrect)} has finished");
string[] dbFiles = Directory.GetFiles(propertyConfiguration.RootDirectory, "*.db", SearchOption.AllDirectories);
foreach (string dbFile in dbFiles)
File.Delete(dbFile);
- _Log.Information("deleting *.db files has finished");
+ _Logger?.LogInformation("deleting *.db files has finished");
if (dbFiles.Any())
{
topDirectories.Clear();
@@ -175,14 +173,14 @@ public class Compare
}
if (!isSilent)
{
- _Log.Information("First pass completed");
+ _Logger?.LogInformation("First pass completed");
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information("Press \"Y\" key to continue or close console if compare not needed");
+ _Logger?.LogInformation("Press \"Y\" key to continue or close console if compare not needed");
if (Console.ReadKey().Key == ConsoleKey.Y)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
}
if (!isSilent)
{
@@ -192,51 +190,51 @@ public class Compare
ConsoleKey? consoleKey = null;
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information($"Execute {nameof(ChangeExtensionFromDeleteToJson)} \"Y(es)\" or \"N(o)\"?");
+ _Logger?.LogInformation($"Execute {nameof(ChangeExtensionFromDeleteToJson)} \"Y(es)\" or \"N(o)\"?");
consoleKey = Console.ReadKey().Key;
if (consoleKey is ConsoleKey.Y or ConsoleKey.N)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
if (consoleKey == ConsoleKey.Y)
ChangeExtensionFromDeleteToJson(aPropertySingletonDirectory);
}
}
if (!isSilent)
{
- _Log.Information("Second pass completed");
+ _Logger?.LogInformation("Second pass completed");
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information("Press \"Y\" key to continue or close console if compare not needed");
+ _Logger?.LogInformation("Press \"Y\" key to continue or close console if compare not needed");
if (Console.ReadKey().Key == ConsoleKey.Y)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
}
string aPropertyContentCollectionDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(propertyConfiguration, nameof(A_Property), "[()]");
ThirdPassToMove(propertyConfiguration, mapLogic, propertyLogic, containers, aPropertyContentCollectionDirectory);
if (!isSilent)
{
- _Log.Information("Third pass completed");
+ _Logger?.LogInformation("Third pass completed");
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information("Press \"Y\" key to continue or close console if compare not needed");
+ _Logger?.LogInformation("Press \"Y\" key to continue or close console if compare not needed");
if (Console.ReadKey().Key == ConsoleKey.Y)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
}
FourthPassCreateWindowsShortcuts(propertyConfiguration, mapLogic, propertyLogic, containers, saveToCollection: false, keepAll: false);
if (!isSilent)
{
- _Log.Information("Fourth pass completed");
+ _Logger?.LogInformation("Fourth pass completed");
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information("Press \"Y\" key to continue or close console if compare not needed");
+ _Logger?.LogInformation("Press \"Y\" key to continue or close console if compare not needed");
if (Console.ReadKey().Key == ConsoleKey.Y)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
}
SaveDiffFilesOrSaveLogAndMoveFiles(propertyConfiguration);
string currentYearDirectory = Path.Combine(propertyConfiguration.RootDirectory, $". {DateTime.Now:yyyy}");
@@ -387,8 +385,6 @@ public class Compare
private long LogDelta(long ticks, string? methodName)
{
long result;
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
double delta = new TimeSpan(DateTime.Now.Ticks - ticks).TotalMilliseconds;
_Log.Debug($"{methodName} took {Math.Floor(delta)} millisecond(s)");
result = DateTime.Now.Ticks;
@@ -438,21 +434,19 @@ public class Compare
private void SaveDiffFilesOrSaveLogAndMoveFiles(Property.Models.Configuration configuration)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
if (_Configuration?.PropertyConfiguration is null)
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(A_Property), "{}");
- _Log.Information(aPropertySingletonDirectory);
- _Log.Information("to");
- _Log.Information(_Configuration.DiffPropertyDirectory);
+ _Logger?.LogInformation(aPropertySingletonDirectory);
+ _Logger?.LogInformation("to");
+ _Logger?.LogInformation(_Configuration.DiffPropertyDirectory);
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information("Press \"Y\" key to continue or close console if compare not needed");
+ _Logger?.LogInformation("Press \"Y\" key to continue or close console if compare not needed");
if (Console.ReadKey().Key == ConsoleKey.Y)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
int loadLessThan = 7;
string diffRootDirectory;
ConsoleKey? consoleKey = null;
@@ -486,27 +480,27 @@ public class Compare
}
for (int x = 0; x < int.MaxValue; x++)
{
- _Log.Information($"Press \"D\" key to {nameof(PropertyCompare.Models.PropertyCompareLogic.SaveDiffFiles)}");
- _Log.Information($"Press \"M\" key to {nameof(PropertyCompare.Models.PropertyCompareLogic.SaveLogAndMoveFiles)}");
- _Log.Information("Press \"End\" key when ready to skip");
+ _Logger?.LogInformation($"Press \"D\" key to {nameof(PropertyCompare.Models.PropertyCompareLogic.SaveDiffFiles)}");
+ _Logger?.LogInformation($"Press \"M\" key to {nameof(PropertyCompare.Models.PropertyCompareLogic.SaveLogAndMoveFiles)}");
+ _Logger?.LogInformation("Press \"End\" key when ready to skip");
consoleKey = Console.ReadKey().Key;
if (consoleKey is ConsoleKey.D or ConsoleKey.M or ConsoleKey.End)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
if (consoleKey.HasValue && consoleKey.Value == ConsoleKey.D)
propertyCompareLogic.SaveDiffFiles(aPropertyCollectionDirectory, loadLessThan, propertyCompareCollection, diffPropertyCompareCollection);
else if (consoleKey.HasValue && consoleKey.Value == ConsoleKey.M)
{
for (int x = 0; x < int.MaxValue; x++)
{
- _Log.Information($"Press \"0 - {loadLessThan}\" key when ready to continue");
- _Log.Information("Press \"End\" key when ready to skip");
+ _Logger?.LogInformation($"Press \"0 - {loadLessThan}\" key when ready to continue");
+ _Logger?.LogInformation("Press \"End\" key when ready to skip");
consoleKey = Console.ReadKey().Key;
if (consoleKey.Value is ConsoleKey.D0 or ConsoleKey.D1 or ConsoleKey.D2 or ConsoleKey.D3 or ConsoleKey.D4 or ConsoleKey.D5 or ConsoleKey.D6 or ConsoleKey.End)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
int i = int.Parse(consoleKey.Value.ToString()[1..]);
propertyCompareLogic.SaveLogAndMoveFiles(aPropertyCollectionDirectory, loadLessThan, propertyCompareCollection, diffPropertyCompareCollection, i);
}
@@ -717,8 +711,6 @@ public class Compare
private void CreateWindowsShortcuts((long Ticks, string FilteredSourceDirectoryFile, string PropertyDirectory, int PropertyId)[] collection, bool keepAll)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
int z = 0;
string fileName;
WindowsShortcut windowsShortcut;
@@ -755,8 +747,6 @@ public class Compare
private void ThirdPassToMove(Property.Models.Configuration configuration, Map.Models.MapLogic mapLogic, A_Property propertyLogic, Shared.Models.Container[] containers, string aPropertyContentCollectionDirectory)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
if (_Configuration?.PropertyConfiguration is null)
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
int stay = 0;
@@ -809,16 +799,16 @@ public class Compare
if (!Directory.Exists(distinctDirectory))
_ = Directory.CreateDirectory(distinctDirectory);
}
- _Log.Information($"{stay} file(s) are staying and {fileMoveCollection.Count} file(s) will be moved");
+ _Logger?.LogInformation($"{stay} file(s) are staying and {fileMoveCollection.Count} file(s) will be moved");
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information($"Press \"M\" key to {nameof(File.Move)}");
- _Log.Information("Press \"End\" key when ready to skip or close console if compare not needed");
+ _Logger?.LogInformation($"Press \"M\" key to {nameof(File.Move)}");
+ _Logger?.LogInformation("Press \"End\" key when ready to skip or close console if compare not needed");
consoleKey = Console.ReadKey().Key;
if (consoleKey is ConsoleKey.M or ConsoleKey.End)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
if (consoleKey.HasValue && consoleKey.Value == ConsoleKey.M)
{
foreach (string fileMove in fileMoveCollection)
@@ -833,8 +823,6 @@ public class Compare
private void FourthPassCreateWindowsShortcuts(Property.Models.Configuration configuration, Map.Models.MapLogic mapLogic, A_Property propertyLogic, Shared.Models.Container[] containers, bool saveToCollection, bool keepAll)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
int stay = 0;
ConsoleKey? consoleKey = null;
long ticks = DateTime.Now.Ticks;
@@ -863,16 +851,16 @@ public class Compare
}
}
collection = propertyLogic.GetPropertyIds(directoryInfoCollection, saveToCollection);
- _Log.Information($"{stay} file(s) are staying and {fileMoveCollection.Count} file(s) will be moved");
+ _Logger?.LogInformation($"{stay} file(s) are staying and {fileMoveCollection.Count} file(s) will be moved");
for (int x = 0; x < int.MaxValue; x++)
{
- _Log.Information($"Press \"S\" key to {nameof(CreateWindowsShortcuts)}");
- _Log.Information("Press \"End\" key when ready to skip or close console if compare not needed");
+ _Logger?.LogInformation($"Press \"S\" key to {nameof(CreateWindowsShortcuts)}");
+ _Logger?.LogInformation("Press \"End\" key when ready to skip or close console if compare not needed");
consoleKey = Console.ReadKey().Key;
if (consoleKey is ConsoleKey.M or ConsoleKey.End)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
if (consoleKey.HasValue && consoleKey.Value == ConsoleKey.S)
CreateWindowsShortcuts(collection, keepAll);
}
diff --git a/Compare/Compare.csproj b/Compare/Compare.csproj
index a1b4478..d089531 100644
--- a/Compare/Compare.csproj
+++ b/Compare/Compare.csproj
@@ -37,10 +37,6 @@
-
-
-
-
diff --git a/Compare/Models/Stateless/SerilogExtensionMethods.cs b/Compare/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 667f356..0000000
--- a/Compare/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Compare.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Compare/Program.cs b/Compare/Program.cs
index 5456c4a..92405ea 100644
--- a/Compare/Program.cs
+++ b/Compare/Program.cs
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Configuration;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Compare.Models;
@@ -11,9 +10,8 @@ namespace View_by_Distance.Compare;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -29,9 +27,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -40,31 +35,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- Compare _ = new(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ Compare _ = new(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Copy-Distinct/Copy-Distinct.csproj b/Copy-Distinct/Copy-Distinct.csproj
index ad0b7ce..95ff485 100644
--- a/Copy-Distinct/Copy-Distinct.csproj
+++ b/Copy-Distinct/Copy-Distinct.csproj
@@ -39,10 +39,6 @@
-
-
-
-
diff --git a/Copy-Distinct/CopyDistinct.cs b/Copy-Distinct/CopyDistinct.cs
index b548cc3..95b5f3d 100644
--- a/Copy-Distinct/CopyDistinct.cs
+++ b/Copy-Distinct/CopyDistinct.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using ShellProgressBar;
using View_by_Distance.Copy.Distinct.Models;
using View_by_Distance.Shared.Models;
@@ -19,7 +19,7 @@ public class CopyDistinct
private readonly IReadOnlyDictionary _FileGroups;
private readonly Property.Models.Configuration _PropertyConfiguration;
- public CopyDistinct(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public CopyDistinct(List args, ILogger logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
{
if (isSilent)
{ }
@@ -29,15 +29,14 @@ public class CopyDistinct
_IsEnvironment = isEnvironment;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
- ILogger? log = Log.ForContext();
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
_PropertyConfiguration = propertyConfiguration;
_Configuration = configuration;
- log.Information(propertyConfiguration.RootDirectory);
+ logger?.LogInformation(propertyConfiguration.RootDirectory);
(bool move, List filesCollection, bool anyLenFiles, bool moveBack) = Verify();
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, appSettings.CopyTo, new string[] { appSettings.ResultDirectoryKey });
- List lines = CopyDistinctFilesInDirectories(log, move, filesCollection, anyLenFiles, moveBack);
+ List lines = CopyDistinctFilesInDirectories(logger, move, filesCollection, anyLenFiles, moveBack);
if (lines.Any())
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(propertyConfiguration.RootDirectory);
@@ -154,7 +153,7 @@ public class CopyDistinct
return (distinctDirectories.ToArray(), results);
}
- private List CopyDistinctFilesInDirectories(ILogger log, bool move, List filesCollection, bool anyLenFiles, bool moveBack)
+ private List CopyDistinctFilesInDirectories(ILogger? logger, bool move, List filesCollection, bool anyLenFiles, bool moveBack)
{
List results = new();
ProgressBar progressBar;
@@ -184,30 +183,30 @@ public class CopyDistinct
_ = Directory.CreateDirectory(distinctDirectory);
}
if (move)
- log.Information($"Ready to Move {toDoCollection.Count} file(s)?");
+ logger?.LogInformation($"Ready to Move {toDoCollection.Count} file(s)?");
else if (!moveBack)
- log.Information($"Ready to Copy {toDoCollection.Count} file(s)?");
+ logger?.LogInformation($"Ready to Copy {toDoCollection.Count} file(s)?");
else
- log.Information($"Ready to Move back {toDoCollection.Count} file(s)?");
+ logger?.LogInformation($"Ready to Move back {toDoCollection.Count} file(s)?");
for (int y = 0; y < int.MaxValue; y++)
{
if (move)
- log.Information("Press \"Y\" key to move file(s), \"N\" key to log file(s) or close console to not move files");
+ logger?.LogInformation("Press \"Y\" key to move file(s), \"N\" key to log file(s) or close console to not move files");
else if (!moveBack)
- log.Information("Press \"Y\" key to copy file(s), \"N\" key to log file(s) or close console to not copy files");
+ logger?.LogInformation("Press \"Y\" key to copy file(s), \"N\" key to log file(s) or close console to not copy files");
else
- log.Information("Press \"Y\" key to move back file(s), \"N\" key to log file(s) or close console to not move back files");
+ logger?.LogInformation("Press \"Y\" key to move back file(s), \"N\" key to log file(s) or close console to not move back files");
consoleKey = System.Console.ReadKey().Key;
if (consoleKey is ConsoleKey.Y or ConsoleKey.N)
break;
}
- log.Information(". . .");
+ logger?.LogInformation(". . .");
if (consoleKey is null || consoleKey.Value != ConsoleKey.Y)
{
if (move || moveBack)
- log.Information("Nothing moved!");
+ logger?.LogInformation("Nothing moved!");
else
- log.Information("Nothing copied!");
+ logger?.LogInformation("Nothing copied!");
}
else
{
@@ -215,9 +214,9 @@ public class CopyDistinct
results.AddRange(Shared.Models.Stateless.Methods.IDirectory.CopyOrMove(toDoCollection, move, moveBack, () => progressBar.Tick()));
progressBar.Dispose();
if (move || moveBack)
- log.Information("Done moving");
+ logger?.LogInformation("Done moving");
else
- log.Information("Done copying");
+ logger?.LogInformation("Done copying");
}
return results;
}
diff --git a/Copy-Distinct/Models/Stateless/SerilogExtensionMethods.cs b/Copy-Distinct/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index be42b73..0000000
--- a/Copy-Distinct/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Copy.Distinct.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Copy-Distinct/Program.cs b/Copy-Distinct/Program.cs
index 45fbadc..dd76229 100644
--- a/Copy-Distinct/Program.cs
+++ b/Copy-Distinct/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Copy.Distinct.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Copy.Distinct;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -30,9 +31,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -41,31 +39,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- _ = new CopyDistinct(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ _ = new CopyDistinct(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Date-Group/Date-Group.csproj b/Date-Group/Date-Group.csproj
index 1c5a4dc..1ee6194 100644
--- a/Date-Group/Date-Group.csproj
+++ b/Date-Group/Date-Group.csproj
@@ -39,10 +39,6 @@
-
-
-
-
diff --git a/Date-Group/DateGroup.cs b/Date-Group/DateGroup.cs
index 7c8d3b3..35bd3b0 100644
--- a/Date-Group/DateGroup.cs
+++ b/Date-Group/DateGroup.cs
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
using System.Globalization;
using System.Text;
@@ -13,15 +14,15 @@ namespace View_by_Distance.Date.Group;
public class DateGroup
{
- private readonly Serilog.ILogger? _Log;
private readonly AppSettings _AppSettings;
private readonly List _Exceptions;
+ private readonly ILogger? _Logger;
private readonly IsEnvironment _IsEnvironment;
private readonly Models.Configuration _Configuration;
private readonly List> _FileKeyValuePairs;
private readonly Dictionary>> _FilePropertiesKeyValuePairs;
- public DateGroup(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public DateGroup(List args, ILogger? logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
{
if (isSilent)
{ }
@@ -29,15 +30,15 @@ public class DateGroup
{ }
if (console is null)
{ }
+ _Logger = logger;
_AppSettings = appSettings;
_IsEnvironment = isEnvironment;
_Exceptions = new List();
- _Log = Serilog.Log.ForContext();
_FileKeyValuePairs = new List>();
_FilePropertiesKeyValuePairs = new Dictionary>>();
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
Models.Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
- _Log.Information(propertyConfiguration.RootDirectory);
+ _Logger?.LogInformation(propertyConfiguration.RootDirectory);
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: true);
Verify(configuration);
bool reverse = false;
@@ -49,12 +50,8 @@ public class DateGroup
string[] dbFiles = Directory.GetFiles(propertyConfiguration.RootDirectory, "*.db", SearchOption.AllDirectories);
foreach (string dbFile in dbFiles)
File.Delete(dbFile);
- if (true || appSettings.MaxDegreeOfParallelism < 2)
- ticks = LogDelta(ticks, nameof(File.Delete));
for (int i = 1; i < 10; i++)
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(propertyConfiguration.RootDirectory);
- if (true || appSettings.MaxDegreeOfParallelism < 2)
- ticks = LogDelta(ticks, nameof(Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories));
string destinationRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(propertyConfiguration, "Z) Moved");
string aResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property));
string aPropertySingletonDirectory = Path.Combine(aResultsFullGroupDirectory, "{}");
@@ -67,8 +64,6 @@ public class DateGroup
if (propertyConfiguration.PopulatePropertyId && (configuration.ByCreateDateShortcut || configuration.ByHash) && Shared.Models.Stateless.Methods.IProperty.Any(containers))
{
propertyLogic.SavePropertyParallelWork(ticks, metadata, t, containers);
- if (appSettings.MaxDegreeOfParallelism < 2)
- ticks = LogDelta(ticks, nameof(A_Property.SavePropertyParallelWork));
if (propertyLogic.ExceptionsDirectories.Any())
throw new Exception();
}
@@ -133,17 +128,6 @@ public class DateGroup
return result;
}
- private long LogDelta(long ticks, string? methodName)
- {
- long result;
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
- double delta = new TimeSpan(DateTime.Now.Ticks - ticks).TotalMilliseconds;
- _Log.Debug($"{methodName} took {Math.Floor(delta)} millisecond(s)");
- result = DateTime.Now.Ticks;
- return result;
- }
-
private List<(Item Item, long LastWriteTimeTicks, long MinimumDateTimeTicks, string[] Destination)> GetMoveFileCollection(string destinationDirectory, string topDirectory, Item[] filteredItems)
{
List<(Item Item, long LastWriteTimeTicks, long MinimumDateTimeTicks, string[] Destination)> results = new();
@@ -376,8 +360,6 @@ public class DateGroup
private void MoveFiles(Property.Models.Configuration configuration, string destinationRoot, Container[] containers)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
string checkDirectory;
bool hasDuplicate;
string fullFileName;
@@ -410,14 +392,14 @@ public class DateGroup
_ = Directory.CreateDirectory(checkDirectory);
}
}
- _Log.Information($"Ready to move {fileMoveCollectionAll.Length} file(s)?");
+ _Logger?.LogInformation($"Ready to move {fileMoveCollectionAll.Length} file(s)?");
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information("Press \"Y\" key to move file(s) or close console to not move files");
+ _Logger?.LogInformation("Press \"Y\" key to move file(s) or close console to not move files");
if (System.Console.ReadKey().Key == ConsoleKey.Y)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
int moved = 0;
foreach ((Item item, long lastWriteTimeTicks, long minimumDateTimeTicks, string[] destination) in fileMoveCollectionAll)
{
@@ -454,14 +436,14 @@ public class DateGroup
}
}
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(destinationRoot);
- _Log.Information($"{moved} file(s) moved");
+ _Logger?.LogInformation($"{moved} file(s) moved");
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information("Press \"Y\" key to move file(s) back or close console to leave them moved");
+ _Logger?.LogInformation("Press \"Y\" key to move file(s) back or close console to leave them moved");
if (System.Console.ReadKey().Key == ConsoleKey.Y)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
foreach ((Item item, long lastWriteTimeTicks, long minimumDateTimeTicks, string[] destination) in fileMoveCollectionAll)
{
fullFileName = Path.Combine(destination);
@@ -472,7 +454,7 @@ public class DateGroup
File.Move(fullFileName, item.ImageFileHolder.FullName);
moved += 1;
}
- _Log.Information($"Done moving back {moved} file(s)");
+ _Logger?.LogInformation($"Done moving back {moved} file(s)");
for (int i = 1; i < 10; i++)
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(configuration.RootDirectory);
}
diff --git a/Date-Group/Models/Stateless/SerilogExtensionMethods.cs b/Date-Group/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index f36a943..0000000
--- a/Date-Group/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Date.Group.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Date-Group/Program.cs b/Date-Group/Program.cs
index a776c82..27edf19 100644
--- a/Date-Group/Program.cs
+++ b/Date-Group/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Date.Group.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Date.Group;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -30,9 +31,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -79,31 +77,28 @@ public class Program
throw new Exception("Chelsea");
#nullable restore
Shared.Models.Console console = new();
- DateGroup _ = new(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ DateGroup _ = new(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Delete-By-Distinct/Delete-By-Distinct.csproj b/Delete-By-Distinct/Delete-By-Distinct.csproj
index 5cf586a..46d880a 100644
--- a/Delete-By-Distinct/Delete-By-Distinct.csproj
+++ b/Delete-By-Distinct/Delete-By-Distinct.csproj
@@ -38,10 +38,6 @@
-
-
-
-
diff --git a/Delete-By-Distinct/DeleteByDistinct.cs b/Delete-By-Distinct/DeleteByDistinct.cs
index 8919d95..5781637 100644
--- a/Delete-By-Distinct/DeleteByDistinct.cs
+++ b/Delete-By-Distinct/DeleteByDistinct.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using ShellProgressBar;
using View_by_Distance.Delete.By.Distinct.Models;
using View_by_Distance.Property.Models;
@@ -11,28 +11,27 @@ namespace View_by_Distance.Delete.By.Distinct;
public class DeleteByDistinct
{
- public DeleteByDistinct(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public DeleteByDistinct(List args, ILogger logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
{
if (isSilent)
{ }
if (console is null)
{ }
long ticks = DateTime.Now.Ticks;
- ILogger? log = Log.ForContext();
Dictionary> keyValuePairs = new();
Configuration configuration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
- log.Information(configuration.RootDirectory);
+ logger?.LogInformation(configuration.RootDirectory);
if (!appSettings.TicksForLong && !appSettings.SizeForLong)
throw new Exception("Check appSettings file!");
bool compareIsPopulatedAndNotTheSame = !string.IsNullOrEmpty(appSettings.CompareRootDirectory) && appSettings.CompareRootDirectory != configuration.RootDirectory;
- Work(appSettings, ticks, log, configuration.RootDirectory, nameof(configuration.RootDirectory), options, keyValuePairs, logOnly: compareIsPopulatedAndNotTheSame);
+ Work(appSettings, ticks, logger, configuration.RootDirectory, nameof(configuration.RootDirectory), options, keyValuePairs, logOnly: compareIsPopulatedAndNotTheSame);
if (compareIsPopulatedAndNotTheSame)
- Work(appSettings, ticks, log, appSettings.CompareRootDirectory, nameof(appSettings.CompareRootDirectory), options, keyValuePairs, logOnly: false);
+ Work(appSettings, ticks, logger, appSettings.CompareRootDirectory, nameof(appSettings.CompareRootDirectory), options, keyValuePairs, logOnly: false);
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(appSettings.CompareRootDirectory);
}
- private static void Work(AppSettings appSettings, long ticks, ILogger log, string directory, string variable, ProgressBarOptions options, Dictionary> keyValuePairs, bool logOnly)
+ private static void Work(AppSettings appSettings, long ticks, ILogger? logger, string directory, string variable, ProgressBarOptions options, Dictionary> keyValuePairs, bool logOnly)
{
string check;
string logFile;
@@ -48,7 +47,7 @@ public class DeleteByDistinct
List deletedDirectories = new();
Dictionary> longToCollectionB = new();
List<(string Source, string Destination)> renameFiles = new();
- log.Information($"Gathering {appSettings.SearchPattern} files from <{directory}>");
+ logger?.LogInformation($"Gathering {appSettings.SearchPattern} files from <{directory}>");
(string directory, string[] files)[] leftCollection = Shared.Models.Stateless.Methods.IFileHolder.GetFiles(directory, appSettings.SearchPattern).ToArray();
totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
message = $") Looking for duplicates from <{directory}> - {totalSeconds} total second(s)";
@@ -105,21 +104,21 @@ public class DeleteByDistinct
}
}
progressBar.Dispose();
- log.Information(". . .");
+ logger?.LogInformation(". . .");
logFile = $"{ticks}-{variable}-Files-A.lsv";
if (!logOnly)
File.WriteAllLines(Path.Combine(directory, logFile), deletedFiles);
if (deletedFiles.Any() && !logOnly)
{
- log.Information($"Ready to delete {deletedFiles.Count} from {variable} {appSettings.SearchPattern} file(s)? See <{logFile}>");
+ logger?.LogInformation($"Ready to delete {deletedFiles.Count} from {variable} {appSettings.SearchPattern} file(s)? See <{logFile}>");
for (int y = 0; y < int.MaxValue; y++)
{
- log.Information("Press \"Y\" key to delete file(s), \"N\" key to log file(s) or close console to not delete files");
+ logger?.LogInformation("Press \"Y\" key to delete file(s), \"N\" key to log file(s) or close console to not delete files");
consoleKey = Console.ReadKey().Key;
if (consoleKey is ConsoleKey.Y or ConsoleKey.N)
break;
}
- log.Information(". . .");
+ logger?.LogInformation(". . .");
if (consoleKey is not null && consoleKey.Value == ConsoleKey.Y)
{
foreach (string file in deletedFiles)
@@ -150,7 +149,7 @@ public class DeleteByDistinct
deletedDirectories.AddRange(collection);
}
progressBar.Dispose();
- log.Information(". . .");
+ logger?.LogInformation(". . .");
logFile = $"{ticks + 1}-{variable}-Directories.lsv";
File.WriteAllLines(Path.Combine(directory, logFile), deletedDirectories.Distinct());
}
@@ -161,15 +160,15 @@ public class DeleteByDistinct
File.WriteAllLines(Path.Combine(directory, logFile), renameFiles.Select(l => l.Source));
logFile = $"{ticks}-{variable}-Files-C.lsv";
File.WriteAllLines(Path.Combine(directory, logFile), renameFiles.Select(l => l.Destination));
- log.Information($"Ready to rename to match {renameFiles.Count} from {variable} {appSettings.SearchPattern} file(s)? See <{logFile}>");
+ logger?.LogInformation($"Ready to rename to match {renameFiles.Count} from {variable} {appSettings.SearchPattern} file(s)? See <{logFile}>");
for (int y = 0; y < int.MaxValue; y++)
{
- log.Information("Press \"Y\" key to rename to match file(s), \"N\" key to log file(s) or close console to not rename to match files");
+ logger?.LogInformation("Press \"Y\" key to rename to match file(s), \"N\" key to log file(s) or close console to not rename to match files");
consoleKey = Console.ReadKey().Key;
if (consoleKey is ConsoleKey.Y or ConsoleKey.N)
break;
}
- log.Information(". . .");
+ logger?.LogInformation(". . .");
if (consoleKey is not null && consoleKey.Value == ConsoleKey.Y)
{
foreach ((string source, string destination) in renameFiles)
diff --git a/Delete-By-Distinct/Models/Stateless/SerilogExtensionMethods.cs b/Delete-By-Distinct/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 38c52da..0000000
--- a/Delete-By-Distinct/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Delete.By.Distinct.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Delete-By-Distinct/Program.cs b/Delete-By-Distinct/Program.cs
index 03a299a..2606154 100644
--- a/Delete-By-Distinct/Program.cs
+++ b/Delete-By-Distinct/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Delete.By.Distinct.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Delete.By.Distinct;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -30,9 +31,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -41,31 +39,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- _ = new DeleteByDistinct(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ _ = new DeleteByDistinct(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Delete-By-Relative/Delete-By-Relative.csproj b/Delete-By-Relative/Delete-By-Relative.csproj
index 73a8a20..446129d 100644
--- a/Delete-By-Relative/Delete-By-Relative.csproj
+++ b/Delete-By-Relative/Delete-By-Relative.csproj
@@ -38,10 +38,6 @@
-
-
-
-
diff --git a/Delete-By-Relative/DeleteByRelative.cs b/Delete-By-Relative/DeleteByRelative.cs
index 91d4baf..cc013ba 100644
--- a/Delete-By-Relative/DeleteByRelative.cs
+++ b/Delete-By-Relative/DeleteByRelative.cs
@@ -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 args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public DeleteByRelative(List args, ILogger 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();
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);
diff --git a/Delete-By-Relative/Models/Stateless/SerilogExtensionMethods.cs b/Delete-By-Relative/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 7e4d443..0000000
--- a/Delete-By-Relative/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Delete.By.Relative.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Delete-By-Relative/Program.cs b/Delete-By-Relative/Program.cs
index 72e172e..de85a29 100644
--- a/Delete-By-Relative/Program.cs
+++ b/Delete-By-Relative/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Delete.By.Relative.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Delete.By.Relative;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -30,9 +31,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -41,31 +39,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- _ = new DeleteByRelative(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ _ = new DeleteByRelative(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Distance/Distance.csproj b/Distance/Distance.csproj
index 1bef709..6e467c3 100644
--- a/Distance/Distance.csproj
+++ b/Distance/Distance.csproj
@@ -35,7 +35,6 @@
-
diff --git a/Distance/Models/Stateless/SerilogExtensionMethods.cs b/Distance/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 80d18c0..0000000
--- a/Distance/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Distance.Models.Stateless;
-
-internal static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Distance/Models/_E_Distance.cs b/Distance/Models/_E_Distance.cs
index 72a9971..aa59aed 100644
--- a/Distance/Models/_E_Distance.cs
+++ b/Distance/Models/_E_Distance.cs
@@ -1,7 +1,6 @@
using ShellProgressBar;
using System.Collections.ObjectModel;
using System.Text.Json;
-using View_by_Distance.Distance.Models.Stateless;
using View_by_Distance.FaceRecognitionDotNet;
using View_by_Distance.Property.Models.Stateless;
using View_by_Distance.Shared.Models;
@@ -17,7 +16,6 @@ public partial class E_Distance : IDistance
private readonly List _Moved;
private readonly List _Debug;
private readonly List _Renamed;
- private readonly Serilog.ILogger? _Log;
private readonly int _FaceConfidencePercent;
private readonly bool _DistanceRenameToMatch;
private readonly bool _DistanceMoveUnableToMatch;
@@ -35,7 +33,6 @@ public partial class E_Distance : IDistance
_AllMappedFaceFiles = new();
_AllMappedFaceFileNames = new();
_DuplicateMappedFaceFiles = new();
- _Log = Serilog.Log.ForContext();
_DistanceRenameToMatch = distanceRenameToMatch;
_FaceConfidencePercent = faceConfidencePercent;
_DistanceMoveUnableToMatch = distanceMoveUnableToMatch;
@@ -298,16 +295,13 @@ public partial class E_Distance : IDistance
public void Clear()
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
- double?[] debug = (from l in _Debug where l is null or not 0 select l).ToArray();
- if (debug.Length > 0)
- {
- string debugMessage = $"{_Debug.Count - debug.Length} - {debug.Min()} - {_Debug.Max()}";
- _Log.Info(debugMessage);
- }
- if (_DuplicateMappedFaceFiles.Count > 0)
- _Log.Info($"Renamed {_DuplicateMappedFaceFiles.Count} to *.dup file(s)");
+ // double?[] debug = (from l in _Debug where l is null or not 0 select l).ToArray();
+ // if (debug.Length > 0)
+ // {
+ // string debugMessage = $"{_Debug.Count - debug.Length} - {debug.Min()} - {_Debug.Max()}";
+ // }
+ // if (_DuplicateMappedFaceFiles.Count > 0)
+ // _Log.Info($"Renamed {_DuplicateMappedFaceFiles.Count} to *.dup file(s)");
if (_Moved.Count > 0 || _Renamed.Count > 0)
throw new NotImplementedException("Restart!");
_Debug.Clear();
diff --git a/Drag-Drop-Explorer/Drag-Drop-Explorer.csproj b/Drag-Drop-Explorer/Drag-Drop-Explorer.csproj
index 8247eab..ec28da6 100644
--- a/Drag-Drop-Explorer/Drag-Drop-Explorer.csproj
+++ b/Drag-Drop-Explorer/Drag-Drop-Explorer.csproj
@@ -30,10 +30,6 @@
-
-
-
-
diff --git a/Drag-Drop-Explorer/DragDropExplorer.cs b/Drag-Drop-Explorer/DragDropExplorer.cs
index fceb6cd..a70765b 100644
--- a/Drag-Drop-Explorer/DragDropExplorer.cs
+++ b/Drag-Drop-Explorer/DragDropExplorer.cs
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Configuration;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
@@ -14,7 +13,6 @@ namespace View_by_Distance.Drag_Drop_Explorer;
public partial class DragDropExplorer : Form
{
- private readonly ILogger _Logger;
private readonly Calendar _Calendar;
private readonly TextBox _PathTextBox;
private readonly TextBox _JsonTextBox;
@@ -27,13 +25,11 @@ public partial class DragDropExplorer : Form
public DragDropExplorer()
{
InitializeComponent();
- ILogger logger;
AppSettings appSettings;
string workingDirectory;
IsEnvironment isEnvironment;
IConfigurationRoot configurationRoot;
_Calendar = new CultureInfo("en-US").Calendar;
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -48,11 +44,6 @@ public partial class DragDropExplorer : Form
throw new Exception("Working path name must have parentDirectory value!");
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();
- logger.Information("Complete");
- _Logger = logger;
_AppSettings = appSettings;
_IsEnvironment = isEnvironment;
_WorkingDirectory = workingDirectory;
@@ -130,7 +121,6 @@ public partial class DragDropExplorer : Form
_FirstTextBox.Text = string.Empty;
_PathTextBox.Text = string.Empty;
_JsonTextBox.Text = string.Empty;
- _Logger.Information("No data");
}
else
{
diff --git a/Drag-Drop-Move/Drag-Drop-Move.csproj b/Drag-Drop-Move/Drag-Drop-Move.csproj
index 590c4cc..7cf0795 100644
--- a/Drag-Drop-Move/Drag-Drop-Move.csproj
+++ b/Drag-Drop-Move/Drag-Drop-Move.csproj
@@ -30,10 +30,6 @@
-
-
-
-
diff --git a/Drag-Drop-Move/DragDropMove.cs b/Drag-Drop-Move/DragDropMove.cs
index d770271..583e2a1 100644
--- a/Drag-Drop-Move/DragDropMove.cs
+++ b/Drag-Drop-Move/DragDropMove.cs
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Configuration;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using System.Text.Json;
@@ -13,7 +12,6 @@ namespace View_by_Distance.Drag.Drop.Move;
public partial class DragDropMove : Form
{
- private readonly ILogger _Logger;
private readonly TextBox _PathTextBox;
private readonly TextBox _JsonTextBox;
private readonly TextBox _FirstTextBox;
@@ -25,12 +23,10 @@ public partial class DragDropMove : Form
public DragDropMove()
{
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);
@@ -45,11 +41,6 @@ public partial class DragDropMove : Form
throw new Exception("Working path name must have parentDirectory value!");
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();
- logger.Information("Complete");
- _Logger = logger;
_AppSettings = appSettings;
_IsEnvironment = isEnvironment;
_WorkingDirectory = workingDirectory;
@@ -186,7 +177,6 @@ public partial class DragDropMove : Form
_FirstTextBox.Text = string.Empty;
_PathTextBox.Text = string.Empty;
_JsonTextBox.Text = string.Empty;
- _Logger.Information("No data");
}
}
catch (Exception)
diff --git a/Drag-Drop-Search/Drag-Drop-Search.csproj b/Drag-Drop-Search/Drag-Drop-Search.csproj
index e7e3636..bfb6b1e 100644
--- a/Drag-Drop-Search/Drag-Drop-Search.csproj
+++ b/Drag-Drop-Search/Drag-Drop-Search.csproj
@@ -31,10 +31,6 @@
-
-
-
-
diff --git a/Drag-Drop-Search/DragDropSearch.cs b/Drag-Drop-Search/DragDropSearch.cs
index 7a1ad0e..f1a61cf 100644
--- a/Drag-Drop-Search/DragDropSearch.cs
+++ b/Drag-Drop-Search/DragDropSearch.cs
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Configuration;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Drag_Drop.Models;
@@ -14,7 +13,6 @@ namespace View_by_Distance.Drag_Drop;
public partial class DragDropSearch : Form
{
- private readonly ILogger _Logger;
private readonly TextBox _TextBox;
private readonly AppSettings _AppSettings;
private readonly ProgressBar _ProgressBar;
@@ -29,14 +27,12 @@ public partial class DragDropSearch : Form
public DragDropSearch()
{
InitializeComponent();
- ILogger logger;
_IdToItem = new();
AppSettings appSettings;
string workingDirectory;
IsEnvironment isEnvironment;
Models.Configuration configuration;
IConfigurationRoot configurationRoot;
- LoggerConfiguration loggerConfiguration = new();
Property.Models.Configuration propertyConfiguration;
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
@@ -51,14 +47,9 @@ public partial class DragDropSearch : Form
throw new Exception("Working path name must have parentDirectory value!");
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();
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
(_, _, string resizeFileNameExtension) = C_Resize.GetTuple(configuration.OutputExtension, configuration.OutputQuality);
- logger.Information("Complete");
- _Logger = logger;
_AppSettings = appSettings;
_Configuration = configuration;
_IsEnvironment = isEnvironment;
@@ -128,14 +119,6 @@ public partial class DragDropSearch : Form
continue;
_IdToItem.Add(item.Property.Id.Value, item);
}
- if (_Logger is null)
- throw new NullReferenceException(nameof(_Logger));
- _Logger.Debug((_AppSettings is null).ToString());
- _Logger.Debug((_Configuration is null).ToString());
- _Logger.Debug((_IsEnvironment is null).ToString());
- _Logger.Debug((_WorkingDirectory is null).ToString());
- _Logger.Debug((_ConfigurationRoot is null).ToString());
- _Logger.Debug((_PropertyConfiguration is null).ToString());
}
public static string? GetFaceEncoding(string file)
@@ -179,8 +162,6 @@ public partial class DragDropSearch : Form
{
Text = item.ImageFileHolder.Name;
_TextBox.Text = item.ImageFileHolder.FullName;
- if (item.ImageFileHolder.DirectoryName is not null)
- _Logger.Information(item.ImageFileHolder.DirectoryName);
if (!string.IsNullOrEmpty(item.ImageFileHolder.DirectoryName))
_ = Process.Start("explorer.exe", string.Concat("\"", item.ImageFileHolder.DirectoryName, "\""));
}
diff --git a/Drag-Drop-Set-Property-Item/Drag-Drop-Set-Property-Item.csproj b/Drag-Drop-Set-Property-Item/Drag-Drop-Set-Property-Item.csproj
index 7185e03..89fc539 100644
--- a/Drag-Drop-Set-Property-Item/Drag-Drop-Set-Property-Item.csproj
+++ b/Drag-Drop-Set-Property-Item/Drag-Drop-Set-Property-Item.csproj
@@ -31,10 +31,6 @@
-
-
-
-
diff --git a/Drag-Drop-Set-Property-Item/DragDropSetPropertyItem.cs b/Drag-Drop-Set-Property-Item/DragDropSetPropertyItem.cs
index 158cc67..5f27338 100644
--- a/Drag-Drop-Set-Property-Item/DragDropSetPropertyItem.cs
+++ b/Drag-Drop-Set-Property-Item/DragDropSetPropertyItem.cs
@@ -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();
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 GetRecords(ASCIIEncoding asciiEncoding, int tagId, List files)
{
diff --git a/Duplicate-Search/Duplicate-Search.csproj b/Duplicate-Search/Duplicate-Search.csproj
index 65aaa4d..bc9dc37 100644
--- a/Duplicate-Search/Duplicate-Search.csproj
+++ b/Duplicate-Search/Duplicate-Search.csproj
@@ -37,10 +37,6 @@
-
-
-
-
diff --git a/Duplicate-Search/DuplicateSearch.cs b/Duplicate-Search/DuplicateSearch.cs
index d207724..2e26cf6 100644
--- a/Duplicate-Search/DuplicateSearch.cs
+++ b/Duplicate-Search/DuplicateSearch.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using ShellProgressBar;
using System.Text;
using System.Text.Json;
@@ -14,7 +14,7 @@ namespace View_by_Distance.Duplicate.Search;
public class DuplicateSearch
{
- public DuplicateSearch(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public DuplicateSearch(List args, ILogger logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
{
if (isSilent)
{ }
@@ -22,9 +22,8 @@ public class DuplicateSearch
{ }
string searchPattern = "*";
long ticks = DateTime.Now.Ticks;
- ILogger? log = Log.ForContext();
Configuration configuration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
- log.Information(configuration.RootDirectory);
+ logger?.LogInformation(configuration.RootDirectory);
if (appSettings.IndexOnly)
WriteIndexData(ticks, configuration, searchPattern);
else
@@ -38,9 +37,9 @@ public class DuplicateSearch
Dictionary> idToCollection = GetIdToCollection(argZero, configuration, argZeroIsConfigurationRootDirectory, containers, destinationRoot, preloadIds);
int duplicates = (from l in idToCollection where l.Value.Count > 1 select 1).Sum();
if (duplicates == 0)
- log.Information($"Found {duplicates} duplicate file(s)");
+ logger?.LogInformation($"Found {duplicates} duplicate file(s)");
else
- QuestionMove(ticks, log, destinationRoot, idToCollection, duplicates);
+ QuestionMove(ticks, logger, destinationRoot, idToCollection, duplicates);
}
}
@@ -61,7 +60,7 @@ public class DuplicateSearch
File.WriteAllText(Path.Combine(alongSideDirectory, $"{directoryName}-{ticks}.json"), json);
}
- private static void Move(ILogger log, long ticks, string destinationRoot, List<(FileHolder ImageFileHolder, string Destination)> collection)
+ private static void Move(ILogger? logger, long ticks, string destinationRoot, List<(FileHolder ImageFileHolder, string Destination)> collection)
{
StringBuilder stringBuilder = new();
foreach ((FileHolder fileHolder, string destination) in collection)
@@ -70,28 +69,28 @@ public class DuplicateSearch
_ = stringBuilder.AppendLine(destination);
}
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(Path.Combine(destinationRoot, $"{ticks}file(s).lsv"), stringBuilder.ToString(), updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
- log.Information($"Ready to move {collection.Count} file(s)?");
+ logger?.LogInformation($"Ready to move {collection.Count} file(s)?");
for (int y = 0; y < int.MaxValue; y++)
{
- log.Information("Press \"Y\" key to move file(s) or close console to not move files");
+ logger?.LogInformation("Press \"Y\" key to move file(s) or close console to not move files");
if (System.Console.ReadKey().Key == ConsoleKey.Y)
break;
}
- log.Information(". . .");
+ logger?.LogInformation(". . .");
foreach ((FileHolder fileHolder, string destination) in collection)
{
try
{ File.Move(fileHolder.FullName, destination); }
catch (Exception exception)
- { log.Error(exception, $"Failed to move <{fileHolder.FullName}>"); }
+ { logger?.LogError(exception, $"Failed to move <{fileHolder.FullName}>"); }
}
- log.Information($"{collection.Count} file(s) moved");
+ logger?.LogInformation($"{collection.Count} file(s) moved");
for (int y = 0; y < int.MaxValue; y++)
{
- log.Information("Press \"Y\" key to move file(s) back or close console to leave them moved");
+ logger?.LogInformation("Press \"Y\" key to move file(s) back or close console to leave them moved");
if (System.Console.ReadKey().Key != ConsoleKey.Y)
continue;
- log.Information(". . .");
+ logger?.LogInformation(". . .");
foreach ((FileHolder fileHolder, string destination) in collection)
{
if (!File.Exists(destination))
@@ -101,27 +100,27 @@ public class DuplicateSearch
try
{ File.Move(destination, fileHolder.FullName); }
catch (Exception exception)
- { log.Error(exception, $"Failed to move <{destination}>"); }
+ { logger?.LogError(exception, $"Failed to move <{destination}>"); }
}
}
- log.Information(". . .");
+ logger?.LogInformation(". . .");
}
- private static void QuestionMove(long ticks, ILogger log, string destinationRoot, Dictionary> idToCollection, int duplicates)
+ private static void QuestionMove(long ticks, ILogger? logger, string destinationRoot, Dictionary> idToCollection, int duplicates)
{
int[] ids = (from l in idToCollection orderby l.Key where l.Value.Any(m => m is not null) select l.Key).ToArray();
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(Path.Combine(destinationRoot, $"{ticks}-id(s).lsv"), string.Join(Environment.NewLine, ids), updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
string json = JsonSerializer.Serialize(idToCollection, new JsonSerializerOptions { WriteIndented = true });
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(Path.Combine(destinationRoot, $"{ticks}.json"), json, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
- log.Information($"Found {duplicates} duplicate file(s)");
+ logger?.LogInformation($"Found {duplicates} duplicate file(s)");
for (int y = 0; y < int.MaxValue; y++)
{
- log.Information("Press \"Y\" key to continue or close console to leave them moved");
+ logger?.LogInformation("Press \"Y\" key to continue or close console to leave them moved");
if (System.Console.ReadKey().Key != ConsoleKey.Y)
continue;
- log.Information(". . .");
+ logger?.LogInformation(". . .");
List<(FileHolder ImageFileHolder, string Destination)> collection = GetCollectionAndCreateDirectories(idToCollection);
- Move(log, ticks, destinationRoot, collection);
+ Move(logger, ticks, destinationRoot, collection);
}
}
diff --git a/Duplicate-Search/Models/Stateless/SerilogExtensionMethods.cs b/Duplicate-Search/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index e8b4399..0000000
--- a/Duplicate-Search/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Duplicate.Search.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Duplicate-Search/Program.cs b/Duplicate-Search/Program.cs
index 02e681f..067ce20 100644
--- a/Duplicate-Search/Program.cs
+++ b/Duplicate-Search/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Duplicate.Search.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Duplicate.Search;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -30,9 +31,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -41,31 +39,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- _ = new DuplicateSearch(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ _ = new DuplicateSearch(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Face/Face.csproj b/Face/Face.csproj
index 6918f39..57422ef 100644
--- a/Face/Face.csproj
+++ b/Face/Face.csproj
@@ -33,7 +33,6 @@
-
diff --git a/Face/Models/Stateless/SerilogExtensionMethods.cs b/Face/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 50f236a..0000000
--- a/Face/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Face.Models.Stateless;
-
-internal static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Face/Models/_D_Face.cs b/Face/Models/_D_Face.cs
index c37d623..6d3bba4 100644
--- a/Face/Models/_D_Face.cs
+++ b/Face/Models/_D_Face.cs
@@ -1,11 +1,9 @@
using System.Collections.ObjectModel;
-using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;
-using View_by_Distance.Face.Models.Stateless;
using View_by_Distance.FaceRecognitionDotNet;
using View_by_Distance.Metadata.Models;
using View_by_Distance.Property.Models;
@@ -31,7 +29,6 @@ public class D_Face
private readonly Model _Model;
private readonly string _ArgZero;
- private readonly Serilog.ILogger? _Log;
private readonly bool _OverrideForFaceImages;
private readonly bool _LoadPhotoPrismLocations;
private readonly ImageCodecInfo _ImageCodecInfo;
@@ -75,7 +72,6 @@ public class D_Face
_ImageCodecInfo = imageCodecInfo;
_EncoderParameters = encoderParameters;
_FileNameExtension = filenameExtension;
- _Log = Serilog.Log.ForContext();
_HiddenImageCodecInfo = hiddenImageCodecInfo;
_OverrideForFaceImages = overrideForFaceImages;
_PropertyConfiguration = propertyConfiguration;
@@ -219,8 +215,6 @@ public class D_Face
private List GetFaces(string outputResolution, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary outputResolutionToResize, List? locations)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
if (_PropertyConfiguration.NumberOfJitters is null)
throw new NullReferenceException(nameof(_PropertyConfiguration.NumberOfJitters));
if (_PropertyConfiguration.NumberOfTimesToUpsample is null)
@@ -230,10 +224,7 @@ public class D_Face
try
{ unknownImage = FaceRecognition.LoadImageFile(mappingFromItem.ResizedFileHolder.FullName); }
catch (Exception)
- {
- unknownImage = null;
- _Log.Info(string.Concat(new StackFrame().GetMethod()?.Name, " <", mappingFromItem.ResizedFileHolder.FullName, ">"));
- }
+ { unknownImage = null; }
if (unknownImage is not null)
{
(int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation) = Resize.Models.Stateless.Methods.IResize.Get(outputResolution, outputResolutionToResize);
diff --git a/FaceParts/FaceParts.csproj b/FaceParts/FaceParts.csproj
index a9bac33..c77b5ac 100644
--- a/FaceParts/FaceParts.csproj
+++ b/FaceParts/FaceParts.csproj
@@ -33,7 +33,6 @@
-
diff --git a/FaceParts/Models/Stateless/SerilogExtensionMethods.cs b/FaceParts/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 89d58f7..0000000
--- a/FaceParts/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.FaceParts.Models.Stateless;
-
-internal static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/FaceParts/Models/_D2_FaceParts.cs b/FaceParts/Models/_D2_FaceParts.cs
index d0009b2..feeb079 100644
--- a/FaceParts/Models/_D2_FaceParts.cs
+++ b/FaceParts/Models/_D2_FaceParts.cs
@@ -22,7 +22,6 @@ public class D2_FaceParts
protected readonly string _FileNameExtension;
public string FileNameExtension => _FileNameExtension;
- private readonly Serilog.ILogger? _Log;
private readonly ImageCodecInfo _ImageCodecInfo;
private readonly bool _CheckDFaceAndUpWriteDates;
private readonly bool _OverrideForFaceLandmarkImages;
@@ -38,7 +37,6 @@ public class D2_FaceParts
_EncoderParameters = encoderParameters;
_FileNameExtension = filenameExtension;
_AngleBracketCollection = new List();
- _Log = Serilog.Log.ForContext();
_PropertyConfiguration = propertyConfiguration;
_CheckDFaceAndUpWriteDates = checkDFaceAndUpWriteDates;
_OverrideForFaceLandmarkImages = overrideForFaceLandmarkImages;
@@ -131,10 +129,10 @@ public class D2_FaceParts
// it will be after rotation.
PointF[] points =
{
- new PointF(0, 0),
- new PointF(bitmap.Width, 0),
- new PointF(bitmap.Width, bitmap.Height),
- new PointF(0, bitmap.Height),
+ new (0, 0),
+ new (bitmap.Width, 0),
+ new (bitmap.Width, bitmap.Height),
+ new (0, bitmap.Height),
};
rotate_at_origin.TransformPoints(points);
float xMinimum, xMaximum, yMinimum, yMaximum;
diff --git a/Instance/DlibDotNet.cs b/Instance/DlibDotNet.cs
index 1ddfd4f..3b2cb04 100644
--- a/Instance/DlibDotNet.cs
+++ b/Instance/DlibDotNet.cs
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
using ShellProgressBar;
using System.Collections.ObjectModel;
@@ -29,11 +30,11 @@ public partial class DlibDotNet
private readonly F_Random _Random;
private readonly IConsole _Console;
private readonly E_Distance _Distance;
- private readonly Serilog.ILogger? _Log;
private readonly IBlurHasher _BlurHasher;
private readonly D2_FaceParts _FaceParts;
private readonly AppSettings _AppSettings;
private readonly List _Exceptions;
+ private readonly ILogger? _Logger;
private readonly IsEnvironment _IsEnvironment;
private readonly bool _PropertyRootExistedBefore;
private readonly Models.Configuration _Configuration;
@@ -43,6 +44,7 @@ public partial class DlibDotNet
public DlibDotNet(
List args,
+ ILogger logger,
IsEnvironment isEnvironment,
IConfigurationRoot configurationRoot,
AppSettings appSettings,
@@ -51,6 +53,7 @@ public partial class DlibDotNet
IConsole console)
{
string message;
+ _Logger = logger;
_Console = console;
_AppSettings = appSettings;
_IsEnvironment = isEnvironment;
@@ -59,11 +62,10 @@ public partial class DlibDotNet
_JLinkResolvedDirectories = new();
if (ticks.ToString().Last() == '0')
ticks += 1;
- _Log = Serilog.Log.ForContext();
ReadOnlyCollection personContainers;
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
Models.Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
- _Log.Information(propertyConfiguration.RootDirectory);
+ _Logger?.LogInformation(propertyConfiguration.RootDirectory);
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
Verify(configuration);
VerifyExtra(args, propertyConfiguration, configuration);
@@ -78,7 +80,7 @@ public partial class DlibDotNet
_ArgZeroIsConfigurationRootDirectory = propertyConfiguration.RootDirectory == argZero;
if (!Directory.Exists(argZero))
_ = Directory.CreateDirectory(argZero);
- _Log.Information(configuration.ModelDirectory);
+ _Logger?.LogInformation(configuration.ModelDirectory);
{
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetPngLowQuality();
(ImageCodecInfo hiddenImageCodecInfo, EncoderParameters hiddenEncoderParameters, string hiddenFileNameExtension) = C_Resize.GetGifLowQuality();
@@ -149,15 +151,15 @@ public partial class DlibDotNet
if (!_PropertyRootExistedBefore && !_IsEnvironment.Development && _Exceptions.Count == 0 && _ArgZeroIsConfigurationRootDirectory)
{
string d2FacePartsRootDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(propertyConfiguration, nameof(D2_FaceParts));
- _Log.Information(string.Concat("Cleaning <", d2FacePartsRootDirectory, ">"));
+ _Logger?.LogInformation(string.Concat("Cleaning <", d2FacePartsRootDirectory, ">"));
Shared.Models.Stateless.Methods.IPath.ChangeDateForEmptyDirectories(d2FacePartsRootDirectory, ticks);
}
message = $"There were {_Exceptions.Count} exception(s) thrown! {Environment.NewLine}{string.Join(Environment.NewLine, _Exceptions)}";
- _Log.Information(message);
+ _Logger?.LogInformation(message);
if (_Exceptions.Count != 0)
throw new Exception(message);
if (_PropertyRootExistedBefore)
- _Log.Information("First run completed. Run again if wanted");
+ _Logger?.LogInformation("First run completed. Run again if wanted");
}
private static void Verify(Models.Configuration configuration)
@@ -427,8 +429,6 @@ public partial class DlibDotNet
private string SaveUrlAndGetNewRootDirectory(string[] files)
{
string result;
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
if (files.Length == 0)
throw new NotSupportedException();
string? sourceDirectory = Path.GetDirectoryName(files.First());
@@ -448,7 +448,7 @@ public partial class DlibDotNet
int length = result.Length;
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information("Enter fileNameToCollection url for fileNameToCollection image");
+ _Logger?.LogInformation("Enter fileNameToCollection url for fileNameToCollection image");
line = _Console.ReadLine();
if (string.IsNullOrEmpty(line))
break;
@@ -466,14 +466,12 @@ public partial class DlibDotNet
_ = new Item(fileHolder, relativePath, isValidImageFormatExtension);
// container.Items.Add(item);
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
return result;
}
private void FullDoWork(string argZero, string propertyRoot, long ticks, string aResultsFullGroupDirectory, string bResultsFullGroupDirectory, int t, Container[] containers, A_Property propertyLogic, B_Metadata metadata, Dictionary> fileNameToCollection, MapLogic mapLogic)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
int total;
int notMapped;
string message;
@@ -542,11 +540,11 @@ public partial class DlibDotNet
{
for (int y = 0; y < int.MaxValue; y++)
{
- _Log.Information("Press \"Y\" key when ready to continue or close console");
+ _Logger?.LogInformation("Press \"Y\" key when ready to continue or close console");
if (_Console.ReadKey() == ConsoleKey.Y)
break;
}
- _Log.Information(". . .");
+ _Logger?.LogInformation(". . .");
}
total += container.Items.Count;
}
@@ -741,37 +739,22 @@ public partial class DlibDotNet
private void LogItemPropertyIsNull(Item item)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
if (!item.SourceDirectoryFileHolder.Exists)
- _Log.Information(string.Concat("NoJson <", item.ImageFileHolder.FullName, '>'));
+ _Logger?.LogInformation(string.Concat("NoJson <", item.ImageFileHolder.FullName, '>'));
else if (item.FileSizeChanged.HasValue && item.FileSizeChanged.Value)
- _Log.Information(string.Concat("FileSizeChanged <", item.ImageFileHolder.FullName, '>'));
+ _Logger?.LogInformation(string.Concat("FileSizeChanged <", item.ImageFileHolder.FullName, '>'));
else if (item.LastWriteTimeChanged.HasValue && item.LastWriteTimeChanged.Value)
- _Log.Information(string.Concat("LastWriteTimeChanged <", item.ImageFileHolder.FullName, '>'));
+ _Logger?.LogInformation(string.Concat("LastWriteTimeChanged <", item.ImageFileHolder.FullName, '>'));
else if (item.Moved.HasValue && item.Moved.Value)
- _Log.Information(string.Concat("Moved <", item.ImageFileHolder.FullName, '>'));
+ _Logger?.LogInformation(string.Concat("Moved <", item.ImageFileHolder.FullName, '>'));
}
private void LogNameWithoutExtensionIsIdFormatBut(Item item)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
- _Log.Information($"Name without extension is Id format but doesn't match id <{item.ImageFileHolder.FullName}>");
+ _Logger?.LogInformation($"Name without extension is Id format but doesn't match id <{item.ImageFileHolder.FullName}>");
File.Move(item.ImageFileHolder.FullName, $"{item.ImageFileHolder.FullName}.rename");
}
- private long LogDelta(long ticks, string? methodName)
- {
- long result;
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
- double delta = new TimeSpan(DateTime.Now.Ticks - ticks).TotalMilliseconds;
- _Log.Debug($"{methodName} took {Math.Floor(delta)} millisecond(s)");
- result = DateTime.Now.Ticks;
- return result;
- }
-
private int GetNotMappedCountAndUpdateMappingFromPersonThenSetMapping(MapLogic mapLogic, Item item, bool? isFocusRelativePath, ReadOnlyCollection> locationContainers, MappingFromItem mappingFromItem, List? mappingFromPhotoPrismCollection, List faces)
{
int result;
@@ -985,8 +968,6 @@ public partial class DlibDotNet
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(containerDateTimes, item, resizedFileHolder);
Map.Models.Stateless.Methods.IMapLogic.SetCreationTimeMaybeMoveToDecade(_Configuration.PropertyConfiguration, _Configuration.MoveToDecade && _Configuration.LocationContainerDistanceTolerance is null, mappingFromItem, locationContainers);
ReadOnlyDictionary metadataExtractorDirectories = metadata.GetMetadataCollection(subFileTuples, parseExceptions, changesFrom, mappingFromItem);
- if (_AppSettings.MaxDegreeOfParallelism < 2)
- ticks = LogDelta(ticks, nameof(B_Metadata.GetMetadataCollection));
if (_AppSettings.Places.Count > 0)
{
float latitude;
@@ -1010,14 +991,8 @@ public partial class DlibDotNet
}
}
Dictionary outputResolutionToResize = _Resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, item.Property, mappingFromItem);
- if (_AppSettings.MaxDegreeOfParallelism < 2)
- ticks = LogDelta(ticks, nameof(C_Resize.GetResizeKeyValuePairs));
if (_Configuration.SaveResizedSubfiles)
- {
_Resize.SaveResizedSubfile(_Configuration.PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, outputResolutionToResize);
- if (_AppSettings.MaxDegreeOfParallelism < 2)
- ticks = LogDelta(ticks, nameof(C_Resize.SaveResizedSubfile));
- }
if (!_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Contains(outputResolution))
faces = new();
else if (!mappingFromItem.ResizedFileHolder.Exists && !File.Exists(mappingFromItem.ResizedFileHolder.FullName))
@@ -1028,14 +1003,10 @@ public partial class DlibDotNet
if (!fileNameToCollection.TryGetValue(mappingFromItem.Id, out mappingFromPhotoPrismCollection))
mappingFromPhotoPrismCollection = null;
faces = _Faces.GetFaces(outputResolution, dResultsFullGroupDirectory, subFileTuples, parseExceptions, property, mappingFromItem, outputResolutionToResize, locationContainers, mappingFromPhotoPrismCollection);
- if (_AppSettings.MaxDegreeOfParallelism < 2)
- ticks = LogDelta(ticks, nameof(D_Face.GetFaces));
result = GetNotMappedCountAndUpdateMappingFromPersonThenSetMapping(mapLogic, item, isFocusRelativePath, locationContainers, mappingFromItem, mappingFromPhotoPrismCollection, faces);
List<(Shared.Models.Face, FileInfo?, string, bool Saved)> faceCollection = _Faces.SaveFaces(_FaceParts.FileNameExtension, dResultsFullGroupDirectory, subFileTuples, parseExceptions, mappingFromItem, faces);
if (_Configuration.CopyFacesAndSaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
_FaceParts.CopyFacesAndSaveFaceLandmarkImage(facePartsCollectionDirectory, mappingFromItem, faceCollection);
- if (_AppSettings.MaxDegreeOfParallelism < 2)
- ticks = LogDelta(ticks, nameof(D_Face.SaveFaces));
if ((_Configuration.DistanceMoveUnableToMatch || _Configuration.DistanceRenameToMatch)
&& _Configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions.Contains(outputResolution)
&& locationContainers is not null && faceCollection.All(l => !l.Saved))
@@ -1046,8 +1017,6 @@ public partial class DlibDotNet
bool saveRotated = false;
string sourceDirectorySegment = Property.Models.Stateless.IResult.GetRelativePath(_Configuration.PropertyConfiguration, container.SourceDirectory);
_FaceParts.SaveFaceLandmarkImages(_Configuration.PropertyConfiguration, subFileTuples, parseExceptions, mappingFromItem, faces, saveRotated);
- if (_AppSettings.MaxDegreeOfParallelism < 2)
- ticks = LogDelta(ticks, nameof(D2_FaceParts.SaveFaceLandmarkImages));
}
}
lock (sourceDirectoryChanges)
@@ -1073,8 +1042,6 @@ public partial class DlibDotNet
Item[] filteredItems,
string message)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
int result = 0;
int exceptionsCount = 0;
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism };
@@ -1108,10 +1075,9 @@ public partial class DlibDotNet
if (!anyPropertiesChangedForX && (i == 0 || sourceDirectoryChanges.Count > 0))
progressBar.Tick();
}
- catch (Exception ex)
+ catch (Exception)
{
exceptionsCount++;
- _Log.Error(string.Concat(container.SourceDirectory, Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace), ex);
if (exceptionsCount == filteredItems.Length)
throw new Exception(string.Concat("All in [", container.SourceDirectory, "] failed!"));
}
@@ -1173,8 +1139,6 @@ public partial class DlibDotNet
private void SaveFaceDistances(long ticks, MapLogic mapLogic, string dFacesContentDirectory, string d2FacePartsContentDirectory, string d2FacePartsContentCollectionDirectory, ReadOnlyDictionary> idToWholePercentagesToMapping, ReadOnlyCollection faceDistanceEncodings, ReadOnlyCollection faceDistanceContainers)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
int? useFiltersCounter = null;
DistanceLimits distanceLimits;
ReadOnlyCollection sortingContainers;
@@ -1183,7 +1147,7 @@ public partial class DlibDotNet
distanceLimits = new(_Configuration.FaceAreaPermyriad, _Configuration.FaceConfidencePercent, _Configuration.FaceDistancePermyriad, _Configuration.RangeDaysDeltaTolerance, _Configuration.RangeDistanceTolerance, _Configuration.RangeFaceAreaPermyriadTolerance, _Configuration.RangeFaceConfidence, _Configuration.SortingMaximumPerFaceShouldBeHigh);
filteredFaceDistanceContainers = E_Distance.FilteredPostLoadFaceDistanceContainers(mapLogic, faceDistanceContainers, skipOlderThan, distanceLimits);
if (filteredFaceDistanceContainers.Length == 0)
- _Log.Information("All images have been filtered!");
+ _Logger?.LogInformation("All images have been filtered!");
else
{
sortingContainers = E_Distance.SetFaceMappingSortingCollectionThenGetSortedSortingContainers(_AppSettings.MaxDegreeOfParallelism, _MapConfiguration, ticks, mapLogic, distanceLimits, faceDistanceEncodings, filteredFaceDistanceContainers);
@@ -1194,7 +1158,7 @@ public partial class DlibDotNet
distanceLimits = new(_Configuration.FaceAreaPermyriad, _Configuration.FaceConfidencePercent, _Configuration.FaceDistancePermyriad, _Configuration.RangeDaysDeltaTolerance, _Configuration.RangeDistanceTolerance, _Configuration.RangeFaceAreaPermyriadTolerance, _Configuration.RangeFaceConfidence, _Configuration.SortingMaximumPerFaceShouldBeHigh, useFiltersCounter);
filteredFaceDistanceContainers = E_Distance.FilteredPostLoadFaceDistanceContainers(mapLogic, faceDistanceContainers, skipOlderThan, distanceLimits);
if (filteredFaceDistanceContainers.Length == 0)
- _Log.Information("All images have been filtered!");
+ _Logger?.LogInformation("All images have been filtered!");
else
{
sortingContainers = E_Distance.SetFaceMappingSortingCollectionThenGetSortedSortingContainers(_AppSettings.MaxDegreeOfParallelism, _MapConfiguration, ticks, mapLogic, distanceLimits, faceDistanceEncodings, filteredFaceDistanceContainers);
diff --git a/Instance/Instance.csproj b/Instance/Instance.csproj
index add38bb..fc83a84 100644
--- a/Instance/Instance.csproj
+++ b/Instance/Instance.csproj
@@ -41,10 +41,6 @@
-
-
-
-
diff --git a/Instance/Models/Stateless/SerilogExtensionMethods.cs b/Instance/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 07c754c..0000000
--- a/Instance/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Instance.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Instance/Models/_F_Random.cs b/Instance/Models/_F_Random.cs
index 4059686..b66e72a 100644
--- a/Instance/Models/_F_Random.cs
+++ b/Instance/Models/_F_Random.cs
@@ -9,14 +9,12 @@ namespace View_by_Distance.Instance.Models;
internal class F_Random
{
- private readonly Serilog.ILogger? _Log;
private readonly Configuration _Configuration;
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
internal F_Random(Configuration configuration)
{
_Configuration = configuration;
- _Log = Serilog.Log.ForContext();
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = false };
}
diff --git a/Instance/Program.cs b/Instance/Program.cs
index 760422d..adeb608 100644
--- a/Instance/Program.cs
+++ b/Instance/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Instance.Models;
@@ -10,9 +12,8 @@ namespace View_by_Distance.Instance;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -27,9 +28,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -38,31 +36,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- DlibDotNet _ = new(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ DlibDotNet _ = new(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Map/Map.csproj b/Map/Map.csproj
index 96a39a4..112a3f8 100644
--- a/Map/Map.csproj
+++ b/Map/Map.csproj
@@ -35,7 +35,6 @@
-
diff --git a/Map/Models/MapLogic.cs b/Map/Models/MapLogic.cs
index bdf29ca..1cdda93 100644
--- a/Map/Models/MapLogic.cs
+++ b/Map/Models/MapLogic.cs
@@ -210,7 +210,6 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
}
private readonly long _Ticks;
- private readonly Serilog.ILogger? _Log;
private readonly Configuration? _Configuration;
private readonly string _EDistanceContentTicksDirectory;
private readonly ReadOnlyDictionary _PersonKeyToCount;
@@ -225,10 +224,7 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
{
_Ticks = ticks;
_Configuration = configuration;
- _Log = Serilog.Log.ForContext();
_PropertyConfiguration = propertyConfiguration;
- if (_Log is null)
- { }
ReadOnlyDictionary readOnlyPersonKeyToCount;
List notMappedPersonContainers = new();
Dictionary> skipCollection = new();
diff --git a/Map/Models/Stateless/SerilogExtensionMethods.cs b/Map/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 73fa032..0000000
--- a/Map/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Map.Models.Stateless;
-
-internal static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Metadata-Query/Metadata-Query.csproj b/Metadata-Query/Metadata-Query.csproj
index b31e8c0..7983b5c 100644
--- a/Metadata-Query/Metadata-Query.csproj
+++ b/Metadata-Query/Metadata-Query.csproj
@@ -39,10 +39,6 @@
-
-
-
-
diff --git a/Metadata-Query/MetadataQuery.cs b/Metadata-Query/MetadataQuery.cs
index 159a4e0..f5f3b41 100644
--- a/Metadata-Query/MetadataQuery.cs
+++ b/Metadata-Query/MetadataQuery.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using ShellProgressBar;
using System.Text;
using System.Text.Json;
@@ -19,7 +19,7 @@ public class MetadataQuery
private readonly IConfigurationRoot _ConfigurationRoot;
private readonly Property.Models.Configuration _PropertyConfiguration;
- public MetadataQuery(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public MetadataQuery(List args, ILogger logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
{
if (isSilent)
{ }
@@ -30,14 +30,13 @@ public class MetadataQuery
long ticks = DateTime.Now.Ticks;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
- ILogger? log = Log.ForContext();
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
_PropertyConfiguration = propertyConfiguration;
_Configuration = configuration;
- log.Information(propertyConfiguration.RootDirectory);
+ logger?.LogInformation(propertyConfiguration.RootDirectory);
Verify();
- MetadataQueryFilesInDirectories(log, ticks);
+ MetadataQueryFilesInDirectories(logger, ticks);
}
private void Verify()
@@ -122,10 +121,10 @@ public class MetadataQuery
return keyValuePairs;
}
- private void MetadataQueryFilesInDirectories(ILogger log, long ticks)
+ private void MetadataQueryFilesInDirectories(ILogger? logger, long ticks)
{
List<(string FileName, string Count, string TagGroup, string TagIdName, string Value)> collection = GetCollection(ticks);
- log.Information($"Ready to query {collection.Count} entries?");
+ logger?.LogInformation($"Ready to query {collection.Count} entries?");
IEnumerable<(string FileName, string Count, string TagGroup, string TagIdName, string Value)> enumerable()
{
foreach ((string FileName, string Count, string TagGroup, string TagIdName, string Value) l in collection)
diff --git a/Metadata-Query/Models/Stateless/SerilogExtensionMethods.cs b/Metadata-Query/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 984dc7d..0000000
--- a/Metadata-Query/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Metadata.Query.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Metadata-Query/Program.cs b/Metadata-Query/Program.cs
index 6bd0d54..211f98f 100644
--- a/Metadata-Query/Program.cs
+++ b/Metadata-Query/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Metadata.Query.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Metadata.Query;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -30,9 +31,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -41,31 +39,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- _ = new MetadataQuery(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ _ = new MetadataQuery(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Metadata/Metadata.csproj b/Metadata/Metadata.csproj
index 2400a9f..7378753 100644
--- a/Metadata/Metadata.csproj
+++ b/Metadata/Metadata.csproj
@@ -34,7 +34,6 @@
-
diff --git a/Metadata/Models/Avi.cs b/Metadata/Models/Avi.cs
new file mode 100644
index 0000000..3ee0229
--- /dev/null
+++ b/Metadata/Models/Avi.cs
@@ -0,0 +1,29 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace View_by_Distance.Metadata.Models;
+
+ public record Avi(string? FramesPerSecond1,
+ string? SamplesPerSecond2,
+ string? Duration3,
+ string? VideoCodec4,
+ string? AudioCodec5,
+ string? Width6,
+ string? Height7,
+ string? Streams8,
+ string? DateTimeOriginal320)
+{
+
+ public override string ToString()
+ {
+ string result = JsonSerializer.Serialize(this, AviSourceGenerationContext.Default.Avi);
+ return result;
+ }
+
+}
+
+[JsonSourceGenerationOptions(WriteIndented = true)]
+[JsonSerializable(typeof(Avi))]
+public partial class AviSourceGenerationContext : JsonSerializerContext
+{
+}
\ No newline at end of file
diff --git a/Metadata/Models/B_Metadata.cs b/Metadata/Models/B_Metadata.cs
index 0fe2ead..aa3c925 100644
--- a/Metadata/Models/B_Metadata.cs
+++ b/Metadata/Models/B_Metadata.cs
@@ -16,7 +16,6 @@ namespace View_by_Distance.Metadata.Models;
public class B_Metadata : IMetadata
{
- private readonly Serilog.ILogger? _Log;
private readonly bool _PropertiesChangedForMetadata;
private readonly IPropertyConfiguration _PropertyConfiguration;
private readonly bool _ForceMetadataLastWriteTimeToCreationTime;
@@ -26,7 +25,6 @@ public class B_Metadata : IMetadata
public B_Metadata(IPropertyConfiguration propertyConfiguration)
{
_PropertiesChangedForMetadata = false;
- _Log = Serilog.Log.ForContext();
_PropertyConfiguration = propertyConfiguration;
_ForceMetadataLastWriteTimeToCreationTime = false;
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
@@ -35,7 +33,6 @@ public class B_Metadata : IMetadata
public B_Metadata(IPropertyConfiguration propertyConfiguration, bool forceMetadataLastWriteTimeToCreationTime, bool propertiesChangedForMetadata, string bResultsFullGroupDirectory)
{
- _Log = Serilog.Log.ForContext();
_PropertyConfiguration = propertyConfiguration;
_PropertiesChangedForMetadata = propertiesChangedForMetadata;
_ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime;
diff --git a/Metadata/Models/Exif.cs b/Metadata/Models/Exif.cs
new file mode 100644
index 0000000..c227f59
--- /dev/null
+++ b/Metadata/Models/Exif.cs
@@ -0,0 +1,194 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace View_by_Distance.Metadata.Models;
+
+ public record Exif(string? InteropIndex1,
+ string? Noise37389,
+ string? FocalPlaneXResolutionTiffEp37390,
+ string? FocalPlaneYResolutionTiffEp37391,
+ string? ImageNumber37393,
+ string? SecurityClassification37394,
+ string? ImageHistory37395,
+ string? SubjectLocationTiffEp37396,
+ string? ExposureIndexTiffEp37397,
+ string? SpatialFreqResponseTiffEp37388,
+ string? StandardIdTiffEp37398,
+ string? UserComment37510,
+ string? SubsecondTime37520,
+ string? SubsecondTimeOriginal37521,
+ string? SubsecondTimeDigitized37522,
+ string? WinTitle40091,
+ string? WinComment40092,
+ string? WinAuthor40093,
+ string? WinKeywords40094,
+ string? Makernote37500,
+ string? WinSubject40095,
+ string? FlashEnergyTiffEp37387,
+ string? Flash37385,
+ string? IsoSpeedLatitudeYYY34868,
+ string? IsoSpeedLatitudeZZZ34869,
+ string? ExifVersion36864,
+ string? DateTimeOriginal36867,
+ string? DateTimeDigitized36868,
+ string? TimeZone36880,
+ string? TimeZoneOriginal36881,
+ string? TimeZoneDigitized36882,
+ string? FocalLength37386,
+ string? ComponentsConfiguration37121,
+ string? ShutterSpeed37377,
+ string? Aperture37378,
+ string? BrightnessValue37379,
+ string? ExposureBias37380,
+ string? MaxAperture37381,
+ string? SubjectDistance37382,
+ string? MeteringMode37383,
+ string? WhiteBalance37384,
+ string? CompressedAverageBitsPerPixel37122,
+ string? IsoSpeed34867,
+ string? FlashpixVersion40960,
+ string? ExifImageWidth40962,
+ string? Sharpness41994,
+ string? DeviceSettingDescription41995,
+ string? SubjectDistanceRange41996,
+ string? ImageUniqueId42016,
+ string? CameraOwnerName42032,
+ string? BodySerialNumber42033,
+ string? LensSpecification42034,
+ string? LensMake42035,
+ string? Saturation41993,
+ string? LensModel42036,
+ string? GdalMetadata42112,
+ string? GdalNoData42113,
+ string? Gamma42240,
+ string? PrintImageMatchingInfo50341,
+ string? PanasonicTitle50898,
+ string? PanasonicTitle250899,
+ string? Padding59932,
+ string? Lens65002,
+ string? LensSerialNumber42037,
+ string? ColorSpace40961,
+ string? Contrast41992,
+ string? SceneCaptureType41990,
+ string? ExifImageHeight40963,
+ string? RelatedSoundFile40964,
+ string? FlashEnergy41483,
+ string? SpatialFreqResponse41484,
+ string? FocalPlaneXResolution41486,
+ string? FocalPlaneYResolution41487,
+ string? FocalPlaneResolutionUnit41488,
+ string? SubjectLocation41492,
+ string? GainControl41991,
+ string? ExposureIndex41493,
+ string? FileSource41728,
+ string? SceneType41729,
+ string? CfaPattern41730,
+ string? CustomRendered41985,
+ string? ExposureMode41986,
+ string? WhiteBalanceMode41987,
+ string? DigitalZoomRatio41988,
+ string? Film35MMEquivFocalLength41989,
+ string? SensingMethod41495,
+ string? RecommendedExposureIndex34866,
+ string? StandardOutputSensitivity34865,
+ string? SensitivityType34864,
+ string? YResolution283,
+ string? PlanarConfiguration284,
+ string? PageName285,
+ string? ResolutionUnit296,
+ string? PageNumber297,
+ string? TransferFunction301,
+ string? Software305,
+ string? DateTime306,
+ string? XResolution282,
+ string? Artist315,
+ string? Predictor317,
+ string? WhitePoint318,
+ string? PrimaryChromaticities319,
+ string? TileWidth322,
+ string? TileLength323,
+ string? TileOffsets324,
+ string? TileByteCounts325,
+ string? SubIfdOffset330,
+ string? HostComputer316,
+ string? ExtraSamples338,
+ string? MaxSampleValue281,
+ string? StripByteCounts279,
+ string? InteropVersion2,
+ string? NewSubfileType254,
+ string? SubfileType255,
+ string? ImageWidth256,
+ string? ImageHeight257,
+ string? BitsPerSample258,
+ string? Compression259,
+ string? PhotometricInterpretation262,
+ string? MinSampleValue280,
+ string? Thresholding263,
+ string? DocumentName269,
+ string? ImageDescription270,
+ string? Make271,
+ string? Model272,
+ string? StripOffsets273,
+ string? Orientation274,
+ string? SamplesPerPixel277,
+ string? RowsPerStrip278,
+ string? FillOrder266,
+ string? SampleFormat339,
+ string? TransferRange342,
+ string? JpegTables347,
+ string? FNumber33437,
+ string? PixelScale33550,
+ string? IptcNaa33723,
+ string? ModelTiePoint33922,
+ string? PhotoshopSettings34377,
+ string? InterColorProfile34675,
+ string? GeoTiffGeoKeys34735,
+ string? GeoTiffGeoDoubleParams34736,
+ string? ExposureTime33434,
+ string? GeoTiffGeoAsciiParams34737,
+ string? SpectralSensitivity34852,
+ string? IsoEquivalent34855,
+ string? OptoElectricConversionFunction34856,
+ string? Interlace34857,
+ string? TimeZoneOffsetTiffEp34858,
+ string? SelfTimerModeTiffEp34859,
+ string? TimeZoneOffset34858,
+ string? SelfTimerMode34859,
+ string? ExposureProgram34850,
+ string? Copyright33432,
+ string? BatteryLevel33423,
+ string? CfaPattern233422,
+ string? JpegProc512,
+ string? JpegRestartInterval515,
+ string? JpegLosslessPredictors517,
+ string? JpegPointTransforms518,
+ string? JpegQTables519,
+ string? JpegDcTables520,
+ string? JpegAcTables521,
+ string? YCbCrCoefficients529,
+ string? YCbCrSubsampling530,
+ string? YCbCrPositioning531,
+ string? ReferenceBlackWhite532,
+ string? StripRowCounts559,
+ string? ApplicationNotes700,
+ string? RelatedImageFileFormat4096,
+ string? RelatedImageWidth4097,
+ string? RelatedImageHeight4098,
+ string? Rating18246,
+ string? RatingPercent18249,
+ string? CfaRepeatPatternDim33421)
+{
+
+ public override string ToString()
+ {
+ string result = JsonSerializer.Serialize(this, ExifSourceGenerationContext.Default.Exif);
+ return result;
+ }
+
+}
+
+[JsonSourceGenerationOptions(WriteIndented = true)]
+[JsonSerializable(typeof(Exif))]
+public partial class ExifSourceGenerationContext : JsonSerializerContext
+{
+}
\ No newline at end of file
diff --git a/Metadata/Models/QuickTimeMovieHeader.cs b/Metadata/Models/QuickTimeMovieHeader.cs
new file mode 100644
index 0000000..e63112e
--- /dev/null
+++ b/Metadata/Models/QuickTimeMovieHeader.cs
@@ -0,0 +1,36 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace View_by_Distance.Metadata.Models;
+
+ public record QuickTimeMovieHeader(string? Version1,
+ string? NextTrackId16,
+ string? CurrentTime15,
+ string? SelectionDuration14,
+ string? SelectionTime13,
+ string? PosterTime12,
+ string? PreviewDuration11,
+ string? PreviewTime10,
+ string? Matrix9,
+ string? PreferredVolume8,
+ string? PreferredRate7,
+ string? Duration6,
+ string? TimeScale5,
+ string? Modified4,
+ string? Created3,
+ string? Flags2)
+{
+
+ public override string ToString()
+ {
+ string result = JsonSerializer.Serialize(this, QuickTimeMovieHeaderSourceGenerationContext.Default.QuickTimeMovieHeader);
+ return result;
+ }
+
+}
+
+[JsonSourceGenerationOptions(WriteIndented = true)]
+[JsonSerializable(typeof(QuickTimeMovieHeader))]
+public partial class QuickTimeMovieHeaderSourceGenerationContext : JsonSerializerContext
+{
+}
\ No newline at end of file
diff --git a/Metadata/Models/QuickTimeTrackHeader.cs b/Metadata/Models/QuickTimeTrackHeader.cs
new file mode 100644
index 0000000..deff40f
--- /dev/null
+++ b/Metadata/Models/QuickTimeTrackHeader.cs
@@ -0,0 +1,33 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace View_by_Distance.Metadata.Models;
+
+ public record QuickTimeTrackHeader(string? Version1,
+ string? Flags2,
+ string? Created3,
+ string? Modified4,
+ string? TrackId5,
+ string? Duration6,
+ string? Layer7,
+ string? AlternateGroup8,
+ string? Volume9,
+ string? Width10,
+ string? Height11,
+ string? Matrix12,
+ string? Rotation13)
+{
+
+ public override string ToString()
+ {
+ string result = JsonSerializer.Serialize(this, QuickTimeTrackHeaderSourceGenerationContext.Default.QuickTimeTrackHeader);
+ return result;
+ }
+
+}
+
+[JsonSourceGenerationOptions(WriteIndented = true)]
+[JsonSerializable(typeof(QuickTimeTrackHeader))]
+public partial class QuickTimeTrackHeaderSourceGenerationContext : JsonSerializerContext
+{
+}
\ No newline at end of file
diff --git a/Metadata/Models/Stateless/SerilogExtensionMethods.cs b/Metadata/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 4126243..0000000
--- a/Metadata/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Metadata.Models.Stateless;
-
-internal static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Mirror-Length/Mirror-Length.csproj b/Mirror-Length/Mirror-Length.csproj
index d889638..88e6d75 100644
--- a/Mirror-Length/Mirror-Length.csproj
+++ b/Mirror-Length/Mirror-Length.csproj
@@ -39,10 +39,6 @@
-
-
-
-
diff --git a/Mirror-Length/MirrorLength.cs b/Mirror-Length/MirrorLength.cs
index 6414e81..ce7ccc5 100644
--- a/Mirror-Length/MirrorLength.cs
+++ b/Mirror-Length/MirrorLength.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using ShellProgressBar;
using View_by_Distance.Mirror.Length.Models;
using View_by_Distance.Shared.Models.Methods;
@@ -17,7 +17,7 @@ public class MirrorLength
private readonly IConfigurationRoot _ConfigurationRoot;
private readonly Property.Models.Configuration _PropertyConfiguration;
- public MirrorLength(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public MirrorLength(List args, ILogger logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
{
if (isSilent)
{ }
@@ -28,14 +28,13 @@ public class MirrorLength
long ticks = DateTime.Now.Ticks;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
- ILogger? log = Log.ForContext();
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
_PropertyConfiguration = propertyConfiguration;
_Configuration = configuration;
- log.Information(propertyConfiguration.RootDirectory);
+ logger?.LogInformation(propertyConfiguration.RootDirectory);
Verify();
- MirrorLengthFilesInDirectories(log, ticks);
+ MirrorLengthFilesInDirectories(logger, ticks);
}
private void Verify()
@@ -189,7 +188,7 @@ public class MirrorLength
}
}
- private void MirrorLengthFilesInDirectories(ILogger log, long ticks)
+ private void MirrorLengthFilesInDirectories(ILogger? logger, long ticks)
{
string message = nameof(MirrorLength);
List<(string, string, int)> collectionForMarkDown;
diff --git a/Mirror-Length/Models/Stateless/SerilogExtensionMethods.cs b/Mirror-Length/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index e0fb89d..0000000
--- a/Mirror-Length/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Mirror.Length.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Mirror-Length/Program.cs b/Mirror-Length/Program.cs
index c4f4a82..25068b7 100644
--- a/Mirror-Length/Program.cs
+++ b/Mirror-Length/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Mirror.Length.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Mirror.Length;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -30,9 +31,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -41,31 +39,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- _ = new MirrorLength(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ _ = new MirrorLength(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Move-By-Id/Models/Stateless/SerilogExtensionMethods.cs b/Move-By-Id/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 386b1fd..0000000
--- a/Move-By-Id/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Move.By.Id.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Move-By-Id/Move-By-Id.csproj b/Move-By-Id/Move-By-Id.csproj
index 0be2614..f8ca9a7 100644
--- a/Move-By-Id/Move-By-Id.csproj
+++ b/Move-By-Id/Move-By-Id.csproj
@@ -39,10 +39,6 @@
-
-
-
-
diff --git a/Move-By-Id/MoveById.cs b/Move-By-Id/MoveById.cs
index 606dcb7..121de4d 100644
--- a/Move-By-Id/MoveById.cs
+++ b/Move-By-Id/MoveById.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using ShellProgressBar;
using System.Text;
using View_by_Distance.Move.By.Id.Models;
@@ -20,7 +20,7 @@ public class MoveById
private readonly IConfigurationRoot _ConfigurationRoot;
private readonly Property.Models.Configuration _PropertyConfiguration;
- public MoveById(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public MoveById(List args, ILogger logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
{
if (isSilent)
{ }
@@ -30,7 +30,6 @@ public class MoveById
_IsEnvironment = isEnvironment;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
- ILogger? log = Log.ForContext();
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
_PropertyConfiguration = propertyConfiguration;
@@ -39,7 +38,7 @@ public class MoveById
string? comparePathRoot = Path.GetDirectoryName(appSettings.ComparePathsFile);
if (comparePathRoot is null || comparePathRoot == propertyConfiguration.RootDirectory)
throw new Exception("Nested isn't allowed!");
- log.Information(propertyConfiguration.RootDirectory);
+ logger?.LogInformation(propertyConfiguration.RootDirectory);
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
Verify();
string json = File.ReadAllText(appSettings.ComparePathsFile);
diff --git a/Move-By-Id/Program.cs b/Move-By-Id/Program.cs
index f44c417..e18c983 100644
--- a/Move-By-Id/Program.cs
+++ b/Move-By-Id/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Move.By.Id.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Move.By.Id;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -28,9 +29,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -39,31 +37,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- _ = new MoveById(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ _ = new MoveById(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Offset-Date-Time-Original/Models/Stateless/SerilogExtensionMethods.cs b/Offset-Date-Time-Original/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 65edf24..0000000
--- a/Offset-Date-Time-Original/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Offset.Date.Time.Original.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Offset-Date-Time-Original/Offset-Date-Time-Original.csproj b/Offset-Date-Time-Original/Offset-Date-Time-Original.csproj
index 6206b71..a936b3e 100644
--- a/Offset-Date-Time-Original/Offset-Date-Time-Original.csproj
+++ b/Offset-Date-Time-Original/Offset-Date-Time-Original.csproj
@@ -39,10 +39,6 @@
-
-
-
-
diff --git a/Offset-Date-Time-Original/OffsetDateTimeOriginal.cs b/Offset-Date-Time-Original/OffsetDateTimeOriginal.cs
index 75592ca..b3291cb 100644
--- a/Offset-Date-Time-Original/OffsetDateTimeOriginal.cs
+++ b/Offset-Date-Time-Original/OffsetDateTimeOriginal.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using ShellProgressBar;
using System.Drawing;
using System.Drawing.Imaging;
@@ -30,7 +30,7 @@ public class OffsetDateTimeOriginal
private readonly IConfigurationRoot _ConfigurationRoot;
private readonly Property.Models.Configuration _PropertyConfiguration;
- public OffsetDateTimeOriginal(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public OffsetDateTimeOriginal(List args, ILogger logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
{
if (isSilent)
{ }
@@ -40,14 +40,13 @@ public class OffsetDateTimeOriginal
_IsEnvironment = isEnvironment;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
- ILogger? log = Log.ForContext();
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
_PropertyConfiguration = propertyConfiguration;
_Configuration = configuration;
- log.Information(propertyConfiguration.RootDirectory);
+ logger?.LogInformation(propertyConfiguration.RootDirectory);
Verify();
- List lines = OffsetDateTimeOriginalFilesInDirectories(log);
+ List lines = OffsetDateTimeOriginalFilesInDirectories(logger);
if (lines.Any())
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
}
@@ -154,7 +153,7 @@ public class OffsetDateTimeOriginal
#pragma warning restore CA1416
- private void DateFix(ILogger log, string sourceDirectory)
+ private void DateFix(ILogger? logger, string sourceDirectory)
{
string checkDirectory;
ASCIIEncoding asciiEncoding = new();
@@ -166,14 +165,14 @@ public class OffsetDateTimeOriginal
{
checkDirectory = Path.Combine(sourceDirectory, "1");
if (!Directory.Exists(checkDirectory))
- log.Error($"<{checkDirectory}> doesn't exist!");
+ logger?.LogError($"<{checkDirectory}> doesn't exist!");
else
{
string badDirectory = Path.Combine(sourceDirectory, "Bad");
string targetDirectory = Path.Combine(sourceDirectory, "Target");
string[] minimumDirectory = Directory.GetDirectories(targetDirectory, "*", SearchOption.TopDirectoryOnly);
if (minimumDirectory.Length != 1)
- log.Error($"<{checkDirectory}> doesn't exist!");
+ logger?.LogError($"<{checkDirectory}> doesn't exist!");
else
{
string format = "yyyy-MM-dd";
@@ -181,7 +180,7 @@ public class OffsetDateTimeOriginal
string[] badFiles = !Directory.Exists(badDirectory) ? Array.Empty() : Directory.GetFiles(badDirectory, "*", SearchOption.TopDirectoryOnly);
string[] targetFiles = !Directory.Exists(targetDirectory) ? Array.Empty() : Directory.GetFiles(targetDirectory, "*", SearchOption.TopDirectoryOnly);
if (badFiles.Length != 1 || targetFiles.Length != 1 || maximumDirectory.Length != 1)
- log.Error("bad file(s) or target file(s) or maximum directory doesn't equal 1!");
+ logger?.LogError("bad file(s) or target file(s) or maximum directory doesn't equal 1!");
else
{
int? badId;
@@ -213,7 +212,7 @@ public class OffsetDateTimeOriginal
if (!targetDateTimes.Any() || targetId is null)
throw new Exception(targetMessage);
if (badDateTimeOriginal is null || targetDateTimeOriginal is null)
- log.Error("Date is null!");
+ logger?.LogError("Date is null!");
else
{
TimeSpan timeSpan = new(targetDateTimeOriginal.Value.Ticks - badDateTimeOriginal.Value.Ticks);
@@ -225,10 +224,10 @@ public class OffsetDateTimeOriginal
}
}
- private List OffsetDateTimeOriginalFilesInDirectories(ILogger log)
+ private List OffsetDateTimeOriginalFilesInDirectories(ILogger? logger)
{
List results = new();
- DateFix(log, _PropertyConfiguration.RootDirectory);
+ DateFix(logger, _PropertyConfiguration.RootDirectory);
return results;
}
diff --git a/Offset-Date-Time-Original/Program.cs b/Offset-Date-Time-Original/Program.cs
index 1af8284..ca30c5d 100644
--- a/Offset-Date-Time-Original/Program.cs
+++ b/Offset-Date-Time-Original/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Offset.Date.Time.Original.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Offset.Date.Time.Original;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -30,9 +31,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -41,31 +39,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- _ = new OffsetDateTimeOriginal(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ _ = new OffsetDateTimeOriginal(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/PhotoPrism/Models/Stateless/SerilogExtensionMethods.cs b/PhotoPrism/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 4693dcc..0000000
--- a/PhotoPrism/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.PhotoPrism.Models.Stateless;
-
-internal static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/PhotoPrism/PhotoPrism.csproj b/PhotoPrism/PhotoPrism.csproj
index 4c543c3..6669c96 100644
--- a/PhotoPrism/PhotoPrism.csproj
+++ b/PhotoPrism/PhotoPrism.csproj
@@ -35,7 +35,6 @@
-
diff --git a/PrepareForOld/Models/Stateless/SerilogExtensionMethods.cs b/PrepareForOld/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 29639e5..0000000
--- a/PrepareForOld/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.PrepareForOld.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/PrepareForOld/PrepareForOld.csproj b/PrepareForOld/PrepareForOld.csproj
index 04f07a6..604f8c1 100644
--- a/PrepareForOld/PrepareForOld.csproj
+++ b/PrepareForOld/PrepareForOld.csproj
@@ -35,10 +35,6 @@
-
-
-
-
diff --git a/PrepareForOld/Program.cs b/PrepareForOld/Program.cs
index 3f045f5..cbaf3e5 100644
--- a/PrepareForOld/Program.cs
+++ b/PrepareForOld/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.PrepareForOld.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.PrepareForOld;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -30,9 +31,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -43,27 +41,24 @@ public class Program
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Property-Compare/Models/Stateless/SerilogExtensionMethods.cs b/Property-Compare/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 955e16b..0000000
--- a/Property-Compare/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.PropertyCompare.Models.Stateless;
-
-internal static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Property-Compare/Property-Compare.csproj b/Property-Compare/Property-Compare.csproj
index 1886282..fdbe938 100644
--- a/Property-Compare/Property-Compare.csproj
+++ b/Property-Compare/Property-Compare.csproj
@@ -34,7 +34,6 @@
-
diff --git a/Property/Models/A_Property.cs b/Property/Models/A_Property.cs
index 22c52ad..5ff85f2 100644
--- a/Property/Models/A_Property.cs
+++ b/Property/Models/A_Property.cs
@@ -15,7 +15,6 @@ public class A_Property
public bool Reverse { get; }
public List ExceptionsDirectories => _ExceptionsDirectories;
- private readonly Serilog.ILogger? _Log;
private readonly string _OutputExtension;
private readonly int _MaxDegreeOfParallelism;
private readonly ASCIIEncoding _ASCIIEncoding;
@@ -31,7 +30,6 @@ public class A_Property
_OutputExtension = outputExtension;
_ASCIIEncoding = new ASCIIEncoding();
_Configuration = propertyConfiguration;
- _Log = Serilog.Log.ForContext();
_AngleBracketCollection = new List();
_PropertyConfiguration = propertyConfiguration;
_MaxDegreeOfParallelism = maxDegreeOfParallelism;
@@ -44,17 +42,6 @@ public class A_Property
return result;
}
- private long LogDelta(long ticks, string? methodName)
- {
- long result;
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
- double delta = new TimeSpan(DateTime.Now.Ticks - ticks).TotalMilliseconds;
- _Log.Debug($"{methodName} took {Math.Floor(delta)} millisecond(s)");
- result = DateTime.Now.Ticks;
- return result;
- }
-
private Shared.Models.Property GetImageProperty(Shared.Models.Methods.IMetadata metadata, Item item, List> sourceDirectoryFileTuples, List parseExceptions, bool isIgnoreExtension)
{
Shared.Models.Property? result;
@@ -252,8 +239,6 @@ public class A_Property
public void SavePropertyParallelWork(long ticks, Shared.Models.Methods.IMetadata metadata, int t, Container[] containers)
{
- if (_Log is null)
- throw new NullReferenceException(nameof(_Log));
int total = 0;
string message;
int totalSeconds;
@@ -277,22 +262,10 @@ public class A_Property
totalSeconds = (int)Math.Truncate(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
message = $"{i + 1:000} [{container.Items.Count:000}] / {containersLength:000} - {total} / {t} total - {totalSeconds} total second(s) - {outputResolution} - {container.SourceDirectory}";
SavePropertyParallelWork(_MaxDegreeOfParallelism, metadata, exceptions, sourceDirectoryChanges, container, container.Items, message);
- foreach (Exception exception in exceptions)
- _Log.Error(string.Concat(container.SourceDirectory, Environment.NewLine, exception.Message, Environment.NewLine, exception.StackTrace), exception);
if (exceptions.Count == container.Items.Count)
throw new Exception(string.Concat("All in [", container.SourceDirectory, "]failed!"));
if (exceptions.Count != 0)
_ExceptionsDirectories.Add(container.SourceDirectory);
- if (Directory.GetFiles(propertyRoot, "*.txt", SearchOption.TopDirectoryOnly).Any())
- {
- for (int y = 0; y < int.MaxValue; y++)
- {
- _Log.Information("Press \"Y\" key when ready to continue or close console");
- if (System.Console.ReadKey().Key == ConsoleKey.Y)
- break;
- }
- _Log.Information(". . .");
- }
total += container.Items.Count;
}
}
diff --git a/Property/Models/Stateless/SerilogExtensionMethods.cs b/Property/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 1b1fd86..0000000
--- a/Property/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Property.Models.Stateless;
-
-internal static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Property/Property.csproj b/Property/Property.csproj
index 7fe9599..dc6e2a4 100644
--- a/Property/Property.csproj
+++ b/Property/Property.csproj
@@ -40,9 +40,8 @@
+
-
-
diff --git a/Rename/Models/Stateless/SerilogExtensionMethods.cs b/Rename/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 1d99b9e..0000000
--- a/Rename/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Rename.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Rename/Program.cs b/Rename/Program.cs
index 4986a87..91ed222 100644
--- a/Rename/Program.cs
+++ b/Rename/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Rename.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Rename;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -28,9 +29,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -39,31 +37,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- _ = new Rename(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ _ = new Rename(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Rename/Rename.cs b/Rename/Rename.cs
index fd0d7f6..112aa95 100644
--- a/Rename/Rename.cs
+++ b/Rename/Rename.cs
@@ -1,7 +1,7 @@
using CliWrap;
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using ShellProgressBar;
using System.Text;
using View_by_Distance.Metadata.Models;
@@ -31,7 +31,7 @@ public class Rename
private readonly IConfigurationRoot _ConfigurationRoot;
private readonly Property.Models.Configuration _PropertyConfiguration;
- public Rename(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public Rename(List args, ILogger? logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
{
if (isSilent)
{ }
@@ -41,15 +41,14 @@ public class Rename
_IsEnvironment = isEnvironment;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
- ILogger? log = Log.ForContext();
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
_PropertyConfiguration = propertyConfiguration;
_Configuration = configuration;
- log.Information(propertyConfiguration.RootDirectory);
+ logger?.LogInformation(propertyConfiguration.RootDirectory);
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
Verify();
- List lines = RenameFilesInDirectories(log);
+ List lines = RenameFilesInDirectories(logger);
if (lines.Any())
{
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
@@ -73,7 +72,7 @@ public class Rename
throw new NullReferenceException(nameof(_PropertyConfiguration));
}
- private List RenameFilesInDirectories(ILogger log)
+ private List RenameFilesInDirectories(ILogger? logger)
{
List results = new();
string message;
@@ -159,24 +158,24 @@ public class Rename
File.WriteAllText($"{to}.paddedId", $"{to}{Environment.NewLine}{fileHolder.FullName}");
}
ConsoleKey? consoleKey = null;
- log.Information($"Ready to Move {verifiedToDoCollection.Count} files[i](s)?");
+ logger?.LogInformation($"Ready to Move {verifiedToDoCollection.Count} files[i](s)?");
for (int y = 0; y < int.MaxValue; y++)
{
- log.Information("Press \"Y\" key to move files[i](s), \"N\" key to log files[i](s) or close console to not move files");
+ logger?.LogInformation("Press \"Y\" key to move files[i](s), \"N\" key to log files[i](s) or close console to not move files");
consoleKey = System.Console.ReadKey().Key;
if (consoleKey is ConsoleKey.Y or ConsoleKey.N)
break;
}
- log.Information(". . .");
+ logger?.LogInformation(". . .");
if (consoleKey is null || consoleKey.Value != ConsoleKey.Y)
- log.Information("Nothing moved!");
+ logger?.LogInformation("Nothing moved!");
else
{
message = ") Renaming files";
progressBar = new(count, message, options);
results.AddRange(Move(progressBar, verifiedToDoCollection));
progressBar.Dispose();
- log.Information("Done Moving");
+ logger?.LogInformation("Done Moving");
}
return results;
}
diff --git a/Rename/Rename.csproj b/Rename/Rename.csproj
index 874bcdd..ba571bf 100644
--- a/Rename/Rename.csproj
+++ b/Rename/Rename.csproj
@@ -40,10 +40,6 @@
-
-
-
-
diff --git a/Resize/Models/Stateless/SerilogExtensionMethods.cs b/Resize/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index 1e775eb..0000000
--- a/Resize/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Resize.Models.Stateless;
-
-internal static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Resize/Resize.csproj b/Resize/Resize.csproj
index 45013d1..bc187ce 100644
--- a/Resize/Resize.csproj
+++ b/Resize/Resize.csproj
@@ -33,7 +33,6 @@
-
diff --git a/Set-Created-Date/Models/Stateless/SerilogExtensionMethods.cs b/Set-Created-Date/Models/Stateless/SerilogExtensionMethods.cs
deleted file mode 100644
index c346274..0000000
--- a/Set-Created-Date/Models/Stateless/SerilogExtensionMethods.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace View_by_Distance.Set.Created.Date.Models.Stateless;
-
-public static class SerilogExtensionMethods
-{
-
- internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
-
- internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
-
-}
\ No newline at end of file
diff --git a/Set-Created-Date/Program.cs b/Set-Created-Date/Program.cs
index 73764a2..f9b3ec4 100644
--- a/Set-Created-Date/Program.cs
+++ b/Set-Created-Date/Program.cs
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Set.Created.Date.Models;
@@ -11,9 +13,8 @@ namespace View_by_Distance.Set.Created.Date;
public class Program
{
- public static void Secondary(List args)
+ public static void Secondary(ILogger logger, List args)
{
- LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
@@ -30,9 +31,6 @@ public class Program
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
- _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
- Log.Logger = loggerConfiguration.CreateLogger();
- ILogger log = Log.ForContext();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
@@ -41,31 +39,28 @@ public class Program
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
- _ = new SetCreatedDate(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
+ _ = new SetCreatedDate(args, logger, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
- log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
- }
- finally
- {
- Log.CloseAndFlush();
+ logger?.LogError(ex, "Error!");
}
if (silentIndex > -1)
- log.Debug("Done. Bye");
+ logger?.LogDebug("Done. Bye");
else
{
- log.Debug("Done. Press 'Enter' to end");
+ logger?.LogDebug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
+ ILogger? logger = Host.CreateDefaultBuilder(args).Build().Services.GetRequiredService>();
if (args is not null)
- Secondary(args.ToList());
+ Secondary(logger, args.ToList());
else
- Secondary(new List());
+ Secondary(logger, new List());
}
}
\ No newline at end of file
diff --git a/Set-Created-Date/Set-Created-Date.csproj b/Set-Created-Date/Set-Created-Date.csproj
index 300cdd6..b5f7af4 100644
--- a/Set-Created-Date/Set-Created-Date.csproj
+++ b/Set-Created-Date/Set-Created-Date.csproj
@@ -39,10 +39,6 @@
-
-
-
-
diff --git a/Set-Created-Date/SetCreatedDate.cs b/Set-Created-Date/SetCreatedDate.cs
index 290296e..ea056f8 100644
--- a/Set-Created-Date/SetCreatedDate.cs
+++ b/Set-Created-Date/SetCreatedDate.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
using Phares.Shared;
-using Serilog;
using ShellProgressBar;
using System.Text;
using View_by_Distance.Metadata.Models;
@@ -23,7 +23,7 @@ public class SetCreatedDate
private readonly IReadOnlyDictionary _FileGroups;
private readonly Property.Models.Configuration _PropertyConfiguration;
- public SetCreatedDate(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
+ public SetCreatedDate(List args, ILogger logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
{
if (isSilent)
{ }
@@ -33,16 +33,15 @@ public class SetCreatedDate
_IsEnvironment = isEnvironment;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
- ILogger? log = Log.ForContext();
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
string[] directories = new string[] { propertyConfiguration.ResultContent };
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, appSettings.CopyTo, directories);
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
_PropertyConfiguration = propertyConfiguration;
_Configuration = configuration;
- log.Information(propertyConfiguration.RootDirectory);
+ logger?.LogInformation(propertyConfiguration.RootDirectory);
Verify();
- List lines = SetCreatedDateFilesInDirectories(log);
+ List lines = SetCreatedDateFilesInDirectories(logger);
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
if (lines.Count == 0)
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(propertyConfiguration.RootDirectory);
@@ -139,7 +138,7 @@ public class SetCreatedDate
return results;
}
- private List SetCreatedDateFilesInDirectories(ILogger log)
+ private List SetCreatedDateFilesInDirectories(ILogger? logger)
{
List results = new();
ProgressBar progressBar;
@@ -154,23 +153,23 @@ public class SetCreatedDate
progressBar = new(count, message, options);
List toDoCollection = GetToDoCollection(progressBar, filesCollection);
progressBar.Dispose();
- log.Information($"Ready to set created date {toDoCollection.Count} file(s)?");
+ logger?.LogInformation($"Ready to set created date {toDoCollection.Count} file(s)?");
for (int y = 0; y < int.MaxValue; y++)
{
- log.Information("Press \"Y\" key to set created date file(s), \"N\" key to log file(s) or close console to not set created date files");
+ logger?.LogInformation("Press \"Y\" key to set created date file(s), \"N\" key to log file(s) or close console to not set created date files");
consoleKey = System.Console.ReadKey().Key;
if (consoleKey is ConsoleKey.Y or ConsoleKey.N)
break;
}
- log.Information(". . .");
+ logger?.LogInformation(". . .");
if (consoleKey is null || consoleKey.Value != ConsoleKey.Y)
- log.Information("Nothing set!");
+ logger?.LogInformation("Nothing set!");
else
{
progressBar = new(count, message, options);
results.AddRange(SetCreatedDateForeach(progressBar, toDoCollection));
progressBar.Dispose();
- log.Information("Done setting created date");
+ logger?.LogInformation("Done setting created date");
}
return results;
}
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index 89e52af..528cf27 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -35,10 +35,6 @@
-
-
-
-
diff --git a/Tests/UnitTestCalculations.cs b/Tests/UnitTestCalculations.cs
index 6a856a5..53d0212 100644
--- a/Tests/UnitTestCalculations.cs
+++ b/Tests/UnitTestCalculations.cs
@@ -2,7 +2,6 @@ using Humanizer;
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
@@ -16,7 +15,6 @@ namespace View_by_Distance.Tests;
public partial class UnitTestCalculations
{
- private readonly ILogger _Logger;
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly Configuration _Configuration;
@@ -26,13 +24,11 @@ public partial class UnitTestCalculations
public UnitTestCalculations()
{
- ILogger logger;
AppSettings appSettings;
string workingDirectory;
Configuration configuration;
IsEnvironment isEnvironment;
IConfigurationRoot configurationRoot;
- LoggerConfiguration loggerConfiguration = new();
Property.Models.Configuration propertyConfiguration;
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
@@ -46,13 +42,8 @@ public partial class UnitTestCalculations
throw new Exception("Working directory name must have a value!");
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();
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
- logger.Information("Complete");
- _Logger = logger;
_AppSettings = appSettings;
_Configuration = configuration;
_IsEnvironment = isEnvironment;
@@ -71,7 +62,6 @@ public partial class UnitTestCalculations
[TestMethod]
public void TestMethodNull()
{
- Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_Configuration is null);
Assert.IsFalse(_IsEnvironment is null);
diff --git a/Tests/UnitTestExample.cs b/Tests/UnitTestExample.cs
index d62ce04..fb412c0 100644
--- a/Tests/UnitTestExample.cs
+++ b/Tests/UnitTestExample.cs
@@ -1,7 +1,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Shared.Models.Stateless.Methods;
@@ -13,7 +12,6 @@ namespace View_by_Distance.Tests;
public class UnitTestExample
{
- private readonly ILogger _Logger;
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly Configuration _Configuration;
@@ -23,13 +21,11 @@ public class UnitTestExample
public UnitTestExample()
{
- ILogger logger;
AppSettings appSettings;
string workingDirectory;
Configuration configuration;
IsEnvironment isEnvironment;
IConfigurationRoot configurationRoot;
- LoggerConfiguration loggerConfiguration = new();
Property.Models.Configuration propertyConfiguration;
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
@@ -43,13 +39,8 @@ public class UnitTestExample
throw new Exception("Working directory name must have a value!");
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();
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
- logger.Information("Complete");
- _Logger = logger;
_AppSettings = appSettings;
_Configuration = configuration;
_IsEnvironment = isEnvironment;
@@ -61,7 +52,6 @@ public class UnitTestExample
[TestMethod]
public void TestMethodNull()
{
- Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_Configuration is null);
Assert.IsFalse(_IsEnvironment is null);
diff --git a/Tests/UnitTestHardCoded.cs b/Tests/UnitTestHardCoded.cs
index 76bb18b..7e73446 100644
--- a/Tests/UnitTestHardCoded.cs
+++ b/Tests/UnitTestHardCoded.cs
@@ -1,7 +1,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
@@ -15,7 +14,6 @@ namespace View_by_Distance.Tests;
public partial class UnitTestHardCoded
{
- private readonly ILogger _Logger;
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly Configuration _Configuration;
@@ -25,13 +23,11 @@ public partial class UnitTestHardCoded
public UnitTestHardCoded()
{
- ILogger logger;
AppSettings appSettings;
string workingDirectory;
Configuration configuration;
IsEnvironment isEnvironment;
IConfigurationRoot configurationRoot;
- LoggerConfiguration loggerConfiguration = new();
Property.Models.Configuration propertyConfiguration;
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
@@ -45,13 +41,8 @@ public partial class UnitTestHardCoded
throw new Exception("Working directory name must have a value!");
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();
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
- logger.Information("Complete");
- _Logger = logger;
_AppSettings = appSettings;
_Configuration = configuration;
_IsEnvironment = isEnvironment;
@@ -70,7 +61,6 @@ public partial class UnitTestHardCoded
[TestMethod]
public void TestMethodNull()
{
- Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_Configuration is null);
Assert.IsFalse(_IsEnvironment is null);
diff --git a/Tests/UnitTestResize.cs b/Tests/UnitTestResize.cs
index 62298e9..9904fc9 100644
--- a/Tests/UnitTestResize.cs
+++ b/Tests/UnitTestResize.cs
@@ -1,7 +1,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Phares.Shared;
-using Serilog;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing.Imaging;
@@ -20,7 +19,6 @@ namespace View_by_Distance.Tests;
public class UnitTestResize
{
- private readonly ILogger _Logger;
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly IsEnvironment _IsEnvironment;
@@ -30,13 +28,11 @@ public class UnitTestResize
public UnitTestResize()
{
- ILogger logger;
AppSettings appSettings;
string workingDirectory;
IsEnvironment isEnvironment;
Models.Configuration configuration;
IConfigurationRoot configurationRoot;
- LoggerConfiguration loggerConfiguration = new();
Property.Models.Configuration propertyConfiguration;
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
@@ -50,14 +46,9 @@ public class UnitTestResize
throw new Exception("Working directory name must have a value!");
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();
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
- logger.Information("Complete");
- _Logger = logger;
_AppSettings = appSettings;
_Configuration = configuration;
_IsEnvironment = isEnvironment;
@@ -76,7 +67,6 @@ public class UnitTestResize
[TestMethod]
public void TestMethodNull()
{
- Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_Configuration is null);
Assert.IsFalse(_IsEnvironment is null);
@@ -154,7 +144,6 @@ public class UnitTestResize
(string cResultsFullGroupDirectory, _, _) = GetResultsFullGroupDirectories(outputResolution);
(string aResultsFullGroupDirectory, string bResultsFullGroupDirectory) = GetResultsFullGroupDirectories();
Shared.Models.Methods.IBlurHasher blurHasher = new BlurHash.Models.C2_BlurHasher(_PropertyConfiguration);
- _Logger.Information(_Configuration.ModelDirectory);
A_Property propertyLogic = GetPropertyLogic(reverse, aResultsFullGroupDirectory);
string aPropertySingletonDirectory = Path.Combine(aResultsFullGroupDirectory, "{}");
if (!Directory.Exists(aPropertySingletonDirectory))
diff --git a/TestsWithFaceRecognitionDotNet/TestsWithFaceRecognitionDotNet.csproj b/TestsWithFaceRecognitionDotNet/TestsWithFaceRecognitionDotNet.csproj
index f3fce2e..1452761 100644
--- a/TestsWithFaceRecognitionDotNet/TestsWithFaceRecognitionDotNet.csproj
+++ b/TestsWithFaceRecognitionDotNet/TestsWithFaceRecognitionDotNet.csproj
@@ -34,10 +34,6 @@
-
-
-
-
diff --git a/TestsWithFaceRecognitionDotNet/UnitTestExample.cs b/TestsWithFaceRecognitionDotNet/UnitTestExample.cs
index d62ce04..fb412c0 100644
--- a/TestsWithFaceRecognitionDotNet/UnitTestExample.cs
+++ b/TestsWithFaceRecognitionDotNet/UnitTestExample.cs
@@ -1,7 +1,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Phares.Shared;
-using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Shared.Models.Stateless.Methods;
@@ -13,7 +12,6 @@ namespace View_by_Distance.Tests;
public class UnitTestExample
{
- private readonly ILogger _Logger;
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly Configuration _Configuration;
@@ -23,13 +21,11 @@ public class UnitTestExample
public UnitTestExample()
{
- ILogger logger;
AppSettings appSettings;
string workingDirectory;
Configuration configuration;
IsEnvironment isEnvironment;
IConfigurationRoot configurationRoot;
- LoggerConfiguration loggerConfiguration = new();
Property.Models.Configuration propertyConfiguration;
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
@@ -43,13 +39,8 @@ public class UnitTestExample
throw new Exception("Working directory name must have a value!");
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();
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
- logger.Information("Complete");
- _Logger = logger;
_AppSettings = appSettings;
_Configuration = configuration;
_IsEnvironment = isEnvironment;
@@ -61,7 +52,6 @@ public class UnitTestExample
[TestMethod]
public void TestMethodNull()
{
- Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_Configuration is null);
Assert.IsFalse(_IsEnvironment is null);
diff --git a/TestsWithFaceRecognitionDotNet/UnitTestFace.cs b/TestsWithFaceRecognitionDotNet/UnitTestFace.cs
index a0fee3f..0b54df9 100644
--- a/TestsWithFaceRecognitionDotNet/UnitTestFace.cs
+++ b/TestsWithFaceRecognitionDotNet/UnitTestFace.cs
@@ -1,7 +1,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Phares.Shared;
-using Serilog;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing.Imaging;
@@ -22,7 +21,6 @@ namespace View_by_Distance.Tests;
public class UnitTestFace
{
- private readonly ILogger _Logger;
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly IsEnvironment _IsEnvironment;
@@ -32,13 +30,11 @@ public class UnitTestFace
public UnitTestFace()
{
- ILogger logger;
AppSettings appSettings;
string workingDirectory;
IsEnvironment isEnvironment;
Models.Configuration configuration;
IConfigurationRoot configurationRoot;
- LoggerConfiguration loggerConfiguration = new();
Property.Models.Configuration propertyConfiguration;
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
@@ -52,14 +48,9 @@ public class UnitTestFace
throw new Exception("Working directory name must have a value!");
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();
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
- logger.Information("Complete");
- _Logger = logger;
_AppSettings = appSettings;
_Configuration = configuration;
_IsEnvironment = isEnvironment;
@@ -88,7 +79,6 @@ public class UnitTestFace
[TestMethod]
public void TestMethodNull()
{
- Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_Configuration is null);
Assert.IsFalse(_IsEnvironment is null);
@@ -227,7 +217,6 @@ public class UnitTestFace
(string cResultsFullGroupDirectory, _, _) = GetResultsFullGroupDirectories(outputResolution);
(string aResultsFullGroupDirectory, string bResultsFullGroupDirectory) = GetResultsFullGroupDirectories();
Shared.Models.Methods.IBlurHasher blurHasher = new BlurHash.Models.C2_BlurHasher(_PropertyConfiguration);
- _Logger.Information(_Configuration.ModelDirectory);
A_Property propertyLogic = GetPropertyLogic(reverse, aResultsFullGroupDirectory);
string aPropertySingletonDirectory = Path.Combine(aResultsFullGroupDirectory, "{}");
if (!Directory.Exists(aPropertySingletonDirectory))
diff --git a/ThumbHash/ThumbHash.csproj b/ThumbHash/ThumbHash.csproj
index b80e884..6cda5ad 100644
--- a/ThumbHash/ThumbHash.csproj
+++ b/ThumbHash/ThumbHash.csproj
@@ -33,7 +33,6 @@
-