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

@@ -4,7 +4,6 @@ using System.IO;
using System.Linq;
using System.Text;
using SabreTools.Library.Data;
using SabreTools.Library.DatItems;
using SabreTools.Library.IO;
using SabreTools.Library.Tools;
@@ -71,7 +70,7 @@ namespace SabreTools.Library.DatFiles
catch (Exception ex)
{
string message = $"'{filename}' - There was an error parsing line {cmpr.LineNumber} '{cmpr.CurrentLine}'";
Globals.Logger.Error(ex, message);
logger.Error(ex, message);
if (throwOnError)
{
cmpr.Dispose();
@@ -277,13 +276,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;
}
@@ -339,13 +338,13 @@ namespace SabreTools.Library.DatFiles
// Write the file footer out
WriteFooter(cmpw);
Globals.Logger.Verbose($"File written!{Environment.NewLine}");
logger.Verbose($"File written!{Environment.NewLine}");
cmpw.Dispose();
fs.Dispose();
}
catch (Exception ex)
{
Globals.Logger.Error(ex);
logger.Error(ex);
if (throwOnError) throw ex;
return false;
}