mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add log level input
This commit is contained in:
@@ -785,4 +785,19 @@ namespace SabreTools.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Logging
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Severity of the logging statement
|
||||||
|
/// </summary>
|
||||||
|
public enum LogLevel
|
||||||
|
{
|
||||||
|
VERBOSE = 0,
|
||||||
|
USER,
|
||||||
|
WARNING,
|
||||||
|
ERROR,
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,6 +205,10 @@ Options:
|
|||||||
date. It will also treat all archives as possible games and add all three
|
date. It will also treat all archives as possible games and add all three
|
||||||
hashes (CRC, MD5, SHA-1) for each file.
|
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
|
-nm, --skip-md5 Don't include MD5 in output
|
||||||
This allows the user to skip calculating the MD5 for each of the
|
This allows the user to skip calculating the MD5 for each of the
|
||||||
files which will speed up the creation of the DAT.
|
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
|
||||||
- Nintendo Super Famicom / Super Nintendo Entertainment System SPC
|
- 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
|
-out=, --output-dir= Set output directory
|
||||||
This sets an output folder to be used when the files are created. If
|
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.
|
a path is not defined, the runtime directory is used instead.
|
||||||
@@ -463,6 +471,10 @@ Options:
|
|||||||
- Nintendo Super Famicom / Super Nintendo Entertainment System
|
- Nintendo Super Famicom / Super Nintendo Entertainment System
|
||||||
- Nintendo Super Famicom / Super Nintendo Entertainment System SPC
|
- 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
|
-out=, --output-dir= Set output directory
|
||||||
This sets an output folder to be used when the files are created. If
|
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.
|
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
|
file(s). By default all files will be rebuilt to uncompressed folders in
|
||||||
the output directory.
|
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
|
-dat=, --dat= Input DAT to be used
|
||||||
User-supplied DAT for use in all operations. Multiple instances of
|
User-supplied DAT for use in all operations. Multiple instances of
|
||||||
this flag are allowed.
|
this flag are allowed.
|
||||||
@@ -610,6 +626,10 @@ Options:
|
|||||||
possible criteria. See the individual input information for details. More
|
possible criteria. See the individual input information for details. More
|
||||||
than one split type is allowed at a time.
|
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
|
-ot=, --output-type= Output DATs to a specified format
|
||||||
Add outputting the created DAT to known format. Multiple instances of
|
Add outputting the created DAT to known format. Multiple instances of
|
||||||
this flag are allowed.
|
this flag are allowed.
|
||||||
@@ -727,6 +747,10 @@ Options:
|
|||||||
- Items that include a SHA-512
|
- Items that include a SHA-512
|
||||||
- Items with Nodump status
|
- 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
|
-srt=, --report-type= Output statistics to a specified format
|
||||||
Add outputting the created DAT to known format. Multiple instances of
|
Add outputting the created DAT to known format. Multiple instances of
|
||||||
this flag are allowed.
|
this flag are allowed.
|
||||||
@@ -764,6 +788,10 @@ Options:
|
|||||||
different programs that performed DAT manipulation that work better
|
different programs that performed DAT manipulation that work better
|
||||||
together.
|
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
|
-ot=, --output-type= Output DATs to a specified format
|
||||||
Add outputting the created DAT to known format. Multiple instances of
|
Add outputting the created DAT to known format. Multiple instances of
|
||||||
this flag are allowed.
|
this flag are allowed.
|
||||||
@@ -1158,6 +1186,10 @@ Options:
|
|||||||
within. This will only do a direct verification of the items within and
|
within. This will only do a direct verification of the items within and
|
||||||
will create a fixdat afterwards for missing files.
|
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
|
-dat=, --dat= Input DAT to be used
|
||||||
User-supplied DAT for use in all operations. Multiple instances of
|
User-supplied DAT for use in all operations. Multiple instances of
|
||||||
this flag are allowed.
|
this flag are allowed.
|
||||||
|
|||||||
@@ -949,6 +949,23 @@ namespace SabreTools.Core.Tools
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get LogLevel value from input string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logLevel">String to get value from</param>
|
||||||
|
/// <returns>LogLevel value corresponding to the string</returns>
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get MachineField value from input string
|
/// Get MachineField value from input string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
namespace SabreTools.Logging
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Severity of the logging statement
|
|
||||||
/// </summary>
|
|
||||||
public enum LogLevel
|
|
||||||
{
|
|
||||||
VERBOSE = 0,
|
|
||||||
USER,
|
|
||||||
WARNING,
|
|
||||||
ERROR,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
using SabreTools.Core;
|
||||||
|
|
||||||
namespace SabreTools.Logging
|
namespace SabreTools.Logging
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
using SabreTools.Core;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
|
|
||||||
namespace SabreTools.Logging
|
namespace SabreTools.Logging
|
||||||
|
|||||||
@@ -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<string>() { "-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 const string NameStringValue = "name";
|
||||||
internal static Feature NameStringInput
|
internal static Feature NameStringInput
|
||||||
{
|
{
|
||||||
@@ -1735,6 +1750,11 @@ Some special strings that can be used:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected DatHeader Header { get; set; }
|
protected DatHeader Header { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Lowest log level for output
|
||||||
|
/// </summary>
|
||||||
|
public LogLevel LogLevel { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Output directory
|
/// Output directory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1816,6 +1836,7 @@ Some special strings that can be used:
|
|||||||
Extras = GetExtras(features);
|
Extras = GetExtras(features);
|
||||||
Filter = GetFilter(features);
|
Filter = GetFilter(features);
|
||||||
Header = GetDatHeader(features);
|
Header = GetDatHeader(features);
|
||||||
|
LogLevel = GetString(features, LogLevelStringValue).AsLogLevel();
|
||||||
OutputDir = GetString(features, OutputDirStringValue).Trim('"');
|
OutputDir = GetString(features, OutputDirStringValue).Trim('"');
|
||||||
Remover = GetRemover(features);
|
Remover = GetRemover(features);
|
||||||
Splitter = GetSplitter(features);
|
Splitter = GetSplitter(features);
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ Set the output directory: output(outdir);
|
|||||||
Write the internal items: write([overwrite = true]);
|
Write the internal items: write([overwrite = true]);
|
||||||
Reset the internal state: reset();";
|
Reset the internal state: reset();";
|
||||||
Features = new Dictionary<string, Help.Feature>();
|
Features = new Dictionary<string, Help.Feature>();
|
||||||
|
|
||||||
|
// Common Features
|
||||||
|
AddFeature(LogLevelStringInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ProcessFeatures(Dictionary<string, Help.Feature> features)
|
public override void ProcessFeatures(Dictionary<string, Help.Feature> features)
|
||||||
|
|||||||
@@ -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.";
|
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<string, Help.Feature>();
|
Features = new Dictionary<string, Help.Feature>();
|
||||||
|
|
||||||
|
// Common Features
|
||||||
|
AddFeature(LogLevelStringInput);
|
||||||
|
|
||||||
// Hash Features
|
// Hash Features
|
||||||
AddFeature(SkipMd5Flag);
|
AddFeature(SkipMd5Flag);
|
||||||
AddFeature(SkipSha1Flag);
|
AddFeature(SkipSha1Flag);
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ The following systems have headers that this program can work with:
|
|||||||
- Nintendo Super Famicom / Super Nintendo Entertainment System SPC";
|
- Nintendo Super Famicom / Super Nintendo Entertainment System SPC";
|
||||||
Features = new Dictionary<string, Feature>();
|
Features = new Dictionary<string, Feature>();
|
||||||
|
|
||||||
|
// Common Features
|
||||||
|
AddFeature(LogLevelStringInput);
|
||||||
|
|
||||||
AddFeature(OutputDirStringInput);
|
AddFeature(OutputDirStringInput);
|
||||||
AddFeature(NoStoreHeaderFlag);
|
AddFeature(NoStoreHeaderFlag);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ using SabreTools.Help;
|
|||||||
|
|
||||||
namespace SabreTools.Features
|
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
|
internal class Script : BaseFeature
|
||||||
{
|
{
|
||||||
public const string Value = "Script";
|
public const string Value = "Script";
|
||||||
|
|||||||
@@ -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.";
|
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<string, Feature>();
|
Features = new Dictionary<string, Feature>();
|
||||||
|
|
||||||
|
// Common Features
|
||||||
|
AddFeature(LogLevelStringInput);
|
||||||
|
|
||||||
AddFeature(DatListInput);
|
AddFeature(DatListInput);
|
||||||
AddFeature(OutputDirStringInput);
|
AddFeature(OutputDirStringInput);
|
||||||
AddFeature(DepotFlag);
|
AddFeature(DepotFlag);
|
||||||
|
|||||||
@@ -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.";
|
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<string, Help.Feature>();
|
Features = new Dictionary<string, Help.Feature>();
|
||||||
|
|
||||||
|
// Common Features
|
||||||
|
AddFeature(LogLevelStringInput);
|
||||||
|
|
||||||
AddFeature(OutputTypeListInput);
|
AddFeature(OutputTypeListInput);
|
||||||
this[OutputTypeListInput].AddFeature(DeprecatedFlag);
|
this[OutputTypeListInput].AddFeature(DeprecatedFlag);
|
||||||
AddFeature(OutputDirStringInput);
|
AddFeature(OutputDirStringInput);
|
||||||
|
|||||||
@@ -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.";
|
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<string, Feature>();
|
Features = new Dictionary<string, Feature>();
|
||||||
|
|
||||||
|
// Common Features
|
||||||
|
AddFeature(LogLevelStringInput);
|
||||||
|
|
||||||
AddFeature(DatListInput);
|
AddFeature(DatListInput);
|
||||||
AddFeature(DepotFlag);
|
AddFeature(DepotFlag);
|
||||||
this[DepotFlag].AddFeature(DepotDepthInt32Input);
|
this[DepotFlag].AddFeature(DepotDepthInt32Input);
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
using SabreTools.Features;
|
|
||||||
using SabreTools.Core;
|
using SabreTools.Core;
|
||||||
|
using SabreTools.Features;
|
||||||
using SabreTools.Help;
|
using SabreTools.Help;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
@@ -109,6 +109,9 @@ namespace SabreTools
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the new log level based on settings
|
||||||
|
LoggerImpl.LowestLogLevel = feature.LogLevel;
|
||||||
|
|
||||||
// Now process the current feature
|
// Now process the current feature
|
||||||
Dictionary<string, Feature> features = _help.GetEnabledFeatures();
|
Dictionary<string, Feature> features = _help.GetEnabledFeatures();
|
||||||
switch (featureName)
|
switch (featureName)
|
||||||
|
|||||||
Reference in New Issue
Block a user