[ALL] Use params variant for logging

This commit is contained in:
Matt Nadareski
2017-08-26 14:11:10 -07:00
parent 06d9980b9b
commit 47f70838f1
17 changed files with 120 additions and 120 deletions

View File

@@ -679,14 +679,14 @@ namespace SabreTools.Library.Dats
// If the current item exactly matches the last item, then we don't add it
if ((datItem.GetDuplicateStatus(lastItem) & DupeType.All) != 0)
{
Globals.Logger.Verbose("Exact duplicate found for '" + datItem.Name + "'");
Globals.Logger.Verbose("Exact duplicate found for '{0}'", datItem.Name);
continue;
}
// If the current name matches the previous name, rename the current item
else if (datItem.Name == lastItem.Name)
{
Globals.Logger.Verbose("Name duplicate found for '" + datItem.Name + "'");
Globals.Logger.Verbose("Name duplicate found for '{0}'", datItem.Name);
if (datItem.Type == ItemType.Disk)
{

View File

@@ -670,7 +670,7 @@ namespace SabreTools.Library.Dats
machineType |= MachineType.Mechanical;
break;
default:
Globals.Logger.Warning(gametype + " is not a valid type");
Globals.Logger.Warning("{0} is not a valid type", gametype);
break;
}
@@ -703,7 +703,7 @@ namespace SabreTools.Library.Dats
itemStatus |= ItemStatus.Verified;
break;
default:
Globals.Logger.Warning(status + " is not a valid status");
Globals.Logger.Warning("{0} is not a valid status", status);
break;
}

View File

@@ -115,7 +115,7 @@ namespace SabreTools.Library.Dats
Parallel.For(0, inputs.Count, i =>
{
string input = inputs[i];
Globals.Logger.User("Adding DAT: " + input.Split('¬')[0]);
Globals.Logger.User("Adding DAT: {0}", input.Split('¬')[0]);
datHeaders[i] = new DatFile
{
DatFormat = (DatFormat != 0 ? DatFormat : 0),
@@ -125,7 +125,7 @@ namespace SabreTools.Library.Dats
datHeaders[i].Parse(input.Split('¬')[0], i, 0, splitType, keep: true, clean: clean, remUnicode: remUnicode, descAsName: descAsName);
});
Globals.Logger.User("Processing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Processing complete in {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Populating internal DAT");
Parallel.For(0, inputs.Count, i =>
@@ -151,7 +151,7 @@ namespace SabreTools.Library.Dats
// Now that we have a merged DAT, filter it
Filter(filter, single, trim, root);
Globals.Logger.User("Processing and populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Processing and populating complete in {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
return datHeaders.ToList();
}
@@ -184,7 +184,7 @@ namespace SabreTools.Library.Dats
Parse(path, 0, 0, keep: true, clean: clean, remUnicode: remUnicode, descAsName: descAsName);
});
Globals.Logger.User("Populating base DAT complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Populating base DAT complete in {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
// For comparison's sake, we want to use CRC as the base ordering
BucketBy(SortedBy.CRC, true);
@@ -196,7 +196,7 @@ namespace SabreTools.Library.Dats
// Get the two halves of the path
string[] splitpath = path.Split('¬');
Globals.Logger.User("Comparing '" + splitpath[0] + "' to base DAT");
Globals.Logger.User("Comparing '{0}'' to base DAT", splitpath[0]);
// First we parse in the DAT internally
DatFile intDat = new DatFile();
@@ -294,7 +294,7 @@ namespace SabreTools.Library.Dats
});
outDats = outDatsArray.ToList();
Globals.Logger.User("Initializing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Initializing complete in {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
// Now, loop through the dictionary and populate the correct DATs
start = DateTime.Now;
@@ -316,7 +316,7 @@ namespace SabreTools.Library.Dats
// There's odd cases where there are items with System ID < 0. Skip them for now
if (item.SystemID < 0)
{
Globals.Logger.Warning("Item found with a <0 SystemID: " + item.Name);
Globals.Logger.Warning("Item found with a <0 SystemID: {0}", item.Name);
continue;
}
@@ -324,7 +324,7 @@ namespace SabreTools.Library.Dats
}
});
Globals.Logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Populating complete in {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
// Finally, loop through and output each of the DATs
start = DateTime.Now;
@@ -350,7 +350,7 @@ namespace SabreTools.Library.Dats
outDats[j].WriteToFile(path);
});
Globals.Logger.User("Outputting complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Outputting complete in {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
}
/// <summary>
@@ -426,7 +426,7 @@ namespace SabreTools.Library.Dats
outDats = outDatsArray.ToList();
}
Globals.Logger.User("Initializing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Initializing complete in {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
// Now, loop through the dictionary and populate the correct DATs
start = DateTime.Now;
@@ -482,7 +482,7 @@ namespace SabreTools.Library.Dats
}
});
Globals.Logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Populating complete in {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
// Finally, loop through and output each of the DATs
start = DateTime.Now;
@@ -516,7 +516,7 @@ namespace SabreTools.Library.Dats
outDats[j].WriteToFile(path);
});
}
Globals.Logger.User("Outputting complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Outputting complete in {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
}
/// <summary>
@@ -598,7 +598,7 @@ namespace SabreTools.Library.Dats
}
DatFile innerDatdata = new DatFile(this);
Globals.Logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\"");
Globals.Logger.User("Processing '{0}'", Path.GetFileName(inputFileName));
innerDatdata.Parse(inputFileName, 0, 0, splitType, keep: true, clean: clean, remUnicode: remUnicode, descAsName: descAsName,
keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0));
innerDatdata.Filter(filter, trim, single, root);
@@ -620,7 +620,7 @@ namespace SabreTools.Library.Dats
List<string> subFiles = Directory.EnumerateFiles(inputFileName, "*", SearchOption.AllDirectories).ToList();
Parallel.ForEach(subFiles, file =>
{
Globals.Logger.User("Processing \"" + Path.GetFullPath(file).Remove(0, inputFileName.Length) + "\"");
Globals.Logger.User("Processing '{0}'", Path.GetFullPath(file).Remove(0, inputFileName.Length));
DatFile innerDatdata = new DatFile(this);
innerDatdata.Parse(file, 0, 0, splitType, keep: true, clean: clean, remUnicode: remUnicode, descAsName: descAsName,
keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0));
@@ -633,7 +633,7 @@ namespace SabreTools.Library.Dats
}
else
{
Globals.Logger.Error("I'm sorry but " + inputFileName + " doesn't exist!");
Globals.Logger.Error("I'm sorry but '{0}' doesn't exist!", inputFileName);
return;
}
});

View File

@@ -62,7 +62,7 @@ namespace SabreTools.Library.Dats
// Process the input
if (Directory.Exists(basePath))
{
Globals.Logger.Verbose("Folder found: " + basePath);
Globals.Logger.Verbose("Folder found: {0}", basePath);
// Process the files in the main folder
List<string> files = Directory.EnumerateFiles(basePath, "*", SearchOption.TopDirectoryOnly).ToList();
@@ -129,7 +129,7 @@ namespace SabreTools.Library.Dats
romname = romname.Substring(0, romname.Length - 1);
}
Globals.Logger.Verbose("Adding blank empty folder: " + gamename);
Globals.Logger.Verbose("Adding blank empty folder: {0}", gamename);
this["null"].Add(new Rom(romname, gamename, omitFromScan));
});
}
@@ -181,11 +181,11 @@ namespace SabreTools.Library.Dats
{
// Add the list if it doesn't exist already
Add(rom.Size + "-" + rom.CRC, rom);
Globals.Logger.User("File added: " + Path.GetFileNameWithoutExtension(item) + Environment.NewLine);
Globals.Logger.User("File added: {0}", Path.GetFileNameWithoutExtension(item) + Environment.NewLine);
}
else
{
Globals.Logger.User("File not added: " + Path.GetFileNameWithoutExtension(item) + Environment.NewLine);
Globals.Logger.User("File not added: {0}", Path.GetFileNameWithoutExtension(item) + Environment.NewLine);
return;
}
@@ -288,7 +288,7 @@ namespace SabreTools.Library.Dats
private void PopulateFromDirProcessFile(string item, string parent, string basePath, Hash omitFromScan,
bool addDate, string headerToCheckAgainst)
{
Globals.Logger.Verbose(Path.GetFileName(item) + " treated like a file");
Globals.Logger.Verbose("'{0}' treated like a file", Path.GetFileName(item));
Rom rom = FileTools.GetFileInfo(item, omitFromScan: omitFromScan, date: addDate, header: headerToCheckAgainst);
PopulateFromDirProcessFileHelper(item, rom, basePath, parent);
@@ -419,7 +419,7 @@ namespace SabreTools.Library.Dats
// Add the file information to the DAT
Add(key, datItem);
Globals.Logger.User("File added: " + romname + Environment.NewLine);
Globals.Logger.User("File added: {0}", romname + Environment.NewLine);
}
catch (IOException ex)
{

View File

@@ -48,7 +48,7 @@ namespace SabreTools.Library.Dats
// Create the temporary dictionary to sort into
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
Globals.Logger.User("Organizing roms by " + bucketBy +(mergeroms ? " and merging" : ""));
Globals.Logger.User("Organizing roms by {0}" + (mergeroms ? " and merging" : ""), bucketBy);
// First do the initial sort of all of the roms
List<string> keys = Keys.ToList();

View File

@@ -145,7 +145,7 @@ namespace SabreTools.Library.Dats
}
catch (Exception ex)
{
Globals.Logger.Error("Error with file '" + filename + "': " + ex.ToString());
Globals.Logger.Error("Error with file '{0}': {1}", filename, ex);
}
// If we want to use descriptions as names, update everything
@@ -997,7 +997,7 @@ namespace SabreTools.Library.Dats
// If the line doesn't have the correct number of columns, we log and skip
if (parsedLine.Length != columns.Count)
{
Globals.Logger.Warning("Malformed line found in '" + filename + " at line " + linenum);
Globals.Logger.Warning("Malformed line found in '{0}' at line {1}", filename, linenum);
continue;
}
@@ -1275,7 +1275,7 @@ namespace SabreTools.Library.Dats
int parentcount = parent.Count;
if (parentcount == 0)
{
Globals.Logger.Verbose("Empty parent: " + String.Join("\\", parent) + " found in " + filename);
Globals.Logger.Verbose("Empty parent '{0}' found in '{1}'", String.Join("\\", parent), filename);
empty = true;
}
@@ -2339,7 +2339,7 @@ namespace SabreTools.Library.Dats
}
catch (Exception ex)
{
Globals.Logger.Warning("Exception found while parsing " + filename + ": " + ex.ToString());
Globals.Logger.Warning("Exception found while parsing '{0}': {1}", filename, ex);
// For XML errors, just skip the affected node
xtr?.Read();
@@ -3038,14 +3038,14 @@ namespace SabreTools.Library.Dats
// If there's no name in the rom, we log and skip it
if (item.Name == null)
{
Globals.Logger.Warning(FileName + ": Rom with no name found! Skipping...");
Globals.Logger.Warning("{0}: Rom with no name found! Skipping...", FileName);
return key;
}
// If the name ends with a directory separator, we log and skip it (DOSCenter only?)
if (item.Name.EndsWith("/") || item.Name.EndsWith("\\"))
{
Globals.Logger.Warning(FileName + ": Rom ending with directory separator found: '" + item.Name + "'. Skipping...");
Globals.Logger.Warning("{0}: Rom ending with directory separator found: '{1}'. Skipping...", FileName, item.Name);
return key;
}
@@ -3097,7 +3097,7 @@ namespace SabreTools.Library.Dats
// If the file has no size and it's not the above case, skip and log
else if (itemRom.ItemStatus != ItemStatus.Nodump && (itemRom.Size == 0 || itemRom.Size == -1))
{
Globals.Logger.Verbose(FileName + ": Incomplete entry for \"" + itemRom.Name + "\" will be output as nodump");
Globals.Logger.Verbose("{0}: Incomplete entry for '{1}' will be output as nodump", FileName, itemRom.Name);
itemRom.ItemStatus = ItemStatus.Nodump;
}
// If the file has a size but aboslutely no hashes, skip and log
@@ -3110,7 +3110,7 @@ namespace SabreTools.Library.Dats
&& String.IsNullOrEmpty(itemRom.SHA384)
&& String.IsNullOrEmpty(itemRom.SHA512))
{
Globals.Logger.Verbose(FileName + ": Incomplete entry for \"" + itemRom.Name + "\" will be output as nodump");
Globals.Logger.Verbose("{0}: Incomplete entry for '{1}' will be output as nodump", FileName, itemRom.Name);
itemRom.ItemStatus = ItemStatus.Nodump;
}
@@ -3135,7 +3135,7 @@ namespace SabreTools.Library.Dats
&& String.IsNullOrEmpty(itemDisk.SHA384)
&& String.IsNullOrEmpty(itemDisk.SHA512))
{
Globals.Logger.Verbose("Incomplete entry for \"" + itemDisk.Name + "\" will be output as nodump");
Globals.Logger.Verbose("Incomplete entry for '{0}' will be output as nodump", itemDisk.Name);
itemDisk.ItemStatus = ItemStatus.Nodump;
}

View File

@@ -133,7 +133,7 @@ namespace SabreTools.Library.Dats
// Add to the list if the input is a directory
if (Directory.Exists(input))
{
Globals.Logger.Verbose("Adding depot: '" + input + "'");
Globals.Logger.Verbose("Adding depot: {0}", input);
lock (directories)
{
directories.Add(input);
@@ -160,7 +160,7 @@ namespace SabreTools.Library.Dats
continue;
}
Globals.Logger.User("Checking hash '" + hash + "'");
Globals.Logger.User("Checking hash '{0}'", hash);
// Get the extension path for the hash
string subpath = Style.GetRombaPath(hash);
@@ -196,7 +196,7 @@ namespace SabreTools.Library.Dats
updateDat, false /* isZip */, headerToCheckAgainst);
}
Globals.Logger.User("Rebuilding complete in: " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Rebuilding complete in: {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
#endregion
@@ -322,7 +322,7 @@ namespace SabreTools.Library.Dats
// If the input is a file
if (File.Exists(input))
{
Globals.Logger.User("Checking file: '" + input + "'");
Globals.Logger.User("Checking file: {0}", input);
RebuildGenericHelper(input, outDir, tempDir, quickScan, date, delete, inverse,
outputFormat, romba, archiveScanLevel, updateDat, headerToCheckAgainst);
}
@@ -330,17 +330,17 @@ namespace SabreTools.Library.Dats
// If the input is a directory
else if (Directory.Exists(input))
{
Globals.Logger.Verbose("Checking directory: '" + input + "'");
Globals.Logger.Verbose("Checking directory: {0}", input);
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
{
Globals.Logger.User("Checking file: '" + file + "'");
Globals.Logger.User("Checking file: {0}", file);
RebuildGenericHelper(file, outDir, tempDir, quickScan, date, delete, inverse,
outputFormat, romba, archiveScanLevel, updateDat, headerToCheckAgainst);
}
}
}
Globals.Logger.User("Rebuilding complete in: " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Rebuilding complete in: {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
#endregion
@@ -541,7 +541,7 @@ namespace SabreTools.Library.Dats
// Seek to the beginning of the stream
fileStream.Seek(0, SeekOrigin.Begin);
Globals.Logger.User("Matches found for '" + Style.GetFileName(rom.Name) + "', rebuilding accordingly...");
Globals.Logger.User("Matches found for '{0}', rebuilding accordingly...", Style.GetFileName(rom.Name));
rebuilt = true;
// Now loop through the list and rebuild accordingly
@@ -649,7 +649,7 @@ namespace SabreTools.Library.Dats
item.Machine.UpdateDescription(machinename);
}
Globals.Logger.User("No matches found for '" + Style.GetFileName(rom.Name) + "', rebuilding accordingly from inverse flag...");
Globals.Logger.User("No matches found for '{0}', rebuilding accordingly from inverse flag...", Style.GetFileName(rom.Name));
// Now rebuild to the output file
switch (outputFormat)
@@ -766,7 +766,7 @@ namespace SabreTools.Library.Dats
return rebuilt;
}
Globals.Logger.User("Headerless matches found for '" + Style.GetFileName(rom.Name) + "', rebuilding accordingly...");
Globals.Logger.User("Headerless matches found for '{0}', rebuilding accordingly...", Style.GetFileName(rom.Name));
rebuilt = true;
// Now loop through the list and rebuild accordingly
@@ -872,7 +872,7 @@ namespace SabreTools.Library.Dats
// Add to the list if the input is a directory
if (Directory.Exists(input))
{
Globals.Logger.Verbose("Adding depot: '" + input + "'");
Globals.Logger.Verbose("Adding depot: {0}", input);
directories.Add(input);
}
}
@@ -896,7 +896,7 @@ namespace SabreTools.Library.Dats
continue;
}
Globals.Logger.User("Checking hash '" + hash + "'");
Globals.Logger.User("Checking hash '{0}'", hash);
// Get the extension path for the hash
string subpath = Style.GetRombaPath(hash);
@@ -931,7 +931,7 @@ namespace SabreTools.Library.Dats
fileinfo.GetDuplicates(this, remove: true);
}
Globals.Logger.User("Verifying complete in: " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
Globals.Logger.User("Verifying complete in: {0}", DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
// If there are any entries in the DAT, output to the rebuild directory
_fileName = "fixDAT_" + _fileName;

View File

@@ -115,7 +115,7 @@ namespace SabreTools.Library.Dats
BucketBy(SortedBy.Game, false /* mergeRoms */, norename: norename);
// Output the number of items we're going to be writing
Globals.Logger.User("A total of " + Count + " items will be written out to \"" + FileName + "\"");
Globals.Logger.User("A total of {0} items will be written out to '{1}'", Count, FileName);
// Filter the DAT by 1G1R rules, if we're supposed to
// TODO: Create 1G1R logic before write
@@ -140,13 +140,13 @@ namespace SabreTools.Library.Dats
{
string outfile = outfiles[datFormat];
Globals.Logger.User("Opening file for writing: " + outfile);
Globals.Logger.User("Opening file for writing: {0}", outfile);
FileStream fs = FileTools.TryCreate(outfile);
// If we get back null for some reason, just log and return
if (fs == null)
{
Globals.Logger.Warning("File '" + outfile + "' could not be created for writing! Please check to see if the file is writable");
Globals.Logger.Warning("File '{0}' could not be created for writing! Please check to see if the file is writable", outfile);
return;
}
@@ -197,7 +197,7 @@ namespace SabreTools.Library.Dats
&& ((Rom)rom).Size == -1
&& ((Rom)rom).CRC == "null")
{
Globals.Logger.Verbose("Empty folder found: " + rom.Machine.Name);
Globals.Logger.Verbose("Empty folder found: {0}", rom.Machine.Name);
// If we're in a mode that doesn't allow for actual empty folders, add the blank info
if (datFormat != DatFormat.CSV