2016-03-28 17:54:24 -07:00
|
|
|
|
using System;
|
2017-03-01 21:58:09 -08:00
|
|
|
|
|
2020-12-07 14:29:45 -08:00
|
|
|
|
namespace SabreTools.Logging
|
2016-03-28 17:54:24 -07:00
|
|
|
|
{
|
2019-02-08 21:03:28 -08:00
|
|
|
|
/// <summary>
|
2020-10-07 15:42:30 -07:00
|
|
|
|
/// Per-class logging
|
2019-02-08 21:03:28 -08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class Logger
|
|
|
|
|
|
{
|
2020-10-07 13:16:53 -07:00
|
|
|
|
/// <summary>
|
2020-10-07 15:42:30 -07:00
|
|
|
|
/// Instance associated with this logger
|
2020-10-07 13:16:53 -07:00
|
|
|
|
/// </summary>
|
2020-10-07 15:42:30 -07:00
|
|
|
|
/// TODO: Derive class name for this object, if possible
|
2024-07-17 16:01:22 -04:00
|
|
|
|
private readonly object? _instance;
|
2024-07-17 15:46:42 -04:00
|
|
|
|
|
2019-02-08 21:03:28 -08:00
|
|
|
|
/// <summary>
|
2020-10-07 15:42:30 -07:00
|
|
|
|
/// Constructor
|
2019-02-08 21:03:28 -08:00
|
|
|
|
/// </summary>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public Logger(object? instance = null)
|
2019-02-08 21:03:28 -08:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
_instance = instance;
|
2019-02-08 21:03:28 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-07 13:16:53 -07:00
|
|
|
|
#region Log Event Triggers
|
2019-02-08 21:03:28 -08:00
|
|
|
|
|
2020-09-15 17:09:35 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write the given exception as a verbose message to the log output
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ex">Exception 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>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public void Verbose(Exception ex, string? output = null)
|
2020-09-15 17:09:35 -07:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.Verbose(_instance, ex, output);
|
2020-09-15 17:09:35 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-08 21:03:28 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write the given string as a verbose message to the log output
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="output">String to be written log</param>
|
|
|
|
|
|
/// <returns>True if the output could be written, false otherwise</returns>
|
2020-10-07 13:16:53 -07:00
|
|
|
|
public void Verbose(string output)
|
2019-02-08 21:03:28 -08:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.Verbose(_instance, output);
|
2019-02-08 21:03:28 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-12 11:11:14 -07:00
|
|
|
|
/// <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>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public void Verbose(long total, long current, string? output = null)
|
2020-10-12 11:11:14 -07:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.Verbose(_instance, total, current, output);
|
2020-10-12 11:11:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-09-15 17:09:35 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write the given exception as a user message to the log output
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ex">Exception 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>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public void User(Exception ex, string? output = null)
|
2020-09-15 17:09:35 -07:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.User(_instance, ex, output);
|
2020-09-15 17:09:35 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-08 21:03:28 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write the given string as a user message to the log output
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="output">String to be written log</param>
|
|
|
|
|
|
/// <returns>True if the output could be written, false otherwise</returns>
|
2020-10-07 13:16:53 -07:00
|
|
|
|
public void User(string output)
|
2019-02-08 21:03:28 -08:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.User(_instance, output);
|
2019-02-08 21:03:28 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-12 11:11:14 -07:00
|
|
|
|
/// <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>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public void User(long total, long current, string? output = null)
|
2020-10-12 11:11:14 -07:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.User(_instance, total, current, output);
|
2020-10-12 11:11:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-09-15 14:38:37 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write the given exception as a warning to the log output
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ex">Exception 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>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public void Warning(Exception ex, string? output = null)
|
2020-09-15 14:38:37 -07:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.Warning(_instance, ex, output);
|
2020-09-15 14:38:37 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-08 21:03:28 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write the given string as a warning to the log output
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="output">String to be written log</param>
|
|
|
|
|
|
/// <returns>True if the output could be written, false otherwise</returns>
|
2020-10-07 13:16:53 -07:00
|
|
|
|
public void Warning(string output)
|
2019-02-08 21:03:28 -08:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.Warning(_instance, output);
|
2019-02-08 21:03:28 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-12 11:11:14 -07:00
|
|
|
|
/// <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>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public void Warning(long total, long current, string? output = null)
|
2020-10-12 11:11:14 -07:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.Warning(_instance, total, current, output);
|
2020-10-12 11:11:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-09-15 14:38:37 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Writes the given exception as an error in the log
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ex">Exception 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>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public void Error(Exception ex, string? output = null)
|
2020-09-15 14:38:37 -07:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.Error(_instance, ex, output);
|
2020-09-15 14:38:37 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-08 21:03:28 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Writes the given string as an error in the log
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="output">String to be written log</param>
|
|
|
|
|
|
/// <returns>True if the output could be written, false otherwise</returns>
|
2020-10-07 13:16:53 -07:00
|
|
|
|
public void Error(string output)
|
2019-02-08 21:03:28 -08:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.Error(_instance, output);
|
2019-02-08 21:03:28 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-12 11:11:14 -07:00
|
|
|
|
/// <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>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public void Error(long total, long current, string? output = null)
|
2020-10-12 11:11:14 -07:00
|
|
|
|
{
|
2024-07-17 16:01:22 -04:00
|
|
|
|
LoggerImpl.Error(_instance, total, current, output);
|
2020-10-12 11:11:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-07 13:16:53 -07:00
|
|
|
|
#endregion
|
2019-02-08 21:03:28 -08:00
|
|
|
|
}
|
2016-03-28 17:54:24 -07:00
|
|
|
|
}
|