mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add progression logging
This commit is contained in:
@@ -44,6 +44,17 @@ namespace SabreTools.Library.Logging
|
|||||||
LoggerImpl.Verbose(this.instance, output);
|
LoggerImpl.Verbose(this.instance, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the given verbose progress message to the log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="total">Total count for progress</param>
|
||||||
|
/// <param name="current">Current count for progres</param>
|
||||||
|
/// <param name="output">String to be written log</param>
|
||||||
|
public void Verbose(long total, long current, string output = null)
|
||||||
|
{
|
||||||
|
LoggerImpl.Verbose(instance, total, current, output);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write the given exception as a user message to the log output
|
/// Write the given exception as a user message to the log output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -65,6 +76,17 @@ namespace SabreTools.Library.Logging
|
|||||||
LoggerImpl.User(this.instance, output);
|
LoggerImpl.User(this.instance, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the given user progress message to the log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="total">Total count for progress</param>
|
||||||
|
/// <param name="current">Current count for progres</param>
|
||||||
|
/// <param name="output">String to be written log</param>
|
||||||
|
public void User(long total, long current, string output = null)
|
||||||
|
{
|
||||||
|
LoggerImpl.User(instance, total, current, output);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write the given exception as a warning to the log output
|
/// Write the given exception as a warning to the log output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -86,6 +108,17 @@ namespace SabreTools.Library.Logging
|
|||||||
LoggerImpl.Warning(this.instance, output);
|
LoggerImpl.Warning(this.instance, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the given warning progress message to the log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="total">Total count for progress</param>
|
||||||
|
/// <param name="current">Current count for progres</param>
|
||||||
|
/// <param name="output">String to be written log</param>
|
||||||
|
public void Warning(long total, long current, string output = null)
|
||||||
|
{
|
||||||
|
LoggerImpl.Warning(instance, total, current, output);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes the given exception as an error in the log
|
/// Writes the given exception as an error in the log
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -107,6 +140,17 @@ namespace SabreTools.Library.Logging
|
|||||||
LoggerImpl.Error(this.instance, output);
|
LoggerImpl.Error(this.instance, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the given error progress message to the log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="total">Total count for progress</param>
|
||||||
|
/// <param name="current">Current count for progres</param>
|
||||||
|
/// <param name="output">String to be written log</param>
|
||||||
|
public void Error(long total, long current, string output = null)
|
||||||
|
{
|
||||||
|
LoggerImpl.Error(instance, total, current, output);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,18 +216,18 @@ namespace SabreTools.Library.Logging
|
|||||||
|
|
||||||
// Setup the statement based on the inputs
|
// Setup the statement based on the inputs
|
||||||
string logLine;
|
string logLine;
|
||||||
if (args.Exception == null)
|
if (args.Exception != null)
|
||||||
{
|
{
|
||||||
logLine = args.Statement ?? string.Empty;
|
logLine = $"{(args.Statement != null ? args.Statement + ": " : string.Empty)}{args.Exception}";
|
||||||
}
|
}
|
||||||
else if (args.TotalCount != null && args.CurrentCount != null)
|
else if (args.TotalCount != null && args.CurrentCount != null)
|
||||||
{
|
{
|
||||||
double percentage = (args.CurrentCount.Value / args.TotalCount.Value) * 100;
|
double percentage = ((double)args.CurrentCount.Value / args.TotalCount.Value) * 100;
|
||||||
logLine = $"{percentage:N2}%{(args.Statement != null ? ": " + args.Statement : string.Empty)}";
|
logLine = $"{percentage:N2}%{(args.Statement != null ? ": " + args.Statement : string.Empty)}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logLine = $"{(args.Statement != null ? args.Statement + ": " : string.Empty)}{args.Exception}";
|
logLine = args.Statement ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then write to the log
|
// Then write to the log
|
||||||
@@ -298,6 +298,18 @@ namespace SabreTools.Library.Logging
|
|||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.VERBOSE, output, null));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.VERBOSE, output, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the given verbose progress message to the log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="instance">Instance object that's the source of logging</param>
|
||||||
|
/// <param name="total">Total count for progress</param>
|
||||||
|
/// <param name="current">Current count for progres</param>
|
||||||
|
/// <param name="output">String to be written log</param>
|
||||||
|
internal static void Verbose(object instance, long total, long current, string output = null)
|
||||||
|
{
|
||||||
|
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.VERBOSE, output));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write the given exception as a user message to the log output
|
/// Write the given exception as a user message to the log output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -321,6 +333,18 @@ namespace SabreTools.Library.Logging
|
|||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.USER, output, null));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.USER, output, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the given user progress message to the log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="instance">Instance object that's the source of logging</param>
|
||||||
|
/// <param name="total">Total count for progress</param>
|
||||||
|
/// <param name="current">Current count for progres</param>
|
||||||
|
/// <param name="output">String to be written log</param>
|
||||||
|
internal static void User(object instance, long total, long current, string output = null)
|
||||||
|
{
|
||||||
|
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.USER, output));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write the given exception as a warning to the log output
|
/// Write the given exception as a warning to the log output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -344,6 +368,18 @@ namespace SabreTools.Library.Logging
|
|||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.WARNING, output, null));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.WARNING, output, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the given warning progress message to the log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="instance">Instance object that's the source of logging</param>
|
||||||
|
/// <param name="total">Total count for progress</param>
|
||||||
|
/// <param name="current">Current count for progres</param>
|
||||||
|
/// <param name="output">String to be written log</param>
|
||||||
|
internal static void Warning(object instance, long total, long current, string output = null)
|
||||||
|
{
|
||||||
|
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.WARNING, output));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes the given exception as an error in the log
|
/// Writes the given exception as an error in the log
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -367,6 +403,18 @@ namespace SabreTools.Library.Logging
|
|||||||
LogEventHandler(instance, new LogEventArgs(LogLevel.ERROR, output, null));
|
LogEventHandler(instance, new LogEventArgs(LogLevel.ERROR, output, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the given error progress message to the log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="instance">Instance object that's the source of logging</param>
|
||||||
|
/// <param name="total">Total count for progress</param>
|
||||||
|
/// <param name="current">Current count for progres</param>
|
||||||
|
/// <param name="output">String to be written log</param>
|
||||||
|
internal static void Error(object instance, long total, long current, string output = null)
|
||||||
|
{
|
||||||
|
LogEventHandler(instance, new LogEventArgs(total, current, LogLevel.ERROR, output));
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user