mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Wire up source for logging where possible
This commit is contained in:
@@ -50,7 +50,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore, XmlIgnore]
|
[JsonIgnore, XmlIgnore]
|
||||||
protected Logger logger = new Logger();
|
protected Logger logger;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -62,6 +62,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// <param name="datFile">DatFile to get the values from</param>
|
/// <param name="datFile">DatFile to get the values from</param>
|
||||||
public DatFile(DatFile datFile)
|
public DatFile(DatFile datFile)
|
||||||
{
|
{
|
||||||
|
logger = new Logger(this);
|
||||||
if (datFile != null)
|
if (datFile != null)
|
||||||
{
|
{
|
||||||
Header = datFile.Header;
|
Header = datFile.Header;
|
||||||
|
|||||||
@@ -49,7 +49,12 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly static Logger logger = new Logger();
|
private Logger logger;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Static logger for static methods
|
||||||
|
/// </summary>
|
||||||
|
private static Logger staticLogger = new Logger();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -952,6 +957,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
bucketedBy = Field.NULL;
|
bucketedBy = Field.NULL;
|
||||||
mergedBy = DedupeType.None;
|
mergedBy = DedupeType.None;
|
||||||
items = new ConcurrentDictionary<string, List<DatItem>>();
|
items = new ConcurrentDictionary<string, List<DatItem>>();
|
||||||
|
logger = new Logger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -1417,13 +1423,13 @@ namespace SabreTools.Library.DatFiles
|
|||||||
dirStats.ResetStatistics();
|
dirStats.ResetStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Verbose($"Beginning stat collection for '{file.CurrentPath}'");
|
staticLogger.Verbose($"Beginning stat collection for '{file.CurrentPath}'");
|
||||||
List<string> games = new List<string>();
|
List<string> games = new List<string>();
|
||||||
DatFile datdata = DatFile.CreateAndParse(file.CurrentPath);
|
DatFile datdata = DatFile.CreateAndParse(file.CurrentPath);
|
||||||
datdata.Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: true);
|
datdata.Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: true);
|
||||||
|
|
||||||
// Output single DAT stats (if asked)
|
// Output single DAT stats (if asked)
|
||||||
logger.User($"Adding stats for file '{file.CurrentPath}'\n");
|
staticLogger.User($"Adding stats for file '{file.CurrentPath}'\n");
|
||||||
if (single)
|
if (single)
|
||||||
{
|
{
|
||||||
reports.ForEach(report => report.ReplaceStatistics(datdata.Header.FileName, datdata.Items.Keys.Count, datdata.Items));
|
reports.ForEach(report => report.ReplaceStatistics(datdata.Header.FileName, datdata.Items.Keys.Count, datdata.Items));
|
||||||
@@ -1467,7 +1473,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Output footer if needed
|
// Output footer if needed
|
||||||
reports.ForEach(report => report.WriteFooter());
|
reports.ForEach(report => report.WriteFooter());
|
||||||
|
|
||||||
logger.User($"{Environment.NewLine}Please check the log folder if the stats scrolled offscreen");
|
staticLogger.User($"{Environment.NewLine}Please check the log folder if the stats scrolled offscreen");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -380,7 +380,13 @@ namespace SabreTools.Library.DatItems
|
|||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore, XmlIgnore]
|
[JsonIgnore, XmlIgnore]
|
||||||
protected static Logger logger = new Logger();
|
protected Logger logger;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Static logger for static methods
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore, XmlIgnore]
|
||||||
|
protected static Logger staticLogger = new Logger();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -414,6 +420,14 @@ namespace SabreTools.Library.DatItems
|
|||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public DatItem()
|
||||||
|
{
|
||||||
|
logger = new Logger(this);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a specific type of DatItem to be used based on an ItemType
|
/// Create a specific type of DatItem to be used based on an ItemType
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1027,14 +1041,14 @@ namespace SabreTools.Library.DatItems
|
|||||||
// If the current item exactly matches the last item, then we don't add it
|
// If the current item exactly matches the last item, then we don't add it
|
||||||
if (datItem.GetDuplicateStatus(lastItem).HasFlag(DupeType.All))
|
if (datItem.GetDuplicateStatus(lastItem).HasFlag(DupeType.All))
|
||||||
{
|
{
|
||||||
logger.Verbose($"Exact duplicate found for '{datItemName}'");
|
staticLogger.Verbose($"Exact duplicate found for '{datItemName}'");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current name matches the previous name, rename the current item
|
// If the current name matches the previous name, rename the current item
|
||||||
else if (datItemName == lastItemName)
|
else if (datItemName == lastItemName)
|
||||||
{
|
{
|
||||||
logger.Verbose($"Name duplicate found for '{datItemName}'");
|
staticLogger.Verbose($"Name duplicate found for '{datItemName}'");
|
||||||
|
|
||||||
if (datItem.ItemType == ItemType.Disk || datItem.ItemType == ItemType.Media || datItem.ItemType == ItemType.Rom)
|
if (datItem.ItemType == ItemType.Disk || datItem.ItemType == ItemType.Media || datItem.ItemType == ItemType.Rom)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace SabreTools.Library.FileTypes
|
|||||||
return archive;
|
return archive;
|
||||||
|
|
||||||
// Create the archive based on the type
|
// Create the archive based on the type
|
||||||
logger.Verbose($"Found archive of type: {at}");
|
staticLogger.Verbose($"Found archive of type: {at}");
|
||||||
switch (at)
|
switch (at)
|
||||||
{
|
{
|
||||||
case FileType.GZipArchive:
|
case FileType.GZipArchive:
|
||||||
|
|||||||
@@ -22,7 +22,12 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected static Logger logger = new Logger();
|
protected Logger logger;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Static logger for static methods
|
||||||
|
/// </summary>
|
||||||
|
protected static Logger staticLogger = new Logger();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Flag specific to Folder to omit Machine name from output path
|
/// Flag specific to Folder to omit Machine name from output path
|
||||||
@@ -42,6 +47,7 @@ namespace SabreTools.Library.FileTypes
|
|||||||
{
|
{
|
||||||
this.Type = FileType.Folder;
|
this.Type = FileType.Folder;
|
||||||
this.writeToParent = writeToParent;
|
this.writeToParent = writeToParent;
|
||||||
|
logger = new Logger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -54,6 +60,7 @@ namespace SabreTools.Library.FileTypes
|
|||||||
: base(filename, getHashes)
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
this.Type = FileType.Folder;
|
this.Type = FileType.Folder;
|
||||||
|
logger = new Logger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -21,7 +21,19 @@ namespace SabreTools.Library.Filtering
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Logger logger = new Logger();
|
private readonly Logger logger;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public ExtraIni()
|
||||||
|
{
|
||||||
|
logger = new Logger(this);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -291,12 +291,24 @@ namespace SabreTools.Library.Filtering
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Logger logger = new Logger();
|
private readonly Logger logger;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Instance methods
|
#region Instance methods
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public Filter()
|
||||||
|
{
|
||||||
|
logger = new Logger(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Filter Population
|
#region Filter Population
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -11,17 +11,38 @@ namespace SabreTools.Library.Help
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class TopLevel : Feature
|
public abstract class TopLevel : Feature
|
||||||
{
|
{
|
||||||
|
#region Fields
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of files, directories, and potential wildcard paths
|
||||||
|
/// </summary>
|
||||||
public List<string> Inputs = new List<string>();
|
public List<string> Inputs = new List<string>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Logging
|
#region Logging
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Logger logger = new Logger();
|
private readonly Logger logger;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public TopLevel()
|
||||||
|
{
|
||||||
|
logger = new Logger(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Processing
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process args list based on current feature
|
/// Process args list based on current feature
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -63,6 +84,8 @@ namespace SabreTools.Library.Help
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void ProcessFeatures(Dictionary<string, Feature> features) { }
|
public virtual void ProcessFeatures(Dictionary<string, Feature> features) { }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Generic Extraction
|
#region Generic Extraction
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -43,7 +43,19 @@ namespace SabreTools.Library.Skippers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Logger logger = new Logger();
|
private readonly Logger logger;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public SkipperRule()
|
||||||
|
{
|
||||||
|
logger = new Logger(this);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace SabreTools.Library.Tools
|
|||||||
{
|
{
|
||||||
private string _subject;
|
private string _subject;
|
||||||
private DateTime _startTime;
|
private DateTime _startTime;
|
||||||
private readonly Logger _logger = new Logger();
|
private readonly Logger _logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor that initalizes the stopwatch
|
/// Constructor that initalizes the stopwatch
|
||||||
@@ -19,6 +19,7 @@ namespace SabreTools.Library.Tools
|
|||||||
public InternalStopwatch()
|
public InternalStopwatch()
|
||||||
{
|
{
|
||||||
_subject = string.Empty;
|
_subject = string.Empty;
|
||||||
|
_logger = new Logger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -28,6 +29,7 @@ namespace SabreTools.Library.Tools
|
|||||||
public InternalStopwatch(string subject)
|
public InternalStopwatch(string subject)
|
||||||
{
|
{
|
||||||
_subject = subject;
|
_subject = subject;
|
||||||
|
_logger = new Logger(this);
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user