diff --git a/SabreTools.Core/Enums.cs b/SabreTools.Core/Enums.cs
index 16a7b67e..ea849e9c 100644
--- a/SabreTools.Core/Enums.cs
+++ b/SabreTools.Core/Enums.cs
@@ -785,4 +785,19 @@ namespace SabreTools.Core
}
#endregion
+
+ #region Logging
+
+ ///
+ /// Severity of the logging statement
+ ///
+ public enum LogLevel
+ {
+ VERBOSE = 0,
+ USER,
+ WARNING,
+ ERROR,
+ }
+
+ #endregion
}
diff --git a/SabreTools.Core/README.1ST b/SabreTools.Core/README.1ST
index 03a34a50..8d99f03e 100644
--- a/SabreTools.Core/README.1ST
+++ b/SabreTools.Core/README.1ST
@@ -205,6 +205,10 @@ Options:
date. It will also treat all archives as possible games and add all three
hashes (CRC, MD5, SHA-1) for each file.
+ -ll=, --log-level= Set the lowest log level for output
+ Set the lowest log level for output.
+ Possible values are: Verbose, User, Warning, Error
+
-nm, --skip-md5 Don't include MD5 in output
This allows the user to skip calculating the MD5 for each of the
files which will speed up the creation of the DAT.
@@ -437,6 +441,10 @@ Options:
- Nintendo Super Famicom / Super Nintendo Entertainment System
- Nintendo Super Famicom / Super Nintendo Entertainment System SPC
+ -ll=, --log-level= Set the lowest log level for output
+ Set the lowest log level for output.
+ Possible values are: Verbose, User, Warning, Error
+
-out=, --output-dir= Set output directory
This sets an output folder to be used when the files are created. If
a path is not defined, the runtime directory is used instead.
@@ -463,7 +471,11 @@ Options:
- Nintendo Super Famicom / Super Nintendo Entertainment System
- Nintendo Super Famicom / Super Nintendo Entertainment System SPC
- -out=, --output-dir= Set output directory
+ -ll=, --log-level= Set the lowest log level for output
+ Set the lowest log level for output.
+ Possible values are: Verbose, User, Warning, Error
+
+ -out=, --output-dir= Set output directory
This sets an output folder to be used when the files are created. If
a path is not defined, the runtime directory is used instead.
@@ -472,6 +484,10 @@ Options:
file(s). By default all files will be rebuilt to uncompressed folders in
the output directory.
+ -ll=, --log-level= Set the lowest log level for output
+ Set the lowest log level for output.
+ Possible values are: Verbose, User, Warning, Error
+
-dat=, --dat= Input DAT to be used
User-supplied DAT for use in all operations. Multiple instances of
this flag are allowed.
@@ -610,6 +626,10 @@ Options:
possible criteria. See the individual input information for details. More
than one split type is allowed at a time.
+ -ll=, --log-level= Set the lowest log level for output
+ Set the lowest log level for output.
+ Possible values are: Verbose, User, Warning, Error
+
-ot=, --output-type= Output DATs to a specified format
Add outputting the created DAT to known format. Multiple instances of
this flag are allowed.
@@ -727,6 +747,10 @@ Options:
- Items that include a SHA-512
- Items with Nodump status
+ -ll=, --log-level= Set the lowest log level for output
+ Set the lowest log level for output.
+ Possible values are: Verbose, User, Warning, Error
+
-srt=, --report-type= Output statistics to a specified format
Add outputting the created DAT to known format. Multiple instances of
this flag are allowed.
@@ -764,6 +788,10 @@ Options:
different programs that performed DAT manipulation that work better
together.
+ -ll=, --log-level= Set the lowest log level for output
+ Set the lowest log level for output.
+ Possible values are: Verbose, User, Warning, Error
+
-ot=, --output-type= Output DATs to a specified format
Add outputting the created DAT to known format. Multiple instances of
this flag are allowed.
@@ -1158,6 +1186,10 @@ Options:
within. This will only do a direct verification of the items within and
will create a fixdat afterwards for missing files.
+ -ll=, --log-level= Set the lowest log level for output
+ Set the lowest log level for output.
+ Possible values are: Verbose, User, Warning, Error
+
-dat=, --dat= Input DAT to be used
User-supplied DAT for use in all operations. Multiple instances of
this flag are allowed.
diff --git a/SabreTools.Core/Tools/Converters.cs b/SabreTools.Core/Tools/Converters.cs
index 9411128b..9758ad46 100644
--- a/SabreTools.Core/Tools/Converters.cs
+++ b/SabreTools.Core/Tools/Converters.cs
@@ -949,7 +949,24 @@ namespace SabreTools.Core.Tools
};
}
- ///
+ ///
+ /// Get LogLevel value from input string
+ ///
+ /// String to get value from
+ /// LogLevel value corresponding to the string
+ public static LogLevel AsLogLevel(this string logLevel)
+ {
+ return logLevel.ToLowerInvariant() switch
+ {
+ "verbose" => LogLevel.VERBOSE,
+ "user" => LogLevel.USER,
+ "warning" => LogLevel.WARNING,
+ "error" => LogLevel.ERROR,
+ _ => LogLevel.VERBOSE,
+ };
+ }
+
+ ///
/// Get MachineField value from input string
///
/// String to get value from
diff --git a/SabreTools.Logging/Enums.cs b/SabreTools.Logging/Enums.cs
deleted file mode 100644
index cdc45f97..00000000
--- a/SabreTools.Logging/Enums.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace SabreTools.Logging
-{
- ///
- /// Severity of the logging statement
- ///
- public enum LogLevel
- {
- VERBOSE = 0,
- USER,
- WARNING,
- ERROR,
- }
-}
diff --git a/SabreTools.Logging/LogEventArgs.cs b/SabreTools.Logging/LogEventArgs.cs
index 490a7b3e..deead8c3 100644
--- a/SabreTools.Logging/LogEventArgs.cs
+++ b/SabreTools.Logging/LogEventArgs.cs
@@ -1,5 +1,7 @@
using System;
+using SabreTools.Core;
+
namespace SabreTools.Logging
{
///
diff --git a/SabreTools.Logging/LoggerImpl.cs b/SabreTools.Logging/LoggerImpl.cs
index 43a757b4..26987abe 100644
--- a/SabreTools.Logging/LoggerImpl.cs
+++ b/SabreTools.Logging/LoggerImpl.cs
@@ -2,6 +2,7 @@
using System.IO;
using System.Text;
+using SabreTools.Core;
using SabreTools.IO;
namespace SabreTools.Logging
diff --git a/SabreTools/Features/BaseFeature.cs b/SabreTools/Features/BaseFeature.cs
index cdbc7ad7..c06a8a80 100644
--- a/SabreTools/Features/BaseFeature.cs
+++ b/SabreTools/Features/BaseFeature.cs
@@ -1555,6 +1555,21 @@ Possible values are: None, Zip, Unzip, Partial, Flat");
}
}
+ internal const string LogLevelStringValue = "log-level";
+ internal static Feature LogLevelStringInput
+ {
+ get
+ {
+ return new Feature(
+ LogLevelStringValue,
+ new List() { "-ll", "--log-level" },
+ "Set the lowest log level for output",
+ ParameterType.String,
+ longDescription: @"Set the lowest log level for output.
+Possible values are: Verbose, User, Warning, Error");
+ }
+ }
+
internal const string NameStringValue = "name";
internal static Feature NameStringInput
{
@@ -1735,6 +1750,11 @@ Some special strings that can be used:
///
protected DatHeader Header { get; set; }
+ ///
+ /// Lowest log level for output
+ ///
+ public LogLevel LogLevel { get; protected set; }
+
///
/// Output directory
///
@@ -1816,6 +1836,7 @@ Some special strings that can be used:
Extras = GetExtras(features);
Filter = GetFilter(features);
Header = GetDatHeader(features);
+ LogLevel = GetString(features, LogLevelStringValue).AsLogLevel();
OutputDir = GetString(features, OutputDirStringValue).Trim('"');
Remover = GetRemover(features);
Splitter = GetSplitter(features);
diff --git a/SabreTools/Features/Batch.cs b/SabreTools/Features/Batch.cs
index eb35f954..2547a072 100644
--- a/SabreTools/Features/Batch.cs
+++ b/SabreTools/Features/Batch.cs
@@ -44,6 +44,9 @@ Set the output directory: output(outdir);
Write the internal items: write([overwrite = true]);
Reset the internal state: reset();";
Features = new Dictionary();
+
+ // Common Features
+ AddFeature(LogLevelStringInput);
}
public override void ProcessFeatures(Dictionary features)
diff --git a/SabreTools/Features/DatFromDir.cs b/SabreTools/Features/DatFromDir.cs
index 51eab831..5eb9b27d 100644
--- a/SabreTools/Features/DatFromDir.cs
+++ b/SabreTools/Features/DatFromDir.cs
@@ -22,6 +22,9 @@ namespace SabreTools.Features
LongDescription = "Create a DAT file from an input directory or set of files. By default, this will output a DAT named based on the input directory and the current date. It will also treat all archives as possible games and add all three hashes (CRC, MD5, SHA-1) for each file.";
Features = new Dictionary();
+ // Common Features
+ AddFeature(LogLevelStringInput);
+
// Hash Features
AddFeature(SkipMd5Flag);
AddFeature(SkipSha1Flag);
diff --git a/SabreTools/Features/Extract.cs b/SabreTools/Features/Extract.cs
index 481cfc7e..bb7a4654 100644
--- a/SabreTools/Features/Extract.cs
+++ b/SabreTools/Features/Extract.cs
@@ -34,6 +34,9 @@ The following systems have headers that this program can work with:
- Nintendo Super Famicom / Super Nintendo Entertainment System SPC";
Features = new Dictionary();
+ // Common Features
+ AddFeature(LogLevelStringInput);
+
AddFeature(OutputDirStringInput);
AddFeature(NoStoreHeaderFlag);
}
diff --git a/SabreTools/Features/Script.cs b/SabreTools/Features/Script.cs
index 5927fd12..c572ef8d 100644
--- a/SabreTools/Features/Script.cs
+++ b/SabreTools/Features/Script.cs
@@ -4,6 +4,8 @@ using SabreTools.Help;
namespace SabreTools.Features
{
+ // TODO: With the introduction of the `--log-level` input, can we create a better way
+ // to handle "universal" flags? Having script as its own feature is not ideal.
internal class Script : BaseFeature
{
public const string Value = "Script";
diff --git a/SabreTools/Features/Sort.cs b/SabreTools/Features/Sort.cs
index b7ac81a0..7d68fc30 100644
--- a/SabreTools/Features/Sort.cs
+++ b/SabreTools/Features/Sort.cs
@@ -23,6 +23,9 @@ namespace SabreTools.Features
LongDescription = "This feature allows the user to quickly rebuild based on a supplied DAT file(s). By default all files will be rebuilt to uncompressed folders in the output directory.";
Features = new Dictionary();
+ // Common Features
+ AddFeature(LogLevelStringInput);
+
AddFeature(DatListInput);
AddFeature(OutputDirStringInput);
AddFeature(DepotFlag);
diff --git a/SabreTools/Features/Split.cs b/SabreTools/Features/Split.cs
index 6be4aefe..706123d1 100644
--- a/SabreTools/Features/Split.cs
+++ b/SabreTools/Features/Split.cs
@@ -23,6 +23,9 @@ namespace SabreTools.Features
LongDescription = "This feature allows the user to split input DATs by a number of different possible criteria. See the individual input information for details. More than one split type is allowed at a time.";
Features = new Dictionary();
+ // Common Features
+ AddFeature(LogLevelStringInput);
+
AddFeature(OutputTypeListInput);
this[OutputTypeListInput].AddFeature(DeprecatedFlag);
AddFeature(OutputDirStringInput);
diff --git a/SabreTools/Features/Verify.cs b/SabreTools/Features/Verify.cs
index 9d47b4e1..a596ec32 100644
--- a/SabreTools/Features/Verify.cs
+++ b/SabreTools/Features/Verify.cs
@@ -23,6 +23,9 @@ namespace SabreTools.Features
LongDescription = "When used, this will use an input DAT or set of DATs to blindly check against an input folder. The base of the folder is considered the base for the combined DATs and games are either the directories or archives within. This will only do a direct verification of the items within and will create a fixdat afterwards for missing files.";
Features = new Dictionary();
+ // Common Features
+ AddFeature(LogLevelStringInput);
+
AddFeature(DatListInput);
AddFeature(DepotFlag);
this[DepotFlag].AddFeature(DepotDepthInt32Input);
diff --git a/SabreTools/Program.cs b/SabreTools/Program.cs
index 8c3155bf..7897a97a 100644
--- a/SabreTools/Program.cs
+++ b/SabreTools/Program.cs
@@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.IO;
-using SabreTools.Features;
using SabreTools.Core;
+using SabreTools.Features;
using SabreTools.Help;
using SabreTools.IO;
using SabreTools.Logging;
@@ -109,6 +109,9 @@ namespace SabreTools
return;
}
+ // Set the new log level based on settings
+ LoggerImpl.LowestLogLevel = feature.LogLevel;
+
// Now process the current feature
Dictionary features = _help.GetEnabledFeatures();
switch (featureName)