mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Extract out Logging namespace
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -14,6 +14,8 @@
|
|||||||
/SabreTools.Help/obj/
|
/SabreTools.Help/obj/
|
||||||
/SabreTools.Library/bin/
|
/SabreTools.Library/bin/
|
||||||
/SabreTools.Library/obj/
|
/SabreTools.Library/obj/
|
||||||
|
/SabreTools.Logging/bin/
|
||||||
|
/SabreTools.Logging/obj/
|
||||||
/SabreTools.Skippers/bin/
|
/SabreTools.Skippers/bin/
|
||||||
/SabreTools.Skippers/obj/
|
/SabreTools.Skippers/obj/
|
||||||
/SabreTools.userprefs
|
/SabreTools.userprefs
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ using System.Xml;
|
|||||||
|
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.DatFiles;
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using RombaSharp.Features;
|
using RombaSharp.Features;
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
using SabreTools.Library.Logging;
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace RombaSharp
|
namespace RombaSharp
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SabreTools.Help\SabreTools.Help.csproj" />
|
<ProjectReference Include="..\SabreTools.Help\SabreTools.Help.csproj" />
|
||||||
<ProjectReference Include="..\SabreTools.Library\SabreTools.Library.csproj" />
|
<ProjectReference Include="..\SabreTools.Library\SabreTools.Library.csproj" />
|
||||||
|
<ProjectReference Include="..\SabreTools.Logging\SabreTools.Logging.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -11,4 +11,8 @@
|
|||||||
<DefineConstants>NET_FRAMEWORK</DefineConstants>
|
<DefineConstants>NET_FRAMEWORK</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SabreTools.Logging\SabreTools.Logging.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace SabreTools.Help
|
namespace SabreTools.Help
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -23,8 +25,7 @@ namespace SabreTools.Help
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// TODO: Re-enable all logging once Logging namespace separated out
|
private readonly Logger logger;
|
||||||
//private readonly Logger logger;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ namespace SabreTools.Help
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public TopLevel()
|
public TopLevel()
|
||||||
{
|
{
|
||||||
//logger = new Logger(this);
|
logger = new Logger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -67,9 +68,9 @@ namespace SabreTools.Help
|
|||||||
// Everything else isn't a file
|
// Everything else isn't a file
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//logger.Error($"Invalid input detected: {args[i]}");
|
logger.Error($"Invalid input detected: {args[i]}");
|
||||||
help.OutputIndividualFeature(this.Name);
|
help.OutputIndividualFeature(this.Name);
|
||||||
//LoggerImpl.Close();
|
LoggerImpl.Close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ using System.Threading.Tasks;
|
|||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.FileTypes;
|
using SabreTools.Library.FileTypes;
|
||||||
using SabreTools.Library.Filtering;
|
using SabreTools.Library.Filtering;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
using SabreTools.Library.Reports;
|
using SabreTools.Library.Reports;
|
||||||
using SabreTools.Library.Skippers;
|
using SabreTools.Library.Skippers;
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ using System.Threading.Tasks;
|
|||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
using SabreTools.Library.Reports;
|
using SabreTools.Library.Reports;
|
||||||
using NaturalSort;
|
using NaturalSort;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ using System.Linq;
|
|||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.FileTypes;
|
using SabreTools.Library.FileTypes;
|
||||||
using SabreTools.Library.Filtering;
|
using SabreTools.Library.Filtering;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
using NaturalSort;
|
using NaturalSort;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
|
|
||||||
namespace SabreTools.Library.FileTypes
|
namespace SabreTools.Library.FileTypes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using SabreTools.Library.Logging;
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
|
|
||||||
namespace SabreTools.Library.Filtering
|
namespace SabreTools.Library.Filtering
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
|
|
||||||
namespace SabreTools.Library.Filtering
|
namespace SabreTools.Library.Filtering
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
|
|
||||||
namespace SabreTools.Library.Filtering
|
namespace SabreTools.Library.Filtering
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using SabreTools.Library.Logging;
|
using SabreTools.Logging;
|
||||||
using NaturalSort;
|
using NaturalSort;
|
||||||
|
|
||||||
namespace SabreTools.Library.IO
|
namespace SabreTools.Library.IO
|
||||||
|
|||||||
@@ -6,10 +6,9 @@ using System.Xml;
|
|||||||
using System.Xml.Schema;
|
using System.Xml.Schema;
|
||||||
|
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.DatFiles;
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.FileTypes;
|
using SabreTools.Library.FileTypes;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
using SabreTools.Library.Tools;
|
|
||||||
|
|
||||||
namespace SabreTools.Library.IO
|
namespace SabreTools.Library.IO
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.DatFiles;
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.FileTypes;
|
using SabreTools.Library.FileTypes;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
using Compress.ThreadReaders;
|
using Compress.ThreadReaders;
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.DatFiles;
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.FileTypes;
|
using SabreTools.Library.FileTypes;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
using SabreTools.Library.Skippers;
|
using SabreTools.Library.Skippers;
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SabreTools.Data\SabreTools.Data.csproj" />
|
<ProjectReference Include="..\SabreTools.Data\SabreTools.Data.csproj" />
|
||||||
|
<ProjectReference Include="..\SabreTools.Logging\SabreTools.Logging.csproj" />
|
||||||
<ProjectReference Include="..\SabreTools.Skippers\SabreTools.Skippers.csproj" />
|
<ProjectReference Include="..\SabreTools.Skippers\SabreTools.Skippers.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -35,8 +36,4 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Help\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.IO;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
using SabreTools.Library.Logging;
|
using SabreTools.Logging;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
|
|
||||||
namespace SabreTools.Library.Tools
|
namespace SabreTools.Library.Tools
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
using SabreTools.Library.Logging;
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace SabreTools.Library.Tools
|
namespace SabreTools.Library.Tools
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace SabreTools.Library.Logging
|
namespace SabreTools.Logging
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Severity of the logging statement
|
/// Severity of the logging statement
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace SabreTools.Library.Logging
|
namespace SabreTools.Logging
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generic delegate type for log events
|
/// Generic delegate type for log events
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace SabreTools.Library.Logging
|
namespace SabreTools.Logging
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Per-class logging
|
/// Per-class logging
|
||||||
@@ -3,9 +3,8 @@ using System.IO;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
using SabreTools.Library.IO;
|
|
||||||
|
|
||||||
namespace SabreTools.Library.Logging
|
namespace SabreTools.Logging
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal logging implementation
|
/// Internal logging implementation
|
||||||
@@ -87,7 +86,7 @@ namespace SabreTools.Library.Logging
|
|||||||
{
|
{
|
||||||
// Set and create the output
|
// Set and create the output
|
||||||
if (addDate)
|
if (addDate)
|
||||||
Filename = $"{Path.GetFileNameWithoutExtension(filename)} ({DateTime.Now:yyyy-MM-dd HH-mm-ss}).{PathExtensions.GetNormalizedExtension(filename)}";
|
Filename = $"{Path.GetFileNameWithoutExtension(filename)} ({DateTime.Now:yyyy-MM-dd HH-mm-ss}).{GetNormalizedExtension(filename)}";
|
||||||
else
|
else
|
||||||
Filename = filename;
|
Filename = filename;
|
||||||
}
|
}
|
||||||
@@ -112,7 +111,7 @@ namespace SabreTools.Library.Logging
|
|||||||
if (!string.IsNullOrEmpty(LogDirectory) && !Directory.Exists(LogDirectory))
|
if (!string.IsNullOrEmpty(LogDirectory) && !Directory.Exists(LogDirectory))
|
||||||
Directory.CreateDirectory(LogDirectory);
|
Directory.CreateDirectory(LogDirectory);
|
||||||
|
|
||||||
FileStream logfile = FileExtensions.TryCreate(Path.Combine(LogDirectory, Filename));
|
FileStream logfile = TryCreate(Path.Combine(LogDirectory, Filename));
|
||||||
_log = new StreamWriter(logfile, Encoding.UTF8, (int)(4 * Constants.KibiByte), true)
|
_log = new StreamWriter(logfile, Encoding.UTF8, (int)(4 * Constants.KibiByte), true)
|
||||||
{
|
{
|
||||||
AutoFlush = true
|
AutoFlush = true
|
||||||
@@ -282,7 +281,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="ex">Exception to be written log</param>
|
/// <param name="ex">Exception to be written log</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
internal static void Verbose(object instance, Exception ex, string output = null)
|
public static void Verbose(object instance, Exception ex, string output = null)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.VERBOSE, output, ex));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.VERBOSE, output, ex));
|
||||||
}
|
}
|
||||||
@@ -293,7 +292,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="instance">Instance object that's the source of logging</param>
|
/// <param name="instance">Instance object that's the source of logging</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
internal static void Verbose(object instance, string output)
|
public static void Verbose(object instance, string output)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.VERBOSE, output, null));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.VERBOSE, output, null));
|
||||||
}
|
}
|
||||||
@@ -305,7 +304,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="total">Total count for progress</param>
|
/// <param name="total">Total count for progress</param>
|
||||||
/// <param name="current">Current count for progres</param>
|
/// <param name="current">Current count for progres</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
internal static void Verbose(object instance, long total, long current, string output = null)
|
public static void Verbose(object instance, long total, long current, string output = null)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.VERBOSE, output));
|
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.VERBOSE, output));
|
||||||
}
|
}
|
||||||
@@ -317,7 +316,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="ex">Exception to be written log</param>
|
/// <param name="ex">Exception to be written log</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
internal static void User(object instance, Exception ex, string output = null)
|
public static void User(object instance, Exception ex, string output = null)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.USER, output, ex));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.USER, output, ex));
|
||||||
}
|
}
|
||||||
@@ -328,7 +327,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="instance">Instance object that's the source of logging</param>
|
/// <param name="instance">Instance object that's the source of logging</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
internal static void User(object instance, string output)
|
public static void User(object instance, string output)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.USER, output, null));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.USER, output, null));
|
||||||
}
|
}
|
||||||
@@ -340,7 +339,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="total">Total count for progress</param>
|
/// <param name="total">Total count for progress</param>
|
||||||
/// <param name="current">Current count for progres</param>
|
/// <param name="current">Current count for progres</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
internal static void User(object instance, long total, long current, string output = null)
|
public static void User(object instance, long total, long current, string output = null)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.USER, output));
|
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.USER, output));
|
||||||
}
|
}
|
||||||
@@ -352,7 +351,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="ex">Exception to be written log</param>
|
/// <param name="ex">Exception to be written log</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
internal static void Warning(object instance, Exception ex, string output = null)
|
public static void Warning(object instance, Exception ex, string output = null)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.WARNING, output, ex));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.WARNING, output, ex));
|
||||||
}
|
}
|
||||||
@@ -363,7 +362,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="instance">Instance object that's the source of logging</param>
|
/// <param name="instance">Instance object that's the source of logging</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
internal static void Warning(object instance, string output)
|
public static void Warning(object instance, string output)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.WARNING, output, null));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.WARNING, output, null));
|
||||||
}
|
}
|
||||||
@@ -375,7 +374,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="total">Total count for progress</param>
|
/// <param name="total">Total count for progress</param>
|
||||||
/// <param name="current">Current count for progres</param>
|
/// <param name="current">Current count for progres</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
internal static void Warning(object instance, long total, long current, string output = null)
|
public static void Warning(object instance, long total, long current, string output = null)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.WARNING, output));
|
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.WARNING, output));
|
||||||
}
|
}
|
||||||
@@ -387,7 +386,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="ex">Exception to be written log</param>
|
/// <param name="ex">Exception to be written log</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
internal static void Error(object instance, Exception ex, string output = null)
|
public static void Error(object instance, Exception ex, string output = null)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.ERROR, output, ex));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.ERROR, output, ex));
|
||||||
}
|
}
|
||||||
@@ -398,7 +397,7 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="instance">Instance object that's the source of logging</param>
|
/// <param name="instance">Instance object that's the source of logging</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
internal static void Error(object instance, string output)
|
public static void Error(object instance, string output)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.ERROR, output, null));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.ERROR, output, null));
|
||||||
}
|
}
|
||||||
@@ -410,11 +409,62 @@ namespace SabreTools.Library.Logging
|
|||||||
/// <param name="total">Total count for progress</param>
|
/// <param name="total">Total count for progress</param>
|
||||||
/// <param name="current">Current count for progres</param>
|
/// <param name="current">Current count for progres</param>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
internal static void Error(object instance, long total, long current, string output = null)
|
public static void Error(object instance, long total, long current, string output = null)
|
||||||
{
|
{
|
||||||
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.ERROR, output));
|
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.ERROR, output));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
// TODO: Remove this region once IO namespace is separated out properly
|
||||||
|
#region TEMPORARY - REMOVEME
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the extension from the path, if possible
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to get extension from</param>
|
||||||
|
/// <returns>Extension, if possible</returns>
|
||||||
|
public static string GetNormalizedExtension(string path)
|
||||||
|
{
|
||||||
|
// Check null or empty first
|
||||||
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Get the extension from the path, if possible
|
||||||
|
string ext = Path.GetExtension(path)?.ToLowerInvariant();
|
||||||
|
|
||||||
|
// Check if the extension is null or empty
|
||||||
|
if (string.IsNullOrWhiteSpace(ext))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Make sure that extensions are valid
|
||||||
|
ext = ext.TrimStart('.');
|
||||||
|
|
||||||
|
return ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Try to create a file for write, optionally throwing the error
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">Name of the file to create</param>
|
||||||
|
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||||
|
/// <returns>An opened stream representing the file on success, null otherwise</returns>
|
||||||
|
public static FileStream TryCreate(string file, bool throwOnError = false)
|
||||||
|
{
|
||||||
|
// Now wrap opening the file
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return File.Open(file, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (throwOnError)
|
||||||
|
throw ex;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
14
SabreTools.Logging/SabreTools - Backup.Logging.csproj
Normal file
14
SabreTools.Logging/SabreTools - Backup.Logging.csproj
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>net48;netcoreapp3.1;net5.0</TargetFrameworks>
|
||||||
|
<RuntimeIdentifiers>win10-x64;win7-x86</RuntimeIdentifiers>
|
||||||
|
<Configurations>Debug;Release</Configurations>
|
||||||
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(TargetFramework)'=='net48'">
|
||||||
|
<DefineConstants>NET_FRAMEWORK</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
18
SabreTools.Logging/SabreTools.Logging.csproj
Normal file
18
SabreTools.Logging/SabreTools.Logging.csproj
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>net48;netcoreapp3.1;net5.0</TargetFrameworks>
|
||||||
|
<RuntimeIdentifiers>win10-x64;win7-x86</RuntimeIdentifiers>
|
||||||
|
<Configurations>Debug;Release</Configurations>
|
||||||
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(TargetFramework)'=='net48'">
|
||||||
|
<DefineConstants>NET_FRAMEWORK</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SabreTools.Data\SabreTools.Data.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net48;netcoreapp3.1;net5.0</TargetFrameworks>
|
<TargetFrameworks>net48;netcoreapp3.1;net5.0</TargetFrameworks>
|
||||||
@@ -11,6 +11,10 @@
|
|||||||
<DefineConstants>NET_FRAMEWORK</DefineConstants>
|
<DefineConstants>NET_FRAMEWORK</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SabreTools.Logging\SabreTools.Logging.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="a7800.xml" />
|
<None Remove="a7800.xml" />
|
||||||
<None Remove="fds.xml" />
|
<None Remove="fds.xml" />
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace SabreTools.Library.Skippers
|
namespace SabreTools.Library.Skippers
|
||||||
{
|
{
|
||||||
public class SkipperRule
|
public class SkipperRule
|
||||||
@@ -40,8 +42,7 @@ namespace SabreTools.Library.Skippers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logging object
|
/// Logging object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// TODO: Re-enable all logging once Logging namespace separated out
|
private readonly Logger logger;
|
||||||
//private readonly Logger logger;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ namespace SabreTools.Library.Skippers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public SkipperRule()
|
public SkipperRule()
|
||||||
{
|
{
|
||||||
//logger = new Logger(this);
|
logger = new Logger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -85,7 +86,7 @@ namespace SabreTools.Library.Skippers
|
|||||||
// If the input file doesn't exist, fail
|
// If the input file doesn't exist, fail
|
||||||
if (!File.Exists(input))
|
if (!File.Exists(input))
|
||||||
{
|
{
|
||||||
//logger.Error($"I'm sorry but '{input}' doesn't exist!");
|
logger.Error($"I'm sorry but '{input}' doesn't exist!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +124,7 @@ namespace SabreTools.Library.Skippers
|
|||||||
|| (Operation > HeaderSkipOperation.Byteswap && (extsize % 4) != 0)
|
|| (Operation > HeaderSkipOperation.Byteswap && (extsize % 4) != 0)
|
||||||
|| (Operation > HeaderSkipOperation.Bitswap && (StartOffset == null || StartOffset % 2 == 0)))
|
|| (Operation > HeaderSkipOperation.Bitswap && (StartOffset == null || StartOffset % 2 == 0)))
|
||||||
{
|
{
|
||||||
//logger.Error("The stream did not have the correct size to be transformed!");
|
logger.Error("The stream did not have the correct size to be transformed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +133,7 @@ namespace SabreTools.Library.Skippers
|
|||||||
BinaryReader br = null;
|
BinaryReader br = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//logger.User("Applying found rule to input stream");
|
logger.User("Applying found rule to input stream");
|
||||||
bw = new BinaryWriter(output);
|
bw = new BinaryWriter(output);
|
||||||
br = new BinaryReader(input);
|
br = new BinaryReader(input);
|
||||||
|
|
||||||
@@ -220,7 +221,7 @@ namespace SabreTools.Library.Skippers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
//logger.Error(ex);
|
logger.Error(ex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Skippers", "Sabr
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Help", "SabreTools.Help\SabreTools.Help.csproj", "{55364167-844F-4B58-8280-F5327FA3D8E7}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Help", "SabreTools.Help\SabreTools.Help.csproj", "{55364167-844F-4B58-8280-F5327FA3D8E7}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Logging", "SabreTools.Logging\SabreTools.Logging.csproj", "{3D54D896-19F0-4723-B1E3-E40FAFE5A078}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -78,6 +80,14 @@ Global
|
|||||||
{55364167-844F-4B58-8280-F5327FA3D8E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
{55364167-844F-4B58-8280-F5327FA3D8E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{55364167-844F-4B58-8280-F5327FA3D8E7}.Release|x64.ActiveCfg = Release|Any CPU
|
{55364167-844F-4B58-8280-F5327FA3D8E7}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{55364167-844F-4B58-8280-F5327FA3D8E7}.Release|x64.Build.0 = Release|Any CPU
|
{55364167-844F-4B58-8280-F5327FA3D8E7}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{3D54D896-19F0-4723-B1E3-E40FAFE5A078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3D54D896-19F0-4723-B1E3-E40FAFE5A078}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3D54D896-19F0-4723-B1E3-E40FAFE5A078}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{3D54D896-19F0-4723-B1E3-E40FAFE5A078}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{3D54D896-19F0-4723-B1E3-E40FAFE5A078}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3D54D896-19F0-4723-B1E3-E40FAFE5A078}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3D54D896-19F0-4723-B1E3-E40FAFE5A078}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{3D54D896-19F0-4723-B1E3-E40FAFE5A078}.Release|x64.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Library.DatFiles;
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.FileTypes;
|
using SabreTools.Library.FileTypes;
|
||||||
using SabreTools.Library.Filtering;
|
using SabreTools.Library.Filtering;
|
||||||
using SabreTools.Library.Logging;
|
|
||||||
using SabreTools.Library.Reports;
|
using SabreTools.Library.Reports;
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using SabreTools.Features;
|
using SabreTools.Features;
|
||||||
using SabreTools.Data;
|
using SabreTools.Data;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
using SabreTools.Library.Logging;
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace SabreTools
|
namespace SabreTools
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SabreTools.Help\SabreTools.Help.csproj" />
|
<ProjectReference Include="..\SabreTools.Help\SabreTools.Help.csproj" />
|
||||||
<ProjectReference Include="..\SabreTools.Library\SabreTools.Library.csproj" />
|
<ProjectReference Include="..\SabreTools.Library\SabreTools.Library.csproj" />
|
||||||
|
<ProjectReference Include="..\SabreTools.Logging\SabreTools.Logging.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user