Instance logging with backing static class instead of Global

This commit is contained in:
Matt Nadareski
2020-10-07 15:42:30 -07:00
parent 348a2a2bcb
commit b7db9f7f14
69 changed files with 1034 additions and 834 deletions

View File

@@ -6,7 +6,6 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using SabreTools.Library.Data;
using SabreTools.Library.DatItems;
using SabreTools.Library.IO;
using SabreTools.Library.Tools;
@@ -70,8 +69,8 @@ namespace SabreTools.Library.DatFiles
{
// The datafile tag can have some attributes
case "datafile":
Header.Build = (Header.Build == null ? xtr.GetAttribute("build") : Header.Build);
Header.Debug = (Header.Debug == null ? xtr.GetAttribute("debug").AsYesNo() : Header.Debug);
Header.Build = Header.Build ?? xtr.GetAttribute("build");
Header.Debug = Header.Debug ?? xtr.GetAttribute("debug").AsYesNo();
xtr.Read();
break;
@@ -107,7 +106,7 @@ namespace SabreTools.Library.DatFiles
}
catch (Exception ex)
{
Globals.Logger.Warning(ex, $"Exception found while parsing '{filename}'");
logger.Warning(ex, $"Exception found while parsing '{filename}'");
if (throwOnError)
{
xtr.Dispose();
@@ -688,13 +687,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;
}
@@ -750,13 +749,13 @@ namespace SabreTools.Library.DatFiles
// Write the file footer out
WriteFooter(xtw);
Globals.Logger.Verbose("File written!" + Environment.NewLine);
logger.Verbose("File written!" + Environment.NewLine);
xtw.Dispose();
fs.Dispose();
}
catch (Exception ex)
{
Globals.Logger.Error(ex);
logger.Error(ex);
if (throwOnError) throw ex;
return false;
}