mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Instance logging with backing static class instead of Global
This commit is contained in:
@@ -4,7 +4,6 @@ using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.DatItems;
|
||||
using SabreTools.Library.IO;
|
||||
using SabreTools.Library.Tools;
|
||||
@@ -90,7 +89,7 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If the split is still unsuccessful, log it and skip
|
||||
if (split.Length == 1)
|
||||
Globals.Logger.Warning($"Possibly malformed line: '{line}'");
|
||||
logger.Warning($"Possibly malformed line: '{line}'");
|
||||
|
||||
string romname = split[0];
|
||||
line = line.Substring(romname.Length);
|
||||
@@ -246,14 +245,14 @@ namespace SabreTools.Library.DatFiles
|
||||
// If we have something else, it's invalid
|
||||
else
|
||||
{
|
||||
Globals.Logger.Warning($"Invalid line detected: '{romname} {line}'");
|
||||
logger.Warning($"Invalid line detected: '{romname} {line}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string message = $"'{filename}' - There was an error parsing at position {sr.BaseStream.Position}";
|
||||
Globals.Logger.Error(ex, message);
|
||||
logger.Error(ex, message);
|
||||
if (throwOnError)
|
||||
{
|
||||
sr.Dispose();
|
||||
@@ -280,13 +279,13 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals.Logger.User($"Opening file for writing: {outfile}");
|
||||
logger.User($"Opening file for writing: {outfile}");
|
||||
FileStream fs = FileExtensions.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");
|
||||
logger.Warning($"File '{outfile}' could not be created for writing! Please check to see if the file is writable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -331,13 +330,13 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
}
|
||||
|
||||
Globals.Logger.Verbose("File written!" + Environment.NewLine);
|
||||
logger.Verbose("File written!" + Environment.NewLine);
|
||||
sw.Dispose();
|
||||
fs.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Globals.Logger.Error(ex);
|
||||
logger.Error(ex);
|
||||
if (throwOnError) throw ex;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user